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/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/base/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 #undef DECLARE_FEATURE_INITIALIZATION | 231 #undef DECLARE_FEATURE_INITIALIZATION |
232 | 232 |
233 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 233 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
234 const char* name, | 234 const char* name, |
235 ElementsKind elements_kind); | 235 ElementsKind elements_kind); |
236 bool InstallNatives(ContextType context_type); | 236 bool InstallNatives(ContextType context_type); |
237 | 237 |
238 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 238 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
239 Handle<JSFunction>* fun); | 239 Handle<JSFunction>* fun); |
240 bool InstallExperimentalNatives(); | 240 bool InstallExperimentalNatives(); |
241 bool InstallExtraNatives(); | 241 bool InstallExtraNatives(ContextType context_type); |
242 bool InstallDebuggerNatives(); | 242 bool InstallDebuggerNatives(); |
243 void InstallBuiltinFunctionIds(); | 243 void InstallBuiltinFunctionIds(); |
244 void InstallExperimentalBuiltinFunctionIds(); | 244 void InstallExperimentalBuiltinFunctionIds(); |
245 void InitializeNormalizedMapCaches(); | 245 void InitializeNormalizedMapCaches(); |
246 | 246 |
247 enum ExtensionTraversalState { | 247 enum ExtensionTraversalState { |
248 UNVISITED, VISITED, INSTALLED | 248 UNVISITED, VISITED, INSTALLED |
249 }; | 249 }; |
250 | 250 |
251 class ExtensionStates { | 251 class ExtensionStates { |
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2093 if (!InstallJSBuiltins(builtins)) return false; | 2093 if (!InstallJSBuiltins(builtins)) return false; |
2094 return true; | 2094 return true; |
2095 } | 2095 } |
2096 | 2096 |
2097 // Set up the utils object as shared container between native scripts. | 2097 // Set up the utils object as shared container between native scripts. |
2098 Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function()); | 2098 Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function()); |
2099 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, | 2099 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, |
2100 "utils container for native scripts"); | 2100 "utils container for native scripts"); |
2101 native_context()->set_natives_utils_object(*utils); | 2101 native_context()->set_natives_utils_object(*utils); |
2102 | 2102 |
2103 Handle<JSObject> extras_binding = | |
2104 factory()->NewJSObject(isolate()->object_function()); | |
2105 JSObject::NormalizeProperties(extras_binding, CLEAR_INOBJECT_PROPERTIES, 2, | |
2106 "container for binding to/from extra natives"); | |
2107 native_context()->set_extras_binding_object(*extras_binding); | |
2108 | |
2109 if (FLAG_expose_natives_as != NULL) { | 2103 if (FLAG_expose_natives_as != NULL) { |
2110 Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils"); | 2104 Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils"); |
2111 JSObject::AddProperty(builtins, utils_key, utils, NONE); | 2105 JSObject::AddProperty(builtins, utils_key, utils, NONE); |
2112 } | 2106 } |
2113 | 2107 |
2114 { // -- S c r i p t | 2108 { // -- S c r i p t |
2115 // Builtin functions for Script. | 2109 // Builtin functions for Script. |
2116 Handle<JSFunction> script_fun = InstallFunction( | 2110 Handle<JSFunction> script_fun = InstallFunction( |
2117 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, | 2111 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, |
2118 isolate()->initial_object_prototype(), Builtins::kIllegal); | 2112 isolate()->initial_object_prototype(), Builtins::kIllegal); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2606 } | 2600 } |
2607 | 2601 |
2608 if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false; | 2602 if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false; |
2609 | 2603 |
2610 InstallExperimentalNativeFunctions(); | 2604 InstallExperimentalNativeFunctions(); |
2611 InstallExperimentalBuiltinFunctionIds(); | 2605 InstallExperimentalBuiltinFunctionIds(); |
2612 return true; | 2606 return true; |
2613 } | 2607 } |
2614 | 2608 |
2615 | 2609 |
2616 bool Genesis::InstallExtraNatives() { | 2610 bool Genesis::InstallExtraNatives(ContextType context_type) { |
2611 if (context_type == THIN_CONTEXT) { | |
2612 return true; | |
2613 } | |
2614 | |
2615 HandleScope scope(isolate()); | |
2616 | |
2617 Handle<JSObject> extras_binding = | |
2618 factory()->NewJSObject(isolate()->object_function()); | |
2619 JSObject::NormalizeProperties(extras_binding, CLEAR_INOBJECT_PROPERTIES, 2, | |
2620 "container for binding to/from extra natives"); | |
2621 native_context()->set_extras_binding_object(*extras_binding); | |
2622 | |
2617 for (int i = ExtraNatives::GetDebuggerCount(); | 2623 for (int i = ExtraNatives::GetDebuggerCount(); |
2618 i < ExtraNatives::GetBuiltinsCount(); i++) { | 2624 i < ExtraNatives::GetBuiltinsCount(); i++) { |
2619 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false; | 2625 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false; |
2620 } | 2626 } |
2621 | 2627 |
2622 return true; | 2628 return true; |
2623 } | 2629 } |
2624 | 2630 |
2625 | 2631 |
2626 bool Genesis::InstallDebuggerNatives() { | 2632 bool Genesis::InstallDebuggerNatives() { |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3211 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); | 3217 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); |
3212 CreateStrictModeFunctionMaps(empty_function); | 3218 CreateStrictModeFunctionMaps(empty_function); |
3213 CreateStrongModeFunctionMaps(empty_function); | 3219 CreateStrongModeFunctionMaps(empty_function); |
3214 Handle<GlobalObject> global_object = | 3220 Handle<GlobalObject> global_object = |
3215 CreateNewGlobals(global_proxy_template, global_proxy); | 3221 CreateNewGlobals(global_proxy_template, global_proxy); |
3216 HookUpGlobalProxy(global_object, global_proxy); | 3222 HookUpGlobalProxy(global_object, global_proxy); |
3217 InitializeGlobal(global_object, empty_function, context_type); | 3223 InitializeGlobal(global_object, empty_function, context_type); |
3218 InitializeNormalizedMapCaches(); | 3224 InitializeNormalizedMapCaches(); |
3219 | 3225 |
3220 if (!InstallNatives(context_type)) return; | 3226 if (!InstallNatives(context_type)) return; |
3227 if (!InstallExtraNatives(context_type)) return; | |
3221 | 3228 |
3222 MakeFunctionInstancePrototypeWritable(); | 3229 MakeFunctionInstancePrototypeWritable(); |
3223 | 3230 |
3224 if (context_type != THIN_CONTEXT) { | 3231 if (context_type != THIN_CONTEXT) { |
Yang
2015/08/13 12:28:24
I suggest putting InstallExtraNatives here. Then y
| |
3225 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 3232 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
3226 } | 3233 } |
3227 isolate->counters()->contexts_created_from_scratch()->Increment(); | 3234 isolate->counters()->contexts_created_from_scratch()->Increment(); |
3228 } | 3235 } |
3229 | 3236 |
3230 // Install experimental and extra natives. Do not include them into the | 3237 // Install experimental natives. Do not include them into the |
3231 // snapshot as we should be able to turn them off at runtime. Re-installing | 3238 // snapshot as we should be able to turn them off at runtime. Re-installing |
3232 // them after they have already been deserialized would also fail. | 3239 // them after they have already been deserialized would also fail. |
3233 if (context_type == FULL_CONTEXT) { | 3240 if (context_type == FULL_CONTEXT) { |
3234 if (!isolate->serializer_enabled()) { | 3241 if (!isolate->serializer_enabled()) { |
3235 InitializeExperimentalGlobal(); | 3242 InitializeExperimentalGlobal(); |
3236 if (!InstallExperimentalNatives()) return; | 3243 if (!InstallExperimentalNatives()) return; |
3237 if (!InstallExtraNatives()) return; | |
3238 // By now the utils object is useless and can be removed. | 3244 // By now the utils object is useless and can be removed. |
3239 native_context()->set_natives_utils_object( | 3245 native_context()->set_natives_utils_object( |
3240 isolate->heap()->undefined_value()); | 3246 isolate->heap()->undefined_value()); |
3241 } | 3247 } |
3242 | 3248 |
3243 // The serializer cannot serialize typed arrays. Reset those typed arrays | 3249 // The serializer cannot serialize typed arrays. Reset those typed arrays |
3244 // for each new context. | 3250 // for each new context. |
3245 InitializeBuiltinTypedArrays(); | 3251 InitializeBuiltinTypedArrays(); |
3246 } else if (context_type == DEBUG_CONTEXT) { | 3252 } else if (context_type == DEBUG_CONTEXT) { |
3247 DCHECK(!isolate->serializer_enabled()); | 3253 DCHECK(!isolate->serializer_enabled()); |
(...skipping 28 matching lines...) Expand all Loading... | |
3276 } | 3282 } |
3277 | 3283 |
3278 | 3284 |
3279 // Called when the top-level V8 mutex is destroyed. | 3285 // Called when the top-level V8 mutex is destroyed. |
3280 void Bootstrapper::FreeThreadResources() { | 3286 void Bootstrapper::FreeThreadResources() { |
3281 DCHECK(!IsActive()); | 3287 DCHECK(!IsActive()); |
3282 } | 3288 } |
3283 | 3289 |
3284 } // namespace internal | 3290 } // namespace internal |
3285 } // namespace v8 | 3291 } // namespace v8 |
OLD | NEW |