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(); |
206 // Installs the contents of the native .js files on the global objects. | 207 // Installs the contents of the native .js files on the global objects. |
207 // Used for creating a context from scratch. | 208 // Used for creating a context from scratch. |
208 void InstallNativeFunctions(); | 209 void InstallNativeFunctions(); |
209 void InstallExperimentalNativeFunctions(); | 210 void InstallExperimentalNativeFunctions(); |
210 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, | 211 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, |
211 const char* name, | 212 const char* name, |
212 ElementsKind elements_kind); | 213 ElementsKind elements_kind); |
213 bool InstallNatives(); | 214 bool InstallNatives(); |
214 | 215 |
215 void InstallTypedArray( | 216 void InstallTypedArray( |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 elements_kind); | 1345 elements_kind); |
1345 JSFunction::SetInitialMap(result, initial_map, | 1346 JSFunction::SetInitialMap(result, initial_map, |
1346 handle(initial_map->prototype(), isolate())); | 1347 handle(initial_map->prototype(), isolate())); |
1347 *fun = result; | 1348 *fun = result; |
1348 | 1349 |
1349 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); | 1350 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); |
1350 *external_map = Map::AsElementsKind(initial_map, external_kind); | 1351 *external_map = Map::AsElementsKind(initial_map, external_kind); |
1351 } | 1352 } |
1352 | 1353 |
1353 | 1354 |
| 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 |
1354 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1369 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
1355 Vector<const char> name = Natives::GetScriptName(index); | 1370 Vector<const char> name = Natives::GetScriptName(index); |
1356 Handle<String> source_code = | 1371 Handle<String> source_code = |
1357 isolate->bootstrapper()->NativesSourceLookup(index); | 1372 isolate->bootstrapper()->NativesSourceLookup(index); |
1358 return CompileNative(isolate, name, source_code); | 1373 return CompileNative(isolate, name, source_code); |
1359 } | 1374 } |
1360 | 1375 |
1361 | 1376 |
1362 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { | 1377 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { |
1363 Vector<const char> name = ExperimentalNatives::GetScriptName(index); | 1378 Vector<const char> name = ExperimentalNatives::GetScriptName(index); |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 if (!InstallNatives()) return; | 2659 if (!InstallNatives()) return; |
2645 | 2660 |
2646 MakeFunctionInstancePrototypeWritable(); | 2661 MakeFunctionInstancePrototypeWritable(); |
2647 | 2662 |
2648 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 2663 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
2649 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2664 isolate->counters()->contexts_created_from_scratch()->Increment(); |
2650 } | 2665 } |
2651 | 2666 |
2652 // Install experimental natives. | 2667 // Install experimental natives. |
2653 if (!InstallExperimentalNatives()) return; | 2668 if (!InstallExperimentalNatives()) return; |
| 2669 InitializeExperimentalGlobal(); |
2654 | 2670 |
2655 // We can't (de-)serialize typed arrays currently, but we are lucky: The state | 2671 // We can't (de-)serialize typed arrays currently, but we are lucky: The state |
2656 // of the random number generator needs no initialization during snapshot | 2672 // of the random number generator needs no initialization during snapshot |
2657 // creation time and we don't need trigonometric functions then. | 2673 // creation time and we don't need trigonometric functions then. |
2658 if (!isolate->serializer_enabled()) { | 2674 if (!isolate->serializer_enabled()) { |
2659 // Initially seed the per-context random number generator using the | 2675 // Initially seed the per-context random number generator using the |
2660 // per-isolate random number generator. | 2676 // per-isolate random number generator. |
2661 const int num_elems = 2; | 2677 const int num_elems = 2; |
2662 const int num_bytes = num_elems * sizeof(uint32_t); | 2678 const int num_bytes = num_elems * sizeof(uint32_t); |
2663 uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes)); | 2679 uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2716 return from + sizeof(NestingCounterType); | 2732 return from + sizeof(NestingCounterType); |
2717 } | 2733 } |
2718 | 2734 |
2719 | 2735 |
2720 // Called when the top-level V8 mutex is destroyed. | 2736 // Called when the top-level V8 mutex is destroyed. |
2721 void Bootstrapper::FreeThreadResources() { | 2737 void Bootstrapper::FreeThreadResources() { |
2722 DCHECK(!IsActive()); | 2738 DCHECK(!IsActive()); |
2723 } | 2739 } |
2724 | 2740 |
2725 } } // namespace v8::internal | 2741 } } // namespace v8::internal |
OLD | NEW |