| 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 "bootstrapper.h" | 5 #include "bootstrapper.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "natives.h" | 9 #include "natives.h" |
| 10 #include "snapshot.h" | 10 #include "snapshot.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 InstanceType type, | 351 InstanceType type, |
| 352 int instance_size, | 352 int instance_size, |
| 353 MaybeHandle<JSObject> maybe_prototype, | 353 MaybeHandle<JSObject> maybe_prototype, |
| 354 Builtins::Name call, | 354 Builtins::Name call, |
| 355 bool set_instance_class_name) { | 355 bool set_instance_class_name) { |
| 356 Isolate* isolate = target->GetIsolate(); | 356 Isolate* isolate = target->GetIsolate(); |
| 357 Factory* factory = isolate->factory(); | 357 Factory* factory = isolate->factory(); |
| 358 Handle<String> internalized_name = factory->InternalizeUtf8String(name); | 358 Handle<String> internalized_name = factory->InternalizeUtf8String(name); |
| 359 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); | 359 Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); |
| 360 Handle<JSFunction> function = factory->NewFunction( | 360 Handle<JSFunction> function = factory->NewFunction( |
| 361 maybe_prototype, internalized_name, type, instance_size, call_code, | 361 maybe_prototype, internalized_name, type, instance_size, call_code); |
| 362 !maybe_prototype.is_null()); | |
| 363 PropertyAttributes attributes; | 362 PropertyAttributes attributes; |
| 364 if (target->IsJSBuiltinsObject()) { | 363 if (target->IsJSBuiltinsObject()) { |
| 365 attributes = | 364 attributes = |
| 366 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 365 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 367 } else { | 366 } else { |
| 368 attributes = DONT_ENUM; | 367 attributes = DONT_ENUM; |
| 369 } | 368 } |
| 370 JSObject::SetLocalPropertyIgnoreAttributes( | 369 JSObject::SetLocalPropertyIgnoreAttributes( |
| 371 target, internalized_name, function, attributes).Check(); | 370 target, internalized_name, function, attributes).Check(); |
| 372 if (set_instance_class_name) { | 371 if (set_instance_class_name) { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 if (!proto_template->IsUndefined()) { | 700 if (!proto_template->IsUndefined()) { |
| 702 js_global_template = | 701 js_global_template = |
| 703 Handle<ObjectTemplateInfo>::cast(proto_template); | 702 Handle<ObjectTemplateInfo>::cast(proto_template); |
| 704 } | 703 } |
| 705 } | 704 } |
| 706 | 705 |
| 707 if (js_global_template.is_null()) { | 706 if (js_global_template.is_null()) { |
| 708 Handle<String> name = Handle<String>(heap()->empty_string()); | 707 Handle<String> name = Handle<String>(heap()->empty_string()); |
| 709 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 708 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( |
| 710 Builtins::kIllegal)); | 709 Builtins::kIllegal)); |
| 711 js_global_function = | 710 js_global_function = factory()->NewFunction( |
| 712 factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, | 711 name, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize, code); |
| 713 JSGlobalObject::kSize, code, true); | |
| 714 // Change the constructor property of the prototype of the | 712 // Change the constructor property of the prototype of the |
| 715 // hidden global function to refer to the Object function. | 713 // hidden global function to refer to the Object function. |
| 716 Handle<JSObject> prototype = | 714 Handle<JSObject> prototype = |
| 717 Handle<JSObject>( | 715 Handle<JSObject>( |
| 718 JSObject::cast(js_global_function->instance_prototype())); | 716 JSObject::cast(js_global_function->instance_prototype())); |
| 719 JSObject::SetLocalPropertyIgnoreAttributes( | 717 JSObject::SetLocalPropertyIgnoreAttributes( |
| 720 prototype, factory()->constructor_string(), | 718 prototype, factory()->constructor_string(), |
| 721 isolate()->object_function(), NONE).Check(); | 719 isolate()->object_function(), NONE).Check(); |
| 722 } else { | 720 } else { |
| 723 Handle<FunctionTemplateInfo> js_global_constructor( | 721 Handle<FunctionTemplateInfo> js_global_constructor( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 735 if (inner_global_out != NULL) { | 733 if (inner_global_out != NULL) { |
| 736 *inner_global_out = inner_global; | 734 *inner_global_out = inner_global; |
| 737 } | 735 } |
| 738 | 736 |
| 739 // Step 2: create or re-initialize the global proxy object. | 737 // Step 2: create or re-initialize the global proxy object. |
| 740 Handle<JSFunction> global_proxy_function; | 738 Handle<JSFunction> global_proxy_function; |
| 741 if (global_template.IsEmpty()) { | 739 if (global_template.IsEmpty()) { |
| 742 Handle<String> name = Handle<String>(heap()->empty_string()); | 740 Handle<String> name = Handle<String>(heap()->empty_string()); |
| 743 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 741 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( |
| 744 Builtins::kIllegal)); | 742 Builtins::kIllegal)); |
| 745 global_proxy_function = | 743 global_proxy_function = factory()->NewFunction( |
| 746 factory()->NewFunction(name, JS_GLOBAL_PROXY_TYPE, | 744 name, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize, code); |
| 747 JSGlobalProxy::kSize, code, true); | |
| 748 } else { | 745 } else { |
| 749 Handle<ObjectTemplateInfo> data = | 746 Handle<ObjectTemplateInfo> data = |
| 750 v8::Utils::OpenHandle(*global_template); | 747 v8::Utils::OpenHandle(*global_template); |
| 751 Handle<FunctionTemplateInfo> global_constructor( | 748 Handle<FunctionTemplateInfo> global_constructor( |
| 752 FunctionTemplateInfo::cast(data->constructor())); | 749 FunctionTemplateInfo::cast(data->constructor())); |
| 753 global_proxy_function = | 750 global_proxy_function = |
| 754 factory()->CreateApiFunction(global_constructor, | 751 factory()->CreateApiFunction(global_constructor, |
| 755 factory()->the_hole_value(), | 752 factory()->the_hole_value(), |
| 756 factory()->OuterGlobalObject); | 753 factory()->OuterGlobalObject); |
| 757 } | 754 } |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 { // --- arguments_boilerplate_ | 1072 { // --- arguments_boilerplate_ |
| 1076 // Make sure we can recognize argument objects at runtime. | 1073 // Make sure we can recognize argument objects at runtime. |
| 1077 // This is done by introducing an anonymous function with | 1074 // This is done by introducing an anonymous function with |
| 1078 // class_name equals 'Arguments'. | 1075 // class_name equals 'Arguments'. |
| 1079 Handle<String> arguments_string = factory->InternalizeOneByteString( | 1076 Handle<String> arguments_string = factory->InternalizeOneByteString( |
| 1080 STATIC_ASCII_VECTOR("Arguments")); | 1077 STATIC_ASCII_VECTOR("Arguments")); |
| 1081 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); | 1078 Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal)); |
| 1082 | 1079 |
| 1083 Handle<JSFunction> function = factory->NewFunction( | 1080 Handle<JSFunction> function = factory->NewFunction( |
| 1084 MaybeHandle<Object>(), arguments_string, JS_OBJECT_TYPE, | 1081 MaybeHandle<Object>(), arguments_string, JS_OBJECT_TYPE, |
| 1085 JSObject::kHeaderSize, code, false); | 1082 JSObject::kHeaderSize, code); |
| 1086 ASSERT(!function->has_initial_map()); | 1083 ASSERT(!function->has_initial_map()); |
| 1087 function->shared()->set_instance_class_name(*arguments_string); | 1084 function->shared()->set_instance_class_name(*arguments_string); |
| 1088 function->shared()->set_expected_nof_properties(2); | 1085 function->shared()->set_expected_nof_properties(2); |
| 1089 function->set_prototype_or_initial_map( | 1086 function->set_prototype_or_initial_map( |
| 1090 native_context()->object_function()->prototype()); | 1087 native_context()->object_function()->prototype()); |
| 1091 Handle<JSObject> result = factory->NewJSObject(function); | 1088 Handle<JSObject> result = factory->NewJSObject(function); |
| 1092 | 1089 |
| 1093 native_context()->set_sloppy_arguments_boilerplate(*result); | 1090 native_context()->set_sloppy_arguments_boilerplate(*result); |
| 1094 // Note: length must be added as the first property and | 1091 // Note: length must be added as the first property and |
| 1095 // callee must be added as the second property. | 1092 // callee must be added as the second property. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 // Check the state of the object. | 1211 // Check the state of the object. |
| 1215 ASSERT(result->HasFastProperties()); | 1212 ASSERT(result->HasFastProperties()); |
| 1216 ASSERT(result->HasFastObjectElements()); | 1213 ASSERT(result->HasFastObjectElements()); |
| 1217 #endif | 1214 #endif |
| 1218 } | 1215 } |
| 1219 | 1216 |
| 1220 { // --- context extension | 1217 { // --- context extension |
| 1221 // Create a function for the context extension objects. | 1218 // Create a function for the context extension objects. |
| 1222 Handle<Code> code = Handle<Code>( | 1219 Handle<Code> code = Handle<Code>( |
| 1223 isolate->builtins()->builtin(Builtins::kIllegal)); | 1220 isolate->builtins()->builtin(Builtins::kIllegal)); |
| 1224 Handle<JSFunction> context_extension_fun = | 1221 Handle<JSFunction> context_extension_fun = factory->NewFunction( |
| 1225 factory->NewFunction(factory->empty_string(), | 1222 factory->empty_string(), JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
| 1226 JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 1223 JSObject::kHeaderSize, code); |
| 1227 JSObject::kHeaderSize, | |
| 1228 code, | |
| 1229 true); | |
| 1230 | 1224 |
| 1231 Handle<String> name = factory->InternalizeOneByteString( | 1225 Handle<String> name = factory->InternalizeOneByteString( |
| 1232 STATIC_ASCII_VECTOR("context_extension")); | 1226 STATIC_ASCII_VECTOR("context_extension")); |
| 1233 context_extension_fun->shared()->set_instance_class_name(*name); | 1227 context_extension_fun->shared()->set_instance_class_name(*name); |
| 1234 native_context()->set_context_extension_function(*context_extension_fun); | 1228 native_context()->set_context_extension_function(*context_extension_fun); |
| 1235 } | 1229 } |
| 1236 | 1230 |
| 1237 | 1231 |
| 1238 { | 1232 { |
| 1239 // Set up the call-as-function delegate. | 1233 // Set up the call-as-function delegate. |
| 1240 Handle<Code> code = | 1234 Handle<Code> code = |
| 1241 Handle<Code>(isolate->builtins()->builtin( | 1235 Handle<Code>(isolate->builtins()->builtin( |
| 1242 Builtins::kHandleApiCallAsFunction)); | 1236 Builtins::kHandleApiCallAsFunction)); |
| 1243 Handle<JSFunction> delegate = | 1237 Handle<JSFunction> delegate = factory->NewFunction( |
| 1244 factory->NewFunction(factory->empty_string(), JS_OBJECT_TYPE, | 1238 factory->empty_string(), JS_OBJECT_TYPE, JSObject::kHeaderSize, code); |
| 1245 JSObject::kHeaderSize, code, true); | |
| 1246 native_context()->set_call_as_function_delegate(*delegate); | 1239 native_context()->set_call_as_function_delegate(*delegate); |
| 1247 delegate->shared()->DontAdaptArguments(); | 1240 delegate->shared()->DontAdaptArguments(); |
| 1248 } | 1241 } |
| 1249 | 1242 |
| 1250 { | 1243 { |
| 1251 // Set up the call-as-constructor delegate. | 1244 // Set up the call-as-constructor delegate. |
| 1252 Handle<Code> code = | 1245 Handle<Code> code = |
| 1253 Handle<Code>(isolate->builtins()->builtin( | 1246 Handle<Code>(isolate->builtins()->builtin( |
| 1254 Builtins::kHandleApiCallAsConstructor)); | 1247 Builtins::kHandleApiCallAsConstructor)); |
| 1255 Handle<JSFunction> delegate = | 1248 Handle<JSFunction> delegate = factory->NewFunction( |
| 1256 factory->NewFunction(factory->empty_string(), JS_OBJECT_TYPE, | 1249 factory->empty_string(), JS_OBJECT_TYPE, JSObject::kHeaderSize, code); |
| 1257 JSObject::kHeaderSize, code, true); | |
| 1258 native_context()->set_call_as_constructor_delegate(*delegate); | 1250 native_context()->set_call_as_constructor_delegate(*delegate); |
| 1259 delegate->shared()->DontAdaptArguments(); | 1251 delegate->shared()->DontAdaptArguments(); |
| 1260 } | 1252 } |
| 1261 | 1253 |
| 1262 // Initialize the embedder data slot. | 1254 // Initialize the embedder data slot. |
| 1263 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); | 1255 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); |
| 1264 native_context()->set_embedder_data(*embedder_data); | 1256 native_context()->set_embedder_data(*embedder_data); |
| 1265 } | 1257 } |
| 1266 | 1258 |
| 1267 | 1259 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 | 1613 |
| 1622 | 1614 |
| 1623 bool Genesis::InstallNatives() { | 1615 bool Genesis::InstallNatives() { |
| 1624 HandleScope scope(isolate()); | 1616 HandleScope scope(isolate()); |
| 1625 | 1617 |
| 1626 // Create a function for the builtins object. Allocate space for the | 1618 // Create a function for the builtins object. Allocate space for the |
| 1627 // JavaScript builtins, a reference to the builtins object | 1619 // JavaScript builtins, a reference to the builtins object |
| 1628 // (itself) and a reference to the native_context directly in the object. | 1620 // (itself) and a reference to the native_context directly in the object. |
| 1629 Handle<Code> code = Handle<Code>( | 1621 Handle<Code> code = Handle<Code>( |
| 1630 isolate()->builtins()->builtin(Builtins::kIllegal)); | 1622 isolate()->builtins()->builtin(Builtins::kIllegal)); |
| 1631 Handle<JSFunction> builtins_fun = | 1623 Handle<JSFunction> builtins_fun = factory()->NewFunction( |
| 1632 factory()->NewFunction(factory()->empty_string(), | 1624 factory()->empty_string(), JS_BUILTINS_OBJECT_TYPE, |
| 1633 JS_BUILTINS_OBJECT_TYPE, | 1625 JSBuiltinsObject::kSize, code); |
| 1634 JSBuiltinsObject::kSize, code, true); | |
| 1635 | 1626 |
| 1636 Handle<String> name = | 1627 Handle<String> name = |
| 1637 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); | 1628 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); |
| 1638 builtins_fun->shared()->set_instance_class_name(*name); | 1629 builtins_fun->shared()->set_instance_class_name(*name); |
| 1639 builtins_fun->initial_map()->set_dictionary_map(true); | 1630 builtins_fun->initial_map()->set_dictionary_map(true); |
| 1640 builtins_fun->initial_map()->set_prototype(heap()->null_value()); | 1631 builtins_fun->initial_map()->set_prototype(heap()->null_value()); |
| 1641 | 1632 |
| 1642 // Allocate the builtins object. | 1633 // Allocate the builtins object. |
| 1643 Handle<JSBuiltinsObject> builtins = | 1634 Handle<JSBuiltinsObject> builtins = |
| 1644 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); | 1635 Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun)); |
| (...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 return from + sizeof(NestingCounterType); | 2663 return from + sizeof(NestingCounterType); |
| 2673 } | 2664 } |
| 2674 | 2665 |
| 2675 | 2666 |
| 2676 // Called when the top-level V8 mutex is destroyed. | 2667 // Called when the top-level V8 mutex is destroyed. |
| 2677 void Bootstrapper::FreeThreadResources() { | 2668 void Bootstrapper::FreeThreadResources() { |
| 2678 ASSERT(!IsActive()); | 2669 ASSERT(!IsActive()); |
| 2679 } | 2670 } |
| 2680 | 2671 |
| 2681 } } // namespace v8::internal | 2672 } } // namespace v8::internal |
| OLD | NEW |