| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 function->shared()->set_instance_class_name(*symbol); | 377 function->shared()->set_instance_class_name(*symbol); |
| 378 } | 378 } |
| 379 function->shared()->set_native(true); | 379 function->shared()->set_native(true); |
| 380 return function; | 380 return function; |
| 381 } | 381 } |
| 382 | 382 |
| 383 | 383 |
| 384 void Genesis::SetFunctionInstanceDescriptor( | 384 void Genesis::SetFunctionInstanceDescriptor( |
| 385 Handle<Map> map, PrototypePropertyMode prototypeMode) { | 385 Handle<Map> map, PrototypePropertyMode prototypeMode) { |
| 386 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; | 386 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; |
| 387 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); | 387 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size)); |
| 388 DescriptorArray::WhitenessWitness witness(*descriptors); | 388 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 389 | 389 |
| 390 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); | 390 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); |
| 391 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); | 391 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); |
| 392 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); | 392 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); |
| 393 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); | 393 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); |
| 394 Handle<Foreign> prototype; | 394 Handle<Foreign> prototype; |
| 395 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 395 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
| 396 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); | 396 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); |
| 397 } | 397 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 empty_function_map->set_prototype( | 518 empty_function_map->set_prototype( |
| 519 native_context()->object_function()->prototype()); | 519 native_context()->object_function()->prototype()); |
| 520 empty_function->set_map(*empty_function_map); | 520 empty_function->set_map(*empty_function_map); |
| 521 return empty_function; | 521 return empty_function; |
| 522 } | 522 } |
| 523 | 523 |
| 524 | 524 |
| 525 void Genesis::SetStrictFunctionInstanceDescriptor( | 525 void Genesis::SetStrictFunctionInstanceDescriptor( |
| 526 Handle<Map> map, PrototypePropertyMode prototypeMode) { | 526 Handle<Map> map, PrototypePropertyMode prototypeMode) { |
| 527 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; | 527 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; |
| 528 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(size)); | 528 Handle<DescriptorArray> descriptors(factory()->NewDescriptorArray(0, size)); |
| 529 DescriptorArray::WhitenessWitness witness(*descriptors); | 529 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 530 | 530 |
| 531 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); | 531 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); |
| 532 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); | 532 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); |
| 533 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); | 533 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); |
| 534 Handle<AccessorPair> caller(factory()->NewAccessorPair()); | 534 Handle<AccessorPair> caller(factory()->NewAccessorPair()); |
| 535 Handle<Foreign> prototype; | 535 Handle<Foreign> prototype; |
| 536 if (prototypeMode != DONT_ADD_PROTOTYPE) { | 536 if (prototypeMode != DONT_ADD_PROTOTYPE) { |
| 537 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); | 537 prototype = factory()->NewForeign(&Accessors::FunctionPrototype); |
| 538 } | 538 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 Builtins::kArrayCode, true); | 861 Builtins::kArrayCode, true); |
| 862 array_function->shared()->set_construct_stub( | 862 array_function->shared()->set_construct_stub( |
| 863 isolate->builtins()->builtin(Builtins::kArrayConstructCode)); | 863 isolate->builtins()->builtin(Builtins::kArrayConstructCode)); |
| 864 array_function->shared()->DontAdaptArguments(); | 864 array_function->shared()->DontAdaptArguments(); |
| 865 | 865 |
| 866 // This seems a bit hackish, but we need to make sure Array.length | 866 // This seems a bit hackish, but we need to make sure Array.length |
| 867 // is 1. | 867 // is 1. |
| 868 array_function->shared()->set_length(1); | 868 array_function->shared()->set_length(1); |
| 869 | 869 |
| 870 Handle<Map> initial_map(array_function->initial_map()); | 870 Handle<Map> initial_map(array_function->initial_map()); |
| 871 Handle<DescriptorArray> array_descriptors(factory->NewDescriptorArray(1)); | 871 Handle<DescriptorArray> array_descriptors( |
| 872 factory->NewDescriptorArray(0, 1)); |
| 872 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 873 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
| 873 | 874 |
| 874 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); | 875 Handle<Foreign> array_length(factory->NewForeign(&Accessors::ArrayLength)); |
| 875 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 876 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 876 DONT_ENUM | DONT_DELETE); | 877 DONT_ENUM | DONT_DELETE); |
| 877 Map::SetDescriptors(initial_map, array_descriptors); | 878 Map::SetDescriptors(initial_map, array_descriptors); |
| 878 | 879 |
| 879 { // Add length. | 880 { // Add length. |
| 880 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); | 881 CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); |
| 881 array_function->initial_map()->AppendDescriptor(&d, witness); | 882 array_function->initial_map()->AppendDescriptor(&d, witness); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 908 Handle<JSFunction> string_fun = | 909 Handle<JSFunction> string_fun = |
| 909 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, | 910 InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, |
| 910 isolate->initial_object_prototype(), | 911 isolate->initial_object_prototype(), |
| 911 Builtins::kIllegal, true); | 912 Builtins::kIllegal, true); |
| 912 string_fun->shared()->set_construct_stub( | 913 string_fun->shared()->set_construct_stub( |
| 913 isolate->builtins()->builtin(Builtins::kStringConstructCode)); | 914 isolate->builtins()->builtin(Builtins::kStringConstructCode)); |
| 914 native_context()->set_string_function(*string_fun); | 915 native_context()->set_string_function(*string_fun); |
| 915 | 916 |
| 916 Handle<Map> string_map = | 917 Handle<Map> string_map = |
| 917 Handle<Map>(native_context()->string_function()->initial_map()); | 918 Handle<Map>(native_context()->string_function()->initial_map()); |
| 918 Handle<DescriptorArray> string_descriptors(factory->NewDescriptorArray(1)); | 919 Handle<DescriptorArray> string_descriptors( |
| 920 factory->NewDescriptorArray(0, 1)); |
| 919 DescriptorArray::WhitenessWitness witness(*string_descriptors); | 921 DescriptorArray::WhitenessWitness witness(*string_descriptors); |
| 920 | 922 |
| 921 Handle<Foreign> string_length( | 923 Handle<Foreign> string_length( |
| 922 factory->NewForeign(&Accessors::StringLength)); | 924 factory->NewForeign(&Accessors::StringLength)); |
| 923 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 925 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 924 DONT_ENUM | DONT_DELETE | READ_ONLY); | 926 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 925 Map::SetDescriptors(string_map, string_descriptors); | 927 Map::SetDescriptors(string_map, string_descriptors); |
| 926 | 928 |
| 927 { // Add length. | 929 { // Add length. |
| 928 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); | 930 CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 949 Builtins::kIllegal, true); | 951 Builtins::kIllegal, true); |
| 950 native_context()->set_regexp_function(*regexp_fun); | 952 native_context()->set_regexp_function(*regexp_fun); |
| 951 | 953 |
| 952 ASSERT(regexp_fun->has_initial_map()); | 954 ASSERT(regexp_fun->has_initial_map()); |
| 953 Handle<Map> initial_map(regexp_fun->initial_map()); | 955 Handle<Map> initial_map(regexp_fun->initial_map()); |
| 954 | 956 |
| 955 ASSERT_EQ(0, initial_map->inobject_properties()); | 957 ASSERT_EQ(0, initial_map->inobject_properties()); |
| 956 | 958 |
| 957 PropertyAttributes final = | 959 PropertyAttributes final = |
| 958 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 960 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 959 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5); | 961 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 5); |
| 960 DescriptorArray::WhitenessWitness witness(*descriptors); | 962 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 961 Map::SetDescriptors(initial_map, descriptors); | 963 Map::SetDescriptors(initial_map, descriptors); |
| 962 | 964 |
| 963 { | 965 { |
| 964 // ECMA-262, section 15.10.7.1. | 966 // ECMA-262, section 15.10.7.1. |
| 965 FieldDescriptor field(heap->source_symbol(), | 967 FieldDescriptor field(heap->source_symbol(), |
| 966 JSRegExp::kSourceFieldIndex, | 968 JSRegExp::kSourceFieldIndex, |
| 967 final); | 969 final); |
| 968 initial_map->AppendDescriptor(&field, witness); | 970 initial_map->AppendDescriptor(&field, witness); |
| 969 } | 971 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 // Install the ThrowTypeError functions. | 1135 // Install the ThrowTypeError functions. |
| 1134 callee->set_getter(*throw_function); | 1136 callee->set_getter(*throw_function); |
| 1135 callee->set_setter(*throw_function); | 1137 callee->set_setter(*throw_function); |
| 1136 caller->set_getter(*throw_function); | 1138 caller->set_getter(*throw_function); |
| 1137 caller->set_setter(*throw_function); | 1139 caller->set_setter(*throw_function); |
| 1138 | 1140 |
| 1139 // Create the map. Allocate one in-object field for length. | 1141 // Create the map. Allocate one in-object field for length. |
| 1140 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, | 1142 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, |
| 1141 Heap::kArgumentsObjectSizeStrict); | 1143 Heap::kArgumentsObjectSizeStrict); |
| 1142 // Create the descriptor array for the arguments object. | 1144 // Create the descriptor array for the arguments object. |
| 1143 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3); | 1145 Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(0, 3); |
| 1144 DescriptorArray::WhitenessWitness witness(*descriptors); | 1146 DescriptorArray::WhitenessWitness witness(*descriptors); |
| 1145 Map::SetDescriptors(map, descriptors); | 1147 Map::SetDescriptors(map, descriptors); |
| 1146 | 1148 |
| 1147 { // length | 1149 { // length |
| 1148 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); | 1150 FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM); |
| 1149 map->AppendDescriptor(&d, witness); | 1151 map->AppendDescriptor(&d, witness); |
| 1150 } | 1152 } |
| 1151 { // callee | 1153 { // callee |
| 1152 CallbacksDescriptor d(*factory->callee_symbol(), | 1154 CallbacksDescriptor d(*factory->callee_symbol(), |
| 1153 *callee, | 1155 *callee, |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 isolate()->initial_object_prototype(), | 1482 isolate()->initial_object_prototype(), |
| 1481 Builtins::kIllegal, false); | 1483 Builtins::kIllegal, false); |
| 1482 Handle<JSObject> prototype = | 1484 Handle<JSObject> prototype = |
| 1483 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1485 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1484 SetPrototype(script_fun, prototype); | 1486 SetPrototype(script_fun, prototype); |
| 1485 native_context()->set_script_function(*script_fun); | 1487 native_context()->set_script_function(*script_fun); |
| 1486 | 1488 |
| 1487 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); | 1489 Handle<Map> script_map = Handle<Map>(script_fun->initial_map()); |
| 1488 | 1490 |
| 1489 Handle<DescriptorArray> script_descriptors( | 1491 Handle<DescriptorArray> script_descriptors( |
| 1490 factory()->NewDescriptorArray(13)); | 1492 factory()->NewDescriptorArray(0, 13)); |
| 1491 DescriptorArray::WhitenessWitness witness(*script_descriptors); | 1493 DescriptorArray::WhitenessWitness witness(*script_descriptors); |
| 1492 | 1494 |
| 1493 Handle<Foreign> script_source( | 1495 Handle<Foreign> script_source( |
| 1494 factory()->NewForeign(&Accessors::ScriptSource)); | 1496 factory()->NewForeign(&Accessors::ScriptSource)); |
| 1495 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName)); | 1497 Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName)); |
| 1496 Handle<String> id_symbol(factory()->LookupAsciiSymbol("id")); | 1498 Handle<String> id_symbol(factory()->LookupAsciiSymbol("id")); |
| 1497 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId)); | 1499 Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId)); |
| 1498 Handle<String> line_offset_symbol( | 1500 Handle<String> line_offset_symbol( |
| 1499 factory()->LookupAsciiSymbol("line_offset")); | 1501 factory()->LookupAsciiSymbol("line_offset")); |
| 1500 Handle<Foreign> script_line_offset( | 1502 Handle<Foreign> script_line_offset( |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT | 1660 // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT |
| 1659 // transition easy to trap. Moreover, they rarely are smi-only. | 1661 // transition easy to trap. Moreover, they rarely are smi-only. |
| 1660 MaybeObject* maybe_map = array_function->initial_map()->Copy(); | 1662 MaybeObject* maybe_map = array_function->initial_map()->Copy(); |
| 1661 Map* new_map; | 1663 Map* new_map; |
| 1662 if (!maybe_map->To(&new_map)) return false; | 1664 if (!maybe_map->To(&new_map)) return false; |
| 1663 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); | 1665 new_map->set_elements_kind(FAST_HOLEY_ELEMENTS); |
| 1664 array_function->set_initial_map(new_map); | 1666 array_function->set_initial_map(new_map); |
| 1665 | 1667 |
| 1666 // Make "length" magic on instances. | 1668 // Make "length" magic on instances. |
| 1667 Handle<Map> initial_map(array_function->initial_map()); | 1669 Handle<Map> initial_map(array_function->initial_map()); |
| 1668 Handle<DescriptorArray> array_descriptors(factory()->NewDescriptorArray(1)); | 1670 Handle<DescriptorArray> array_descriptors( |
| 1671 factory()->NewDescriptorArray(0, 1)); |
| 1669 DescriptorArray::WhitenessWitness witness(*array_descriptors); | 1672 DescriptorArray::WhitenessWitness witness(*array_descriptors); |
| 1670 | 1673 |
| 1671 Handle<Foreign> array_length(factory()->NewForeign( | 1674 Handle<Foreign> array_length(factory()->NewForeign( |
| 1672 &Accessors::ArrayLength)); | 1675 &Accessors::ArrayLength)); |
| 1673 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 1676 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 1674 DONT_ENUM | DONT_DELETE); | 1677 DONT_ENUM | DONT_DELETE); |
| 1675 Map::SetDescriptors(initial_map, array_descriptors); | 1678 Map::SetDescriptors(initial_map, array_descriptors); |
| 1676 | 1679 |
| 1677 { // Add length. | 1680 { // Add length. |
| 1678 CallbacksDescriptor d( | 1681 CallbacksDescriptor d( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 Handle<Map> initial_map = | 1761 Handle<Map> initial_map = |
| 1759 factory()->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize); | 1762 factory()->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize); |
| 1760 initial_map->set_constructor(*array_constructor); | 1763 initial_map->set_constructor(*array_constructor); |
| 1761 | 1764 |
| 1762 // Set prototype on map. | 1765 // Set prototype on map. |
| 1763 initial_map->set_non_instance_prototype(false); | 1766 initial_map->set_non_instance_prototype(false); |
| 1764 initial_map->set_prototype(*array_prototype); | 1767 initial_map->set_prototype(*array_prototype); |
| 1765 | 1768 |
| 1766 // Update map with length accessor from Array and add "index" and "input". | 1769 // Update map with length accessor from Array and add "index" and "input". |
| 1767 Handle<DescriptorArray> reresult_descriptors = | 1770 Handle<DescriptorArray> reresult_descriptors = |
| 1768 factory()->NewDescriptorArray(3); | 1771 factory()->NewDescriptorArray(0, 3); |
| 1769 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); | 1772 DescriptorArray::WhitenessWitness witness(*reresult_descriptors); |
| 1770 Map::SetDescriptors(initial_map, reresult_descriptors); | 1773 Map::SetDescriptors(initial_map, reresult_descriptors); |
| 1771 | 1774 |
| 1772 { | 1775 { |
| 1773 JSFunction* array_function = native_context()->array_function(); | 1776 JSFunction* array_function = native_context()->array_function(); |
| 1774 Handle<DescriptorArray> array_descriptors( | 1777 Handle<DescriptorArray> array_descriptors( |
| 1775 array_function->initial_map()->instance_descriptors()); | 1778 array_function->initial_map()->instance_descriptors()); |
| 1776 String* length = heap()->length_symbol(); | 1779 String* length = heap()->length_symbol(); |
| 1777 int old = array_descriptors->SearchWithCache( | 1780 int old = array_descriptors->SearchWithCache( |
| 1778 length, array_function->initial_map()); | 1781 length, array_function->initial_map()); |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 return from + sizeof(NestingCounterType); | 2399 return from + sizeof(NestingCounterType); |
| 2397 } | 2400 } |
| 2398 | 2401 |
| 2399 | 2402 |
| 2400 // Called when the top-level V8 mutex is destroyed. | 2403 // Called when the top-level V8 mutex is destroyed. |
| 2401 void Bootstrapper::FreeThreadResources() { | 2404 void Bootstrapper::FreeThreadResources() { |
| 2402 ASSERT(!IsActive()); | 2405 ASSERT(!IsActive()); |
| 2403 } | 2406 } |
| 2404 | 2407 |
| 2405 } } // namespace v8::internal | 2408 } } // namespace v8::internal |
| OLD | NEW |