| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/extensions/externalize-string-extension.h" | 9 #include "src/extensions/externalize-string-extension.h" |
| 10 #include "src/extensions/free-buffer-extension.h" | 10 #include "src/extensions/free-buffer-extension.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 if (IsFunctionModeWithPrototype(function_mode)) { | 429 if (IsFunctionModeWithPrototype(function_mode)) { |
| 430 if (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE) { | 430 if (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE) { |
| 431 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); | 431 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); |
| 432 } | 432 } |
| 433 Handle<AccessorInfo> prototype = | 433 Handle<AccessorInfo> prototype = |
| 434 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 434 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
| 435 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 435 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
| 436 prototype, attribs); | 436 prototype, attribs); |
| 437 map->AppendDescriptor(&d); | 437 map->AppendDescriptor(&d); |
| 438 } | 438 } |
| 439 // Must be called after map layout parameters are fully initialized. |
| 440 Map::RebuildLayoutDescriptor(map); |
| 439 } | 441 } |
| 440 | 442 |
| 441 | 443 |
| 442 Handle<Map> Genesis::CreateFunctionMap(FunctionMode function_mode) { | 444 Handle<Map> Genesis::CreateFunctionMap(FunctionMode function_mode) { |
| 443 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 445 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
| 444 SetFunctionInstanceDescriptor(map, function_mode); | 446 SetFunctionInstanceDescriptor(map, function_mode); |
| 445 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); | 447 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); |
| 446 return map; | 448 return map; |
| 447 } | 449 } |
| 448 | 450 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // Add prototype. | 582 // Add prototype. |
| 581 PropertyAttributes attribs = | 583 PropertyAttributes attribs = |
| 582 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs | 584 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs |
| 583 : ro_attribs; | 585 : ro_attribs; |
| 584 Handle<AccessorInfo> prototype = | 586 Handle<AccessorInfo> prototype = |
| 585 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 587 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
| 586 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 588 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
| 587 prototype, attribs); | 589 prototype, attribs); |
| 588 map->AppendDescriptor(&d); | 590 map->AppendDescriptor(&d); |
| 589 } | 591 } |
| 592 // Must be called after map layout parameters are fully initialized. |
| 593 Map::RebuildLayoutDescriptor(map); |
| 590 } | 594 } |
| 591 | 595 |
| 592 | 596 |
| 593 // ECMAScript 5th Edition, 13.2.3 | 597 // ECMAScript 5th Edition, 13.2.3 |
| 594 Handle<JSFunction> Genesis::GetStrictPoisonFunction() { | 598 Handle<JSFunction> Genesis::GetStrictPoisonFunction() { |
| 595 if (strict_poison_function.is_null()) { | 599 if (strict_poison_function.is_null()) { |
| 596 Handle<String> name = factory()->InternalizeOneByteString( | 600 Handle<String> name = factory()->InternalizeOneByteString( |
| 597 STATIC_ASCII_VECTOR("ThrowTypeError")); | 601 STATIC_ASCII_VECTOR("ThrowTypeError")); |
| 598 Handle<Code> code(isolate()->builtins()->builtin( | 602 Handle<Code> code(isolate()->builtins()->builtin( |
| 599 Builtins::kStrictModePoisonPill)); | 603 Builtins::kStrictModePoisonPill)); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 | 923 |
| 920 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 924 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 921 DONT_ENUM | DONT_DELETE); | 925 DONT_ENUM | DONT_DELETE); |
| 922 | 926 |
| 923 Handle<AccessorInfo> array_length = | 927 Handle<AccessorInfo> array_length = |
| 924 Accessors::ArrayLengthInfo(isolate, attribs); | 928 Accessors::ArrayLengthInfo(isolate, attribs); |
| 925 { // Add length. | 929 { // Add length. |
| 926 CallbacksDescriptor d( | 930 CallbacksDescriptor d( |
| 927 Handle<Name>(Name::cast(array_length->name())), | 931 Handle<Name>(Name::cast(array_length->name())), |
| 928 array_length, attribs); | 932 array_length, attribs); |
| 929 array_function->initial_map()->AppendDescriptor(&d); | 933 initial_map->AppendDescriptor(&d); |
| 930 } | 934 } |
| 935 // Must be called after map layout parameters are fully initialized. |
| 936 Map::RebuildLayoutDescriptor(initial_map); |
| 931 | 937 |
| 932 // array_function is used internally. JS code creating array object should | 938 // array_function is used internally. JS code creating array object should |
| 933 // search for the 'Array' property on the global object and use that one | 939 // search for the 'Array' property on the global object and use that one |
| 934 // as the constructor. 'Array' property on a global object can be | 940 // as the constructor. 'Array' property on a global object can be |
| 935 // overwritten by JS code. | 941 // overwritten by JS code. |
| 936 native_context()->set_array_function(*array_function); | 942 native_context()->set_array_function(*array_function); |
| 937 | 943 |
| 938 // Cache the array maps, needed by ArrayConstructorStub | 944 // Cache the array maps, needed by ArrayConstructorStub |
| 939 CacheInitialJSArrayMaps(native_context(), initial_map); | 945 CacheInitialJSArrayMaps(native_context(), initial_map); |
| 940 ArrayConstructorStub array_constructor_stub(isolate); | 946 ArrayConstructorStub array_constructor_stub(isolate); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 | 979 |
| 974 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 980 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 975 DONT_ENUM | DONT_DELETE | READ_ONLY); | 981 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 976 Handle<AccessorInfo> string_length( | 982 Handle<AccessorInfo> string_length( |
| 977 Accessors::StringLengthInfo(isolate, attribs)); | 983 Accessors::StringLengthInfo(isolate, attribs)); |
| 978 | 984 |
| 979 { // Add length. | 985 { // Add length. |
| 980 CallbacksDescriptor d(factory->length_string(), string_length, attribs); | 986 CallbacksDescriptor d(factory->length_string(), string_length, attribs); |
| 981 string_map->AppendDescriptor(&d); | 987 string_map->AppendDescriptor(&d); |
| 982 } | 988 } |
| 989 // Must be called after map layout parameters are fully initialized. |
| 990 Map::RebuildLayoutDescriptor(string_map); |
| 983 } | 991 } |
| 984 | 992 |
| 985 { // --- D a t e --- | 993 { // --- D a t e --- |
| 986 // Builtin functions for Date.prototype. | 994 // Builtin functions for Date.prototype. |
| 987 Handle<JSFunction> date_fun = | 995 Handle<JSFunction> date_fun = |
| 988 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, | 996 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, |
| 989 isolate->initial_object_prototype(), | 997 isolate->initial_object_prototype(), |
| 990 Builtins::kIllegal); | 998 Builtins::kIllegal); |
| 991 | 999 |
| 992 native_context()->set_date_function(*date_fun); | 1000 native_context()->set_date_function(*date_fun); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 writable, | 1059 writable, |
| 1052 Representation::Tagged()); | 1060 Representation::Tagged()); |
| 1053 initial_map->AppendDescriptor(&field); | 1061 initial_map->AppendDescriptor(&field); |
| 1054 } | 1062 } |
| 1055 | 1063 |
| 1056 initial_map->set_inobject_properties(5); | 1064 initial_map->set_inobject_properties(5); |
| 1057 initial_map->set_pre_allocated_property_fields(5); | 1065 initial_map->set_pre_allocated_property_fields(5); |
| 1058 initial_map->set_unused_property_fields(0); | 1066 initial_map->set_unused_property_fields(0); |
| 1059 initial_map->set_instance_size( | 1067 initial_map->set_instance_size( |
| 1060 initial_map->instance_size() + 5 * kPointerSize); | 1068 initial_map->instance_size() + 5 * kPointerSize); |
| 1061 initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map)); | 1069 // Must be called after map layout parameters are fully initialized. |
| 1070 Map::RebuildLayoutDescriptor(initial_map); |
| 1062 | 1071 |
| 1063 // RegExp prototype object is itself a RegExp. | 1072 // RegExp prototype object is itself a RegExp. |
| 1064 Handle<Map> proto_map = Map::Copy(initial_map); | 1073 Handle<Map> proto_map = Map::Copy(initial_map); |
| 1065 proto_map->set_prototype(native_context()->initial_object_prototype()); | 1074 proto_map->set_prototype(native_context()->initial_object_prototype()); |
| 1066 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); | 1075 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); |
| 1067 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, | 1076 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, |
| 1068 heap->query_colon_string()); | 1077 heap->query_colon_string()); |
| 1069 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, | 1078 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, |
| 1070 heap->false_value()); | 1079 heap->false_value()); |
| 1071 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, | 1080 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 } | 1226 } |
| 1218 { // caller | 1227 { // caller |
| 1219 CallbacksDescriptor d(factory->caller_string(), caller, attributes); | 1228 CallbacksDescriptor d(factory->caller_string(), caller, attributes); |
| 1220 map->AppendDescriptor(&d); | 1229 map->AppendDescriptor(&d); |
| 1221 } | 1230 } |
| 1222 | 1231 |
| 1223 map->set_function_with_prototype(true); | 1232 map->set_function_with_prototype(true); |
| 1224 map->set_prototype(native_context()->object_function()->prototype()); | 1233 map->set_prototype(native_context()->object_function()->prototype()); |
| 1225 map->set_pre_allocated_property_fields(1); | 1234 map->set_pre_allocated_property_fields(1); |
| 1226 map->set_inobject_properties(1); | 1235 map->set_inobject_properties(1); |
| 1236 // Must be called after map layout parameters are fully initialized. |
| 1237 Map::RebuildLayoutDescriptor(map); |
| 1227 | 1238 |
| 1228 // Copy constructor from the sloppy arguments boilerplate. | 1239 // Copy constructor from the sloppy arguments boilerplate. |
| 1229 map->set_constructor( | 1240 map->set_constructor( |
| 1230 native_context()->sloppy_arguments_map()->constructor()); | 1241 native_context()->sloppy_arguments_map()->constructor()); |
| 1231 | 1242 |
| 1232 native_context()->set_strict_arguments_map(*map); | 1243 native_context()->set_strict_arguments_map(*map); |
| 1233 | 1244 |
| 1234 ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex); | 1245 ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex); |
| 1235 ASSERT(!map->is_dictionary_map()); | 1246 ASSERT(!map->is_dictionary_map()); |
| 1236 ASSERT(IsFastObjectElementsKind(map->elements_kind())); | 1247 ASSERT(IsFastObjectElementsKind(map->elements_kind())); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 Map::EnsureDescriptorSlack(initial_map, 1); | 1650 Map::EnsureDescriptorSlack(initial_map, 1); |
| 1640 | 1651 |
| 1641 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 1652 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
| 1642 DONT_ENUM | DONT_DELETE); | 1653 DONT_ENUM | DONT_DELETE); |
| 1643 | 1654 |
| 1644 Handle<AccessorInfo> array_length = | 1655 Handle<AccessorInfo> array_length = |
| 1645 Accessors::ArrayLengthInfo(isolate(), attribs); | 1656 Accessors::ArrayLengthInfo(isolate(), attribs); |
| 1646 { // Add length. | 1657 { // Add length. |
| 1647 CallbacksDescriptor d( | 1658 CallbacksDescriptor d( |
| 1648 Handle<Name>(Name::cast(array_length->name())), array_length, attribs); | 1659 Handle<Name>(Name::cast(array_length->name())), array_length, attribs); |
| 1649 array_function->initial_map()->AppendDescriptor(&d); | 1660 initial_map->AppendDescriptor(&d); |
| 1650 } | 1661 } |
| 1662 // Must be called after map layout parameters are fully initialized. |
| 1663 Map::RebuildLayoutDescriptor(initial_map); |
| 1651 | 1664 |
| 1652 return array_function; | 1665 return array_function; |
| 1653 } | 1666 } |
| 1654 | 1667 |
| 1655 | 1668 |
| 1656 bool Genesis::InstallNatives() { | 1669 bool Genesis::InstallNatives() { |
| 1657 HandleScope scope(isolate()); | 1670 HandleScope scope(isolate()); |
| 1658 | 1671 |
| 1659 // Create a function for the builtins object. Allocate space for the | 1672 // Create a function for the builtins object. Allocate space for the |
| 1660 // JavaScript builtins, a reference to the builtins object | 1673 // JavaScript builtins, a reference to the builtins object |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 } | 1849 } |
| 1837 | 1850 |
| 1838 Handle<AccessorInfo> script_source_mapping_url = | 1851 Handle<AccessorInfo> script_source_mapping_url = |
| 1839 Accessors::ScriptSourceMappingUrlInfo(isolate(), attribs); | 1852 Accessors::ScriptSourceMappingUrlInfo(isolate(), attribs); |
| 1840 { | 1853 { |
| 1841 CallbacksDescriptor d( | 1854 CallbacksDescriptor d( |
| 1842 Handle<Name>(Name::cast(script_source_mapping_url->name())), | 1855 Handle<Name>(Name::cast(script_source_mapping_url->name())), |
| 1843 script_source_mapping_url, attribs); | 1856 script_source_mapping_url, attribs); |
| 1844 script_map->AppendDescriptor(&d); | 1857 script_map->AppendDescriptor(&d); |
| 1845 } | 1858 } |
| 1859 // Must be called after map layout parameters are fully initialized. |
| 1860 Map::RebuildLayoutDescriptor(script_map); |
| 1846 | 1861 |
| 1847 // Allocate the empty script. | 1862 // Allocate the empty script. |
| 1848 Handle<Script> script = factory()->NewScript(factory()->empty_string()); | 1863 Handle<Script> script = factory()->NewScript(factory()->empty_string()); |
| 1849 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 1864 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 1850 heap()->public_set_empty_script(*script); | 1865 heap()->public_set_empty_script(*script); |
| 1851 } | 1866 } |
| 1852 { | 1867 { |
| 1853 // Builtin function for OpaqueReference -- a JSValue-based object, | 1868 // Builtin function for OpaqueReference -- a JSValue-based object, |
| 1854 // that keeps its field isolated from JavaScript code. It may store | 1869 // that keeps its field isolated from JavaScript code. It may store |
| 1855 // objects, that JavaScript code may not access. | 1870 // objects, that JavaScript code may not access. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 FieldDescriptor input_field(factory()->input_string(), | 1998 FieldDescriptor input_field(factory()->input_string(), |
| 1984 JSRegExpResult::kInputIndex, | 1999 JSRegExpResult::kInputIndex, |
| 1985 NONE, | 2000 NONE, |
| 1986 Representation::Tagged()); | 2001 Representation::Tagged()); |
| 1987 initial_map->AppendDescriptor(&input_field); | 2002 initial_map->AppendDescriptor(&input_field); |
| 1988 } | 2003 } |
| 1989 | 2004 |
| 1990 initial_map->set_inobject_properties(2); | 2005 initial_map->set_inobject_properties(2); |
| 1991 initial_map->set_pre_allocated_property_fields(2); | 2006 initial_map->set_pre_allocated_property_fields(2); |
| 1992 initial_map->set_unused_property_fields(0); | 2007 initial_map->set_unused_property_fields(0); |
| 2008 // Must be called after map layout parameters are fully initialized. |
| 2009 Map::RebuildLayoutDescriptor(initial_map); |
| 1993 | 2010 |
| 1994 native_context()->set_regexp_result_map(*initial_map); | 2011 native_context()->set_regexp_result_map(*initial_map); |
| 1995 } | 2012 } |
| 1996 | 2013 |
| 1997 #ifdef VERIFY_HEAP | 2014 #ifdef VERIFY_HEAP |
| 1998 builtins->ObjectVerify(); | 2015 builtins->ObjectVerify(); |
| 1999 #endif | 2016 #endif |
| 2000 | 2017 |
| 2001 return true; | 2018 return true; |
| 2002 } | 2019 } |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2705 return from + sizeof(NestingCounterType); | 2722 return from + sizeof(NestingCounterType); |
| 2706 } | 2723 } |
| 2707 | 2724 |
| 2708 | 2725 |
| 2709 // Called when the top-level V8 mutex is destroyed. | 2726 // Called when the top-level V8 mutex is destroyed. |
| 2710 void Bootstrapper::FreeThreadResources() { | 2727 void Bootstrapper::FreeThreadResources() { |
| 2711 ASSERT(!IsActive()); | 2728 ASSERT(!IsActive()); |
| 2712 } | 2729 } |
| 2713 | 2730 |
| 2714 } } // namespace v8::internal | 2731 } } // namespace v8::internal |
| OLD | NEW |