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 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); | 2079 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); |
2080 DCHECK(bridge->context() == *isolate()->native_context()); | 2080 DCHECK(bridge->context() == *isolate()->native_context()); |
2081 | 2081 |
2082 // Allocate the builtins context. | 2082 // Allocate the builtins context. |
2083 Handle<Context> context = | 2083 Handle<Context> context = |
2084 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); | 2084 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); |
2085 context->set_global_object(*builtins); // override builtins global object | 2085 context->set_global_object(*builtins); // override builtins global object |
2086 | 2086 |
2087 native_context()->set_runtime_context(*context); | 2087 native_context()->set_runtime_context(*context); |
2088 | 2088 |
2089 if (context_type == THIN_CONTEXT) { | |
2090 int js_builtins_script_index = Natives::GetDebuggerCount(); | |
2091 if (!Bootstrapper::CompileBuiltin(isolate(), js_builtins_script_index)) | |
2092 return false; | |
2093 if (!InstallJSBuiltins(builtins)) return false; | |
2094 return true; | |
2095 } | |
2096 | |
2097 // Set up the utils object as shared container between native scripts. | 2089 // Set up the utils object as shared container between native scripts. |
2098 Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function()); | 2090 Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function()); |
2099 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, | 2091 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, |
2100 "utils container for native scripts"); | 2092 "utils container for native scripts"); |
2101 native_context()->set_natives_utils_object(*utils); | 2093 native_context()->set_natives_utils_object(*utils); |
2102 | 2094 |
| 2095 int builtin_index = Natives::GetDebuggerCount(); |
| 2096 // Only run prologue.js and runtime.js at this point. |
| 2097 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); |
| 2098 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
| 2099 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); |
| 2100 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
| 2101 if (!InstallJSBuiltins(builtins)) return false; |
| 2102 |
| 2103 // A thin context is ready at this point. |
| 2104 if (context_type == THIN_CONTEXT) return true; |
| 2105 |
2103 if (FLAG_expose_natives_as != NULL) { | 2106 if (FLAG_expose_natives_as != NULL) { |
2104 Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils"); | 2107 Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils"); |
2105 JSObject::AddProperty(builtins, utils_key, utils, NONE); | 2108 JSObject::AddProperty(builtins, utils_key, utils, NONE); |
2106 } | 2109 } |
2107 | 2110 |
2108 { // -- S c r i p t | 2111 { // -- S c r i p t |
2109 // Builtin functions for Script. | 2112 // Builtin functions for Script. |
2110 Handle<JSFunction> script_fun = InstallFunction( | 2113 Handle<JSFunction> script_fun = InstallFunction( |
2111 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, | 2114 builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, |
2112 isolate()->initial_object_prototype(), Builtins::kIllegal); | 2115 isolate()->initial_object_prototype(), Builtins::kIllegal); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 { | 2381 { |
2379 static const PropertyAttributes attributes = | 2382 static const PropertyAttributes attributes = |
2380 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 2383 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
2381 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ | 2384 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ |
2382 Handle<String> varname = factory()->NewStringFromStaticChars(#varname); \ | 2385 Handle<String> varname = factory()->NewStringFromStaticChars(#varname); \ |
2383 JSObject::AddProperty(builtins, varname, factory()->name(), attributes); | 2386 JSObject::AddProperty(builtins, varname, factory()->name(), attributes); |
2384 PUBLIC_SYMBOL_LIST(INSTALL_PUBLIC_SYMBOL) | 2387 PUBLIC_SYMBOL_LIST(INSTALL_PUBLIC_SYMBOL) |
2385 #undef INSTALL_PUBLIC_SYMBOL | 2388 #undef INSTALL_PUBLIC_SYMBOL |
2386 } | 2389 } |
2387 | 2390 |
2388 int i = Natives::GetDebuggerCount(); | 2391 // Run the rest of the native scripts. |
2389 if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false; | 2392 while (builtin_index < Natives::GetBuiltinsCount()) { |
2390 | 2393 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
2391 if (!InstallJSBuiltins(builtins)) return false; | |
2392 | |
2393 for (++i; i < Natives::GetBuiltinsCount(); ++i) { | |
2394 if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false; | |
2395 } | 2394 } |
2396 | 2395 |
2397 if (!CallUtilsFunction(isolate(), "PostNatives")) return false; | 2396 if (!CallUtilsFunction(isolate(), "PostNatives")) return false; |
2398 | 2397 |
2399 auto function_cache = | 2398 auto function_cache = |
2400 ObjectHashTable::New(isolate(), ApiNatives::kInitialFunctionCacheSize, | 2399 ObjectHashTable::New(isolate(), ApiNatives::kInitialFunctionCacheSize, |
2401 USE_CUSTOM_MINIMUM_CAPACITY); | 2400 USE_CUSTOM_MINIMUM_CAPACITY); |
2402 native_context()->set_function_cache(*function_cache); | 2401 native_context()->set_function_cache(*function_cache); |
2403 | 2402 |
2404 // Store the map for the string prototype after the natives has been compiled | 2403 // Store the map for the string prototype after the natives has been compiled |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3279 } | 3278 } |
3280 | 3279 |
3281 | 3280 |
3282 // Called when the top-level V8 mutex is destroyed. | 3281 // Called when the top-level V8 mutex is destroyed. |
3283 void Bootstrapper::FreeThreadResources() { | 3282 void Bootstrapper::FreeThreadResources() { |
3284 DCHECK(!IsActive()); | 3283 DCHECK(!IsActive()); |
3285 } | 3284 } |
3286 | 3285 |
3287 } // namespace internal | 3286 } // namespace internal |
3288 } // namespace v8 | 3287 } // namespace v8 |
OLD | NEW |