| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // deserialized, leaving the GC to pick it up. | 196 // deserialized, leaving the GC to pick it up. |
| 197 void HookUpGlobalProxy(Handle<GlobalObject> global_object, | 197 void HookUpGlobalProxy(Handle<GlobalObject> global_object, |
| 198 Handle<JSGlobalProxy> global_proxy); | 198 Handle<JSGlobalProxy> global_proxy); |
| 199 // Similarly, we want to use the global that has been created by the templates | 199 // Similarly, we want to use the global that has been created by the templates |
| 200 // passed through the API. The global from the snapshot is detached from the | 200 // passed through the API. The global from the snapshot is detached from the |
| 201 // other objects in the snapshot. | 201 // other objects in the snapshot. |
| 202 void HookUpGlobalObject(Handle<GlobalObject> global_object); | 202 void HookUpGlobalObject(Handle<GlobalObject> global_object); |
| 203 // New context initialization. Used for creating a context from scratch. | 203 // New context initialization. Used for creating a context from scratch. |
| 204 void InitializeGlobal(Handle<GlobalObject> global_object, | 204 void InitializeGlobal(Handle<GlobalObject> global_object, |
| 205 Handle<JSFunction> empty_function); | 205 Handle<JSFunction> empty_function); |
| 206 void InitializeExperimentalGlobal(); | |
| 207 // Installs the contents of the native .js files on the global objects. | 206 // Installs the contents of the native .js files on the global objects. |
| 208 // Used for creating a context from scratch. | 207 // Used for creating a context from scratch. |
| 209 void InstallNativeFunctions(); | 208 void InstallNativeFunctions(); |
| 210 void InstallExperimentalNativeFunctions(); | 209 void InstallExperimentalNativeFunctions(); |
| 211 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, | 210 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, |
| 212 const char* name, | 211 const char* name, |
| 213 ElementsKind elements_kind); | 212 ElementsKind elements_kind); |
| 214 bool InstallNatives(); | 213 bool InstallNatives(); |
| 215 | 214 |
| 216 void InstallTypedArray( | 215 void InstallTypedArray( |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 elements_kind); | 1344 elements_kind); |
| 1346 JSFunction::SetInitialMap(result, initial_map, | 1345 JSFunction::SetInitialMap(result, initial_map, |
| 1347 handle(initial_map->prototype(), isolate())); | 1346 handle(initial_map->prototype(), isolate())); |
| 1348 *fun = result; | 1347 *fun = result; |
| 1349 | 1348 |
| 1350 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); | 1349 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); |
| 1351 *external_map = Map::AsElementsKind(initial_map, external_kind); | 1350 *external_map = Map::AsElementsKind(initial_map, external_kind); |
| 1352 } | 1351 } |
| 1353 | 1352 |
| 1354 | 1353 |
| 1355 void Genesis::InitializeExperimentalGlobal() { | |
| 1356 // TODO(erikcorry): Move this into Genesis::InitializeGlobal once we no | |
| 1357 // longer need to live behind a flag. | |
| 1358 Handle<JSObject> builtins(native_context()->builtins()); | |
| 1359 | |
| 1360 Handle<HeapObject> flag( | |
| 1361 FLAG_harmony_regexps ? heap()->true_value() : heap()->false_value()); | |
| 1362 PropertyAttributes attributes = | |
| 1363 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | |
| 1364 Runtime::DefineObjectProperty(builtins, factory()->harmony_regexps_string(), | |
| 1365 flag, attributes).Assert(); | |
| 1366 } | |
| 1367 | |
| 1368 | |
| 1369 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1354 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
| 1370 Vector<const char> name = Natives::GetScriptName(index); | 1355 Vector<const char> name = Natives::GetScriptName(index); |
| 1371 Handle<String> source_code = | 1356 Handle<String> source_code = |
| 1372 isolate->bootstrapper()->NativesSourceLookup(index); | 1357 isolate->bootstrapper()->NativesSourceLookup(index); |
| 1373 return CompileNative(isolate, name, source_code); | 1358 return CompileNative(isolate, name, source_code); |
| 1374 } | 1359 } |
| 1375 | 1360 |
| 1376 | 1361 |
| 1377 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { | 1362 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { |
| 1378 Vector<const char> name = ExperimentalNatives::GetScriptName(index); | 1363 Vector<const char> name = ExperimentalNatives::GetScriptName(index); |
| (...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 if (!InstallNatives()) return; | 2644 if (!InstallNatives()) return; |
| 2660 | 2645 |
| 2661 MakeFunctionInstancePrototypeWritable(); | 2646 MakeFunctionInstancePrototypeWritable(); |
| 2662 | 2647 |
| 2663 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 2648 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
| 2664 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2649 isolate->counters()->contexts_created_from_scratch()->Increment(); |
| 2665 } | 2650 } |
| 2666 | 2651 |
| 2667 // Install experimental natives. | 2652 // Install experimental natives. |
| 2668 if (!InstallExperimentalNatives()) return; | 2653 if (!InstallExperimentalNatives()) return; |
| 2669 InitializeExperimentalGlobal(); | |
| 2670 | 2654 |
| 2671 // We can't (de-)serialize typed arrays currently, but we are lucky: The state | 2655 // We can't (de-)serialize typed arrays currently, but we are lucky: The state |
| 2672 // of the random number generator needs no initialization during snapshot | 2656 // of the random number generator needs no initialization during snapshot |
| 2673 // creation time and we don't need trigonometric functions then. | 2657 // creation time and we don't need trigonometric functions then. |
| 2674 if (!isolate->serializer_enabled()) { | 2658 if (!isolate->serializer_enabled()) { |
| 2675 // Initially seed the per-context random number generator using the | 2659 // Initially seed the per-context random number generator using the |
| 2676 // per-isolate random number generator. | 2660 // per-isolate random number generator. |
| 2677 const int num_elems = 2; | 2661 const int num_elems = 2; |
| 2678 const int num_bytes = num_elems * sizeof(uint32_t); | 2662 const int num_bytes = num_elems * sizeof(uint32_t); |
| 2679 uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes)); | 2663 uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2732 return from + sizeof(NestingCounterType); | 2716 return from + sizeof(NestingCounterType); |
| 2733 } | 2717 } |
| 2734 | 2718 |
| 2735 | 2719 |
| 2736 // Called when the top-level V8 mutex is destroyed. | 2720 // Called when the top-level V8 mutex is destroyed. |
| 2737 void Bootstrapper::FreeThreadResources() { | 2721 void Bootstrapper::FreeThreadResources() { |
| 2738 DCHECK(!IsActive()); | 2722 DCHECK(!IsActive()); |
| 2739 } | 2723 } |
| 2740 | 2724 |
| 2741 } } // namespace v8::internal | 2725 } } // namespace v8::internal |
| OLD | NEW |