OLD | NEW |
---|---|
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); | 392 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); |
393 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); | 393 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); |
394 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); | 394 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); |
395 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); | 395 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); |
396 Handle<Foreign> prototype; | 396 Handle<Foreign> prototype; |
397 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 397 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
398 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); | 398 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); |
399 } | 399 } |
400 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 400 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
401 DONT_ENUM | DONT_DELETE | READ_ONLY); | 401 DONT_ENUM | DONT_DELETE | READ_ONLY); |
402 map->set_instance_descriptors(*descriptors); | 402 Map::SetDescriptors(map, descriptors); |
403 | 403 |
404 { // Add length. | 404 { // Add length. |
405 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); | 405 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); |
406 map->AppendDescriptor(&d, witness); | 406 map->AppendDescriptor(&d, witness); |
407 } | 407 } |
408 { // Add name. | 408 { // Add name. |
409 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); | 409 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); |
410 map->AppendDescriptor(&d, witness); | 410 map->AppendDescriptor(&d, witness); |
411 } | 411 } |
412 { // Add arguments. | 412 { // Add arguments. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); | 533 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); |
534 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); | 534 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); |
535 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); | 535 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); |
536 Handle<AccessorPair> caller(factory()->NewAccessorPair()); | 536 Handle<AccessorPair> caller(factory()->NewAccessorPair()); |
537 Handle<Foreign> prototype; | 537 Handle<Foreign> prototype; |
538 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 538 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
539 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); | 539 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); |
540 } | 540 } |
541 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 541 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
542 DONT_ENUM | DONT_DELETE); | 542 DONT_ENUM | DONT_DELETE); |
543 map->set_instance_descriptors(*descriptors); | 543 |
Michael Starzinger
2012/08/12 18:18:08
Drop the empty newline.
| |
544 Map::SetDescriptors(map, descriptors); | |
544 | 545 |
545 { // Add length. | 546 { // Add length. |
546 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); | 547 CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); |
547 map->AppendDescriptor(&d, witness); | 548 map->AppendDescriptor(&d, witness); |
548 } | 549 } |
549 { // Add name. | 550 { // Add name. |
550 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); | 551 CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); |
551 map->AppendDescriptor(&d, witness); | 552 map->AppendDescriptor(&d, witness); |
552 } | 553 } |
553 { // Add arguments. | 554 { // Add arguments. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
860 isolate->initial_object_prototype(), | 861 isolate->initial_object_prototype(), |
861 Builtins::kArrayCode, true); | 862 Builtins::kArrayCode, true); |
862 array_function->shared()->set_construct_stub( | 863 array_function->shared()->set_construct_stub( |
863 isolate->builtins()->builtin(Builtins::kArrayConstructCode)); | 864 isolate->builtins()->builtin(Builtins::kArrayConstructCode)); |
864 array_function->shared()->DontAdaptArguments(); | 865 array_function->shared()->DontAdaptArguments(); |
865 | 866 |
866 // This seems a bit hackish, but we need to make sure Array.length | 867 // This seems a bit hackish, but we need to make sure Array.length |
867 // is 1. | 868 // is 1. |
868 array_function->shared()->set_length(1); | 869 array_function->shared()->set_length(1); |
869 | 870 |
871 Handle<Map> initial_map(array_function->initial_map()); | |
870 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1)); | 872 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1)); |
871 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 873 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
872 | 874 |
873 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); | 875 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); |
874 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 876 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
875 DONT_ENUM | DONT_DELETE); | 877 DONT_ENUM | DONT_DELETE); |
876 array_function->initial_map()->set_instance_descriptors(*array_descriptors); | 878 Map::SetDescriptors(initial_map, array_descriptors); |
877 | 879 |
878 { // Add length. | 880 { // Add length. |
879 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); | 881 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); |
880 array_function->initial_map()->AppendDescriptor(&d, witness); | 882 array_function->initial_map()->AppendDescriptor(&d, witness); |
881 } | 883 } |
882 | 884 |
883 // array_function is used internally. JS code creating array object should | 885 // array_function is used internally. JS code creating array object should |
884 // search for the 'Array' property on the global object and use that one | 886 // search for the 'Array' property on the global object and use that one |
885 // as the constructor. 'Array' property on a global object can be | 887 // as the constructor. 'Array' property on a global object can be |
886 // overwritten by JS code. | 888 // overwritten by JS code. |
(...skipping 27 matching lines...) Expand all Loading... | |
914 | 916 |
915 Handle<Map> string_map = | 917 Handle<Map> string_map = |
916 Handle<Map>(global_context()->string_function()->initial_map()); | 918 Handle<Map>(global_context()->string_function()->initial_map()); |
917 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1)); | 919 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1)); |
918 DescriptorArray::WhitenessWitness witness(*string_descriptors); | 920 DescriptorArray::WhitenessWitness witness(*string_descriptors); |
919 | 921 |
920 Handle<Foreign> string_length( | 922 Handle<Foreign> string_length( |
921 factory->NewForeign(&Accessors::StringLength)); | 923 factory->NewForeign(&Accessors::StringLength)); |
922 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 924 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
923 DONT_ENUM | DONT_DELETE | READ_ONLY); | 925 DONT_ENUM | DONT_DELETE | READ_ONLY); |
924 string_map->set_instance_descriptors(*string_descriptors); | 926 Map::SetDescriptors(string_map, string_descriptors); |
925 | 927 |
926 { // Add length. | 928 { // Add length. |
927 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); | 929 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); |
928 string_map->AppendDescriptor(&d, witness); | 930 string_map->AppendDescriptor(&d, witness); |
929 } | 931 } |
930 } | 932 } |
931 | 933 |
932 { // --- D a t e --- | 934 { // --- D a t e --- |
933 // Builtin functions for Date.prototype. | 935 // Builtin functions for Date.prototype. |
934 Handle<JSFunction> date_fun = | 936 Handle<JSFunction> date_fun = |
(...skipping 15 matching lines...) Expand all Loading... | |
950 | 952 |
951 ASSERT(regexp_fun->has_initial_map()); | 953 ASSERT(regexp_fun->has_initial_map()); |
952 Handle<Map> initial_map(regexp_fun->initial_map()); | 954 Handle<Map> initial_map(regexp_fun->initial_map()); |
953 | 955 |
954 ASSERT_EQ(0, initial_map->inobject_properties()); | 956 ASSERT_EQ(0, initial_map->inobject_properties()); |
955 | 957 |
956 PropertyAttributes final = | 958 PropertyAttributes final = |
957 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 959 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
958 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); | 960 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); |
959 DescriptorArray::WhitenessWitness witness(*descriptors); | 961 DescriptorArray::WhitenessWitness witness(*descriptors); |
960 initial_map->set_instance_descriptors(*descriptors); | 962 Map::SetDescriptors(initial_map, descriptors); |
961 | 963 |
962 { | 964 { |
963 // ECMA-262, section 15.10.7.1. | 965 // ECMA-262, section 15.10.7.1. |
964 FieldDescriptor field(heap->source_symbol(), | 966 FieldDescriptor field(heap->source_symbol(), |
965 JSRegExp::kSourceFieldIndex, | 967 JSRegExp::kSourceFieldIndex, |
966 final); | 968 final); |
967 initial_map->AppendDescriptor(&field, witness); | 969 initial_map->AppendDescriptor(&field, witness); |
968 } | 970 } |
969 { | 971 { |
970 // ECMA-262, section 15.10.7.2. | 972 // ECMA-262, section 15.10.7.2. |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1134 callee->set_setter(*throw_function); | 1136 callee->set_setter(*throw_function); |
1135 caller->set_getter(*throw_function); | 1137 caller->set_getter(*throw_function); |
1136 caller->set_setter(*throw_function); | 1138 caller->set_setter(*throw_function); |
1137 | 1139 |
1138 // Create the map. Allocate one in-object field for length. | 1140 // Create the map. Allocate one in-object field for length. |
1139 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, | 1141 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, |
1140 Heap::kArgumentsObjectSizeStrict); | 1142 Heap::kArgumentsObjectSizeStrict); |
1141 // Create the descriptor array for the arguments object. | 1143 // Create the descriptor array for the arguments object. |
1142 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 1144 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); |
1143 DescriptorArray::WhitenessWitness witness(*descriptors); | 1145 DescriptorArray::WhitenessWitness witness(*descriptors); |
1144 map->set_instance_descriptors(*descriptors); | 1146 Map::SetDescriptors(map, descriptors); |
1145 | 1147 |
1146 { // length | 1148 { // length |
1147 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); | 1149 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); |
1148 map->AppendDescriptor(&d, witness); | 1150 map->AppendDescriptor(&d, witness); |
1149 } | 1151 } |
1150 { // callee | 1152 { // callee |
1151 CallbacksDescriptor d(*factory->callee_symbol(), | 1153 CallbacksDescriptor d(*factory->callee_symbol(), |
1152 *callee, | 1154 *callee, |
1153 attributes); | 1155 attributes); |
1154 map->AppendDescriptor(&d, witness); | 1156 map->AppendDescriptor(&d, witness); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 Handle<String> eval_from_script_position_symbol( | 1521 Handle<String> eval_from_script_position_symbol( |
1520 factory()->LookupAsciiSymbol("eval_from_script_position")); | 1522 factory()->LookupAsciiSymbol("eval_from_script_position")); |
1521 Handle<Foreign> script_eval_from_script_position( | 1523 Handle<Foreign> script_eval_from_script_position( |
1522 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); | 1524 factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); |
1523 Handle<String> eval_from_function_name_symbol( | 1525 Handle<String> eval_from_function_name_symbol( |
1524 factory()->LookupAsciiSymbol("eval_from_function_name")); | 1526 factory()->LookupAsciiSymbol("eval_from_function_name")); |
1525 Handle<Foreign> script_eval_from_function_name( | 1527 Handle<Foreign> script_eval_from_function_name( |
1526 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); | 1528 factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); |
1527 PropertyAttributes attribs = | 1529 PropertyAttributes attribs = |
1528 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1530 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
1529 script_map->set_instance_descriptors(*script_descriptors); | 1531 Map::SetDescriptors(script_map, script_descriptors); |
1530 | 1532 |
1531 { | 1533 { |
1532 CallbacksDescriptor d( | 1534 CallbacksDescriptor d( |
1533 *factory()->source_symbol(), *script_source, attribs); | 1535 *factory()->source_symbol(), *script_source, attribs); |
1534 script_map->AppendDescriptor(&d, witness); | 1536 script_map->AppendDescriptor(&d, witness); |
1535 } | 1537 } |
1536 | 1538 |
1537 { | 1539 { |
1538 CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs); | 1540 CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs); |
1539 script_map->AppendDescriptor(&d, witness); | 1541 script_map->AppendDescriptor(&d, witness); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1644 | 1646 |
1645 array_function->shared()->set_construct_stub( | 1647 array_function->shared()->set_construct_stub( |
1646 isolate()->builtins()->builtin(Builtins::kArrayConstructCode)); | 1648 isolate()->builtins()->builtin(Builtins::kArrayConstructCode)); |
1647 array_function->shared()->DontAdaptArguments(); | 1649 array_function->shared()->DontAdaptArguments(); |
1648 | 1650 |
1649 // InternalArrays should not use Smi-Only array optimizations. There are too | 1651 // InternalArrays should not use Smi-Only array optimizations. There are too |
1650 // many places in the C++ runtime code (e.g. RegEx) that assume that | 1652 // many places in the C++ runtime code (e.g. RegEx) that assume that |
1651 // elements in InternalArrays can be set to non-Smi values without going | 1653 // elements in InternalArrays can be set to non-Smi values without going |
1652 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT | 1654 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT |
1653 // transition easy to trap. Moreover, they rarely are smi-only. | 1655 // transition easy to trap. Moreover, they rarely are smi-only. |
1654 MaybeObject* maybe_map = | 1656 MaybeObject* maybe_map = array_function->initial_map()->Copy(); |
1655 array_function->initial_map()->Copy(DescriptorArray::MAY_BE_SHARED); | |
1656 Map* new_map; | 1657 Map* new_map; |
1657 if (!maybe_map->To(&new_map)) return false; | 1658 if (!maybe_map->To(&new_map)) return false; |
1658 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); | 1659 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); |
1659 array_function->set_initial_map(new_map); | 1660 array_function->set_initial_map(new_map); |
1660 | 1661 |
1661 // Make "length" magic on instances. | 1662 // Make "length" magic on instances. |
1663 Handle<Map> initial_map(array_function->initial_map()); | |
1662 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1)); | 1664 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1)); |
1663 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 1665 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
1664 | 1666 |
1665 Handle<Foreign> array_length(factory()->NewForeign( | 1667 Handle<Foreign> array_length(factory()->NewForeign( |
1666 &Accessors::ArrayLength)); | 1668 &Accessors::ArrayLength)); |
1667 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 1669 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
1668 DONT_ENUM | DONT_DELETE); | 1670 DONT_ENUM | DONT_DELETE); |
1669 array_function->initial_map()->set_instance_descriptors(*array_descriptors); | 1671 Map::SetDescriptors(initial_map, array_descriptors); |
1670 | 1672 |
1671 { // Add length. | 1673 { // Add length. |
1672 CallbacksDescriptor d( | 1674 CallbacksDescriptor d( |
1673 *factory()->length_symbol(), *array_length, attribs); | 1675 *factory()->length_symbol(), *array_length, attribs); |
1674 array_function->initial_map()->AppendDescriptor(&d, witness); | 1676 array_function->initial_map()->AppendDescriptor(&d, witness); |
1675 } | 1677 } |
1676 | 1678 |
1677 global_context()->set_internal_array_function(*array_function); | 1679 global_context()->set_internal_array_function(*array_function); |
1678 } | 1680 } |
1679 | 1681 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1754 initial_map->set_constructor(*array_constructor); | 1756 initial_map->set_constructor(*array_constructor); |
1755 | 1757 |
1756 // Set prototype on map. | 1758 // Set prototype on map. |
1757 initial_map->set_non_instance_prototype(false); | 1759 initial_map->set_non_instance_prototype(false); |
1758 initial_map->set_prototype(*array_prototype); | 1760 initial_map->set_prototype(*array_prototype); |
1759 | 1761 |
1760 // Update map with length accessor from Array and add "index" and "input". | 1762 // Update map with length accessor from Array and add "index" and "input". |
1761 Handle<DescriptorArray> reresult_descriptors = | 1763 Handle<DescriptorArray> reresult_descriptors = |
1762 factory()->NewDescriptorArray(3); | 1764 factory()->NewDescriptorArray(3); |
1763 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); | 1765 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); |
1764 initial_map->set_instance_descriptors(*reresult_descriptors); | 1766 Map::SetDescriptors(initial_map, reresult_descriptors); |
1765 | 1767 |
1766 { | 1768 { |
1767 JSFunction* array_function = global_context()->array_function(); | 1769 JSFunction* array_function = global_context()->array_function(); |
1768 Handle<DescriptorArray> array_descriptors( | 1770 Handle<DescriptorArray> array_descriptors( |
1769 array_function->initial_map()->instance_descriptors()); | 1771 array_function->initial_map()->instance_descriptors()); |
1770 String* length = heap()->length_symbol(); | 1772 String* length = heap()->length_symbol(); |
1771 int old = array_descriptors->SearchWithCache(length); | 1773 int old = array_descriptors->SearchWithCache(length); |
1772 ASSERT(old != DescriptorArray::kNotFound); | 1774 ASSERT(old != DescriptorArray::kNotFound); |
1773 CallbacksDescriptor desc(length, | 1775 CallbacksDescriptor desc(length, |
1774 array_descriptors->GetValue(old), | 1776 array_descriptors->GetValue(old), |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2386 return from + sizeof(NestingCounterType); | 2388 return from + sizeof(NestingCounterType); |
2387 } | 2389 } |
2388 | 2390 |
2389 | 2391 |
2390 // Called when the top-level V8 mutex is destroyed. | 2392 // Called when the top-level V8 mutex is destroyed. |
2391 void Bootstrapper::FreeThreadResources() { | 2393 void Bootstrapper::FreeThreadResources() { |
2392 ASSERT(!IsActive()); | 2394 ASSERT(!IsActive()); |
2393 } | 2395 } |
2394 | 2396 |
2395 } } // namespace v8::internal | 2397 } } // namespace v8::internal |
OLD | NEW |