Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/bootstrapper.cc

Issue 10782033: Removed CopyAppendForeignDescriptor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed test Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 859
860 { // --- A r r a y --- 860 { // --- A r r a y ---
861 Handle<JSFunction> array_function = 861 Handle<JSFunction> array_function =
862 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 862 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
863 isolate->initial_object_prototype(), 863 isolate->initial_object_prototype(),
864 Builtins::kArrayCode, true); 864 Builtins::kArrayCode, true);
865 array_function->shared()->set_construct_stub( 865 array_function->shared()->set_construct_stub(
866 isolate->builtins()->builtin(Builtins::kArrayConstructCode)); 866 isolate->builtins()->builtin(Builtins::kArrayConstructCode));
867 array_function->shared()->DontAdaptArguments(); 867 array_function->shared()->DontAdaptArguments();
868 868
869
869 // This seems a bit hackish, but we need to make sure Array.length 870 // This seems a bit hackish, but we need to make sure Array.length
870 // is 1. 871 // is 1.
871 array_function->shared()->set_length(1); 872 array_function->shared()->set_length(1);
872 Handle<DescriptorArray> array_descriptors = 873
873 factory->CopyAppendForeignDescriptor( 874 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1));
874 factory->empty_descriptor_array(), 875 PropertyAttributes attribs = static_cast<PropertyAttributes>(
875 factory->length_symbol(), 876 DONT_ENUM | DONT_DELETE);
876 factory->NewForeign(&Accessors::ArrayLength), 877
877 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); 878 DescriptorArray::WhitenessWitness witness(*array_descriptors);
879
880 { // Add length.
881 Handle<Foreign> f(factory->NewForeign(&Accessors::ArrayLength));
882 CallbacksDescriptor d(*factory->length_symbol(), *f, attribs);
883 array_descriptors->Append(&d, witness);
884 }
878 885
879 // array_function is used internally. JS code creating array object should 886 // array_function is used internally. JS code creating array object should
880 // search for the 'Array' property on the global object and use that one 887 // search for the 'Array' property on the global object and use that one
881 // as the constructor. 'Array' property on a global object can be 888 // as the constructor. 'Array' property on a global object can be
882 // overwritten by JS code. 889 // overwritten by JS code.
883 global_context()->set_array_function(*array_function); 890 global_context()->set_array_function(*array_function);
884 array_function->initial_map()->set_instance_descriptors(*array_descriptors); 891 array_function->initial_map()->set_instance_descriptors(*array_descriptors);
885 } 892 }
886 893
887 { // --- N u m b e r --- 894 { // --- N u m b e r ---
(...skipping 13 matching lines...) Expand all
901 } 908 }
902 909
903 { // --- S t r i n g --- 910 { // --- S t r i n g ---
904 Handle<JSFunction> string_fun = 911 Handle<JSFunction> string_fun =
905 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, 912 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize,
906 isolate->initial_object_prototype(), 913 isolate->initial_object_prototype(),
907 Builtins::kIllegal, true); 914 Builtins::kIllegal, true);
908 string_fun->shared()->set_construct_stub( 915 string_fun->shared()->set_construct_stub(
909 isolate->builtins()->builtin(Builtins::kStringConstructCode)); 916 isolate->builtins()->builtin(Builtins::kStringConstructCode));
910 global_context()->set_string_function(*string_fun); 917 global_context()->set_string_function(*string_fun);
911 // Add 'length' property to strings. 918
912 Handle<DescriptorArray> string_descriptors = 919 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1));
913 factory->CopyAppendForeignDescriptor( 920 PropertyAttributes attribs = static_cast<PropertyAttributes>(
914 factory->empty_descriptor_array(), 921 DONT_ENUM | DONT_DELETE | READ_ONLY);
915 factory->length_symbol(), 922
916 factory->NewForeign(&Accessors::StringLength), 923 DescriptorArray::WhitenessWitness witness(*string_descriptors);
917 static_cast<PropertyAttributes>(DONT_ENUM | 924
918 DONT_DELETE | 925 { // Add length.
919 READ_ONLY)); 926 Handle<Foreign> f(factory->NewForeign(&Accessors::StringLength));
927 CallbacksDescriptor d(*factory->length_symbol(), *f, attribs);
928 string_descriptors->Append(&d, witness);
929 }
920 930
921 Handle<Map> string_map = 931 Handle<Map> string_map =
922 Handle<Map>(global_context()->string_function()->initial_map()); 932 Handle<Map>(global_context()->string_function()->initial_map());
923 string_map->set_instance_descriptors(*string_descriptors); 933 string_map->set_instance_descriptors(*string_descriptors);
924 } 934 }
925 935
926 { // --- D a t e --- 936 { // --- D a t e ---
927 // Builtin functions for Date.prototype. 937 // Builtin functions for Date.prototype.
928 Handle<JSFunction> date_fun = 938 Handle<JSFunction> date_fun =
929 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, 939 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize,
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 // Builtin functions for Script. 1475 // Builtin functions for Script.
1466 Handle<JSFunction> script_fun = 1476 Handle<JSFunction> script_fun =
1467 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, 1477 InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize,
1468 isolate()->initial_object_prototype(), 1478 isolate()->initial_object_prototype(),
1469 Builtins::kIllegal, false); 1479 Builtins::kIllegal, false);
1470 Handle<JSObject> prototype = 1480 Handle<JSObject> prototype =
1471 factory()->NewJSObject(isolate()->object_function(), TENURED); 1481 factory()->NewJSObject(isolate()->object_function(), TENURED);
1472 SetPrototype(script_fun, prototype); 1482 SetPrototype(script_fun, prototype);
1473 global_context()->set_script_function(*script_fun); 1483 global_context()->set_script_function(*script_fun);
1474 1484
1475 // Add 'source' and 'data' property to scripts. 1485 PropertyAttributes attribs =
1476 PropertyAttributes common_attributes =
1477 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1486 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1478 Handle<Foreign> foreign_source = 1487
1479 factory()->NewForeign(&Accessors::ScriptSource); 1488 Handle<DescriptorArray> script_descriptors(
1480 Handle<DescriptorArray> script_descriptors = 1489 factory()->NewDescriptorArray(13));
1481 factory()->CopyAppendForeignDescriptor( 1490
1482 factory()->empty_descriptor_array(), 1491 DescriptorArray::WhitenessWitness witness(*script_descriptors);
1483 factory()->LookupAsciiSymbol("source"), 1492
1484 foreign_source, 1493 {
1485 common_attributes); 1494 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptSource));
1486 Handle<Foreign> foreign_name = 1495 CallbacksDescriptor d(
1487 factory()->NewForeign(&Accessors::ScriptName); 1496 *factory()->LookupAsciiSymbol("source"), *f, attribs);
1488 script_descriptors = 1497 script_descriptors->Append(&d, witness);
1489 factory()->CopyAppendForeignDescriptor( 1498 }
1490 script_descriptors, 1499
1491 factory()->LookupAsciiSymbol("name"), 1500 {
1492 foreign_name, 1501 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptName));
1493 common_attributes); 1502 CallbacksDescriptor d(
1494 Handle<Foreign> foreign_id = factory()->NewForeign(&Accessors::ScriptId); 1503 *factory()->LookupAsciiSymbol("name"), *f, attribs);
1495 script_descriptors = 1504 script_descriptors->Append(&d, witness);
1496 factory()->CopyAppendForeignDescriptor( 1505 }
1497 script_descriptors, 1506
1498 factory()->LookupAsciiSymbol("id"), 1507 {
1499 foreign_id, 1508 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptId));
1500 common_attributes); 1509 CallbacksDescriptor d(
1501 Handle<Foreign> foreign_line_offset = 1510 *factory()->LookupAsciiSymbol("id"), *f, attribs);
1502 factory()->NewForeign(&Accessors::ScriptLineOffset); 1511 script_descriptors->Append(&d, witness);
1503 script_descriptors = 1512 }
1504 factory()->CopyAppendForeignDescriptor( 1513
1505 script_descriptors, 1514 {
1506 factory()->LookupAsciiSymbol("line_offset"), 1515 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptLineOffset));
1507 foreign_line_offset, 1516 CallbacksDescriptor d(
1508 common_attributes); 1517 *factory()->LookupAsciiSymbol("line_offset"), *f, attribs);
1509 Handle<Foreign> foreign_column_offset = 1518 script_descriptors->Append(&d, witness);
1510 factory()->NewForeign(&Accessors::ScriptColumnOffset); 1519 }
1511 script_descriptors = 1520
1512 factory()->CopyAppendForeignDescriptor( 1521 {
1513 script_descriptors, 1522 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptColumnOffset));
1514 factory()->LookupAsciiSymbol("column_offset"), 1523 CallbacksDescriptor d(
1515 foreign_column_offset, 1524 *factory()->LookupAsciiSymbol("column_offset"), *f, attribs);
1516 common_attributes); 1525 script_descriptors->Append(&d, witness);
1517 Handle<Foreign> foreign_data = 1526 }
1518 factory()->NewForeign(&Accessors::ScriptData); 1527
1519 script_descriptors = 1528 {
1520 factory()->CopyAppendForeignDescriptor( 1529 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptData));
1521 script_descriptors, 1530 CallbacksDescriptor d(
1522 factory()->LookupAsciiSymbol("data"), 1531 *factory()->LookupAsciiSymbol("data"), *f, attribs);
1523 foreign_data, 1532 script_descriptors->Append(&d, witness);
1524 common_attributes); 1533 }
1525 Handle<Foreign> foreign_type = 1534
1526 factory()->NewForeign(&Accessors::ScriptType); 1535 {
1527 script_descriptors = 1536 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptType));
1528 factory()->CopyAppendForeignDescriptor( 1537 CallbacksDescriptor d(
1529 script_descriptors, 1538 *factory()->LookupAsciiSymbol("type"), *f, attribs);
1530 factory()->LookupAsciiSymbol("type"), 1539 script_descriptors->Append(&d, witness);
1531 foreign_type, 1540 }
1532 common_attributes); 1541
1533 Handle<Foreign> foreign_compilation_type = 1542 {
1534 factory()->NewForeign(&Accessors::ScriptCompilationType); 1543 Handle<Foreign> f(factory()->NewForeign(
1535 script_descriptors = 1544 &Accessors::ScriptCompilationType));
1536 factory()->CopyAppendForeignDescriptor( 1545 CallbacksDescriptor d(
1537 script_descriptors, 1546 *factory()->LookupAsciiSymbol("compilation_type"), *f, attribs);
1538 factory()->LookupAsciiSymbol("compilation_type"), 1547 script_descriptors->Append(&d, witness);
1539 foreign_compilation_type, 1548 }
1540 common_attributes); 1549
1541 Handle<Foreign> foreign_line_ends = 1550 {
1542 factory()->NewForeign(&Accessors::ScriptLineEnds); 1551 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptLineEnds));
1543 script_descriptors = 1552 CallbacksDescriptor d(
1544 factory()->CopyAppendForeignDescriptor( 1553 *factory()->LookupAsciiSymbol("line_ends"), *f, attribs);
1545 script_descriptors, 1554 script_descriptors->Append(&d, witness);
1546 factory()->LookupAsciiSymbol("line_ends"), 1555 }
1547 foreign_line_ends, 1556
1548 common_attributes); 1557 {
1549 Handle<Foreign> foreign_context_data = 1558 Handle<Foreign> f(factory()->NewForeign(&Accessors::ScriptContextData));
1550 factory()->NewForeign(&Accessors::ScriptContextData); 1559 CallbacksDescriptor d(
1551 script_descriptors = 1560 *factory()->LookupAsciiSymbol("context_data"), *f, attribs);
1552 factory()->CopyAppendForeignDescriptor( 1561 script_descriptors->Append(&d, witness);
1553 script_descriptors, 1562 }
1554 factory()->LookupAsciiSymbol("context_data"), 1563
1555 foreign_context_data, 1564 {
1556 common_attributes); 1565 Handle<Foreign> f(factory()->NewForeign(
1557 Handle<Foreign> foreign_eval_from_script = 1566 &Accessors::ScriptEvalFromScript));
1558 factory()->NewForeign(&Accessors::ScriptEvalFromScript); 1567 CallbacksDescriptor d(
1559 script_descriptors = 1568 *factory()->LookupAsciiSymbol("eval_from_script"), *f, attribs);
1560 factory()->CopyAppendForeignDescriptor( 1569 script_descriptors->Append(&d, witness);
1561 script_descriptors, 1570 }
1562 factory()->LookupAsciiSymbol("eval_from_script"), 1571
1563 foreign_eval_from_script, 1572 {
1564 common_attributes); 1573 Handle<Foreign> f(factory()->NewForeign(
1565 Handle<Foreign> foreign_eval_from_script_position = 1574 &Accessors::ScriptEvalFromScriptPosition));
1566 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition); 1575 CallbacksDescriptor d(
1567 script_descriptors = 1576 *factory()->LookupAsciiSymbol("eval_from_script_position"),
1568 factory()->CopyAppendForeignDescriptor( 1577 *f,
1569 script_descriptors, 1578 attribs);
1570 factory()->LookupAsciiSymbol("eval_from_script_position"), 1579 script_descriptors->Append(&d, witness);
1571 foreign_eval_from_script_position, 1580 }
1572 common_attributes); 1581
1573 Handle<Foreign> foreign_eval_from_function_name = 1582 {
1574 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName); 1583 Handle<Foreign> f(factory()->NewForeign(
1575 script_descriptors = 1584 &Accessors::ScriptEvalFromFunctionName));
1576 factory()->CopyAppendForeignDescriptor( 1585 CallbacksDescriptor d(
1577 script_descriptors, 1586 *factory()->LookupAsciiSymbol("eval_from_function_name"),
1578 factory()->LookupAsciiSymbol("eval_from_function_name"), 1587 *f,
1579 foreign_eval_from_function_name, 1588 attribs);
1580 common_attributes); 1589 script_descriptors->Append(&d, witness);
1590 }
1591
1592 script_descriptors->Sort(witness);
1581 1593
1582 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); 1594 Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1583 script_map->set_instance_descriptors(*script_descriptors); 1595 script_map->set_instance_descriptors(*script_descriptors);
1584 1596
1585 // Allocate the empty script. 1597 // Allocate the empty script.
1586 Handle<Script> script = factory()->NewScript(factory()->empty_string()); 1598 Handle<Script> script = factory()->NewScript(factory()->empty_string());
1587 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 1599 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1588 heap()->public_set_empty_script(*script); 1600 heap()->public_set_empty_script(*script);
1589 } 1601 }
1590 { 1602 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT 1642 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT
1631 // transition easy to trap. Moreover, they rarely are smi-only. 1643 // transition easy to trap. Moreover, they rarely are smi-only.
1632 MaybeObject* maybe_map = 1644 MaybeObject* maybe_map =
1633 array_function->initial_map()->Copy(DescriptorArray::MAY_BE_SHARED); 1645 array_function->initial_map()->Copy(DescriptorArray::MAY_BE_SHARED);
1634 Map* new_map; 1646 Map* new_map;
1635 if (!maybe_map->To(&new_map)) return false; 1647 if (!maybe_map->To(&new_map)) return false;
1636 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); 1648 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS);
1637 array_function->set_initial_map(new_map); 1649 array_function->set_initial_map(new_map);
1638 1650
1639 // Make "length" magic on instances. 1651 // Make "length" magic on instances.
1640 Handle<DescriptorArray> array_descriptors = 1652 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1));
1641 factory()->CopyAppendForeignDescriptor( 1653 PropertyAttributes attribs = static_cast<PropertyAttributes>(
1642 factory()->empty_descriptor_array(), 1654 DONT_ENUM | DONT_DELETE);
1643 factory()->length_symbol(), 1655
1644 factory()->NewForeign(&Accessors::ArrayLength), 1656 DescriptorArray::WhitenessWitness witness(*array_descriptors);
1645 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); 1657
1658 { // Add length.
1659 Handle<Foreign> f(factory()->NewForeign(&Accessors::ArrayLength));
1660 CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs);
1661 array_descriptors->Append(&d, witness);
1662 }
1646 1663
1647 array_function->initial_map()->set_instance_descriptors( 1664 array_function->initial_map()->set_instance_descriptors(
1648 *array_descriptors); 1665 *array_descriptors);
1649 1666
1650 global_context()->set_internal_array_function(*array_function); 1667 global_context()->set_internal_array_function(*array_function);
1651 } 1668 }
1652 1669
1653 if (FLAG_disable_native_files) { 1670 if (FLAG_disable_native_files) {
1654 PrintF("Warning: Running without installed natives!\n"); 1671 PrintF("Warning: Running without installed natives!\n");
1655 return true; 1672 return true;
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 return from + sizeof(NestingCounterType); 2370 return from + sizeof(NestingCounterType);
2354 } 2371 }
2355 2372
2356 2373
2357 // Called when the top-level V8 mutex is destroyed. 2374 // Called when the top-level V8 mutex is destroyed.
2358 void Bootstrapper::FreeThreadResources() { 2375 void Bootstrapper::FreeThreadResources() {
2359 ASSERT(!IsActive()); 2376 ASSERT(!IsActive());
2360 } 2377 }
2361 2378
2362 } } // namespace v8::internal 2379 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698