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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 Handle<JSGlobalProxy> global_proxy); | 194 Handle<JSGlobalProxy> global_proxy); |
195 // Similarly, we want to use the global that has been created by the templates | 195 // Similarly, we want to use the global that has been created by the templates |
196 // passed through the API. The global from the snapshot is detached from the | 196 // passed through the API. The global from the snapshot is detached from the |
197 // other objects in the snapshot. | 197 // other objects in the snapshot. |
198 void HookUpGlobalObject(Handle<GlobalObject> global_object, | 198 void HookUpGlobalObject(Handle<GlobalObject> global_object, |
199 Handle<FixedArray> outdated_contexts); | 199 Handle<FixedArray> outdated_contexts); |
200 // New context initialization. Used for creating a context from scratch. | 200 // New context initialization. Used for creating a context from scratch. |
201 void InitializeGlobal(Handle<GlobalObject> global_object, | 201 void InitializeGlobal(Handle<GlobalObject> global_object, |
202 Handle<JSFunction> empty_function); | 202 Handle<JSFunction> empty_function); |
203 void InitializeExperimentalGlobal(); | 203 void InitializeExperimentalGlobal(); |
| 204 void InitializeExtrasExportsObject(); |
204 // Installs the contents of the native .js files on the global objects. | 205 // Installs the contents of the native .js files on the global objects. |
205 // Used for creating a context from scratch. | 206 // Used for creating a context from scratch. |
206 void InstallNativeFunctions(); | 207 void InstallNativeFunctions(); |
207 void InstallExperimentalNativeFunctions(); | 208 void InstallExperimentalNativeFunctions(); |
208 // Typed arrays are not serializable and have to initialized afterwards. | 209 // Typed arrays are not serializable and have to initialized afterwards. |
209 void InitializeBuiltinTypedArrays(); | 210 void InitializeBuiltinTypedArrays(); |
210 | 211 |
211 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ | 212 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ |
212 void InstallNativeFunctions_##id(); \ | 213 void InstallNativeFunctions_##id(); \ |
213 void InitializeGlobal_##id(); | 214 void InitializeGlobal_##id(); |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 void Genesis::InitializeExperimentalGlobal() { | 1435 void Genesis::InitializeExperimentalGlobal() { |
1435 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); | 1436 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); |
1436 | 1437 |
1437 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) | 1438 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) |
1438 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) | 1439 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) |
1439 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) | 1440 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) |
1440 #undef FEATURE_INITIALIZE_GLOBAL | 1441 #undef FEATURE_INITIALIZE_GLOBAL |
1441 } | 1442 } |
1442 | 1443 |
1443 | 1444 |
| 1445 void Genesis::InitializeExtrasExportsObject() { |
| 1446 Handle<JSObject> exports = |
| 1447 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 1448 |
| 1449 native_context()->set_extras_exports_object(*exports); |
| 1450 |
| 1451 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); |
| 1452 Handle<String> exports_string = |
| 1453 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("extrasExports")); |
| 1454 Runtime::SetObjectProperty(isolate(), builtins, exports_string, exports, |
| 1455 STRICT).Assert(); |
| 1456 } |
| 1457 |
| 1458 |
1444 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1459 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
1445 Vector<const char> name = Natives::GetScriptName(index); | 1460 Vector<const char> name = Natives::GetScriptName(index); |
1446 Handle<String> source_code = | 1461 Handle<String> source_code = |
1447 isolate->bootstrapper()->SourceLookup<Natives>(index); | 1462 isolate->bootstrapper()->SourceLookup<Natives>(index); |
1448 return CompileNative(isolate, name, source_code); | 1463 return CompileNative(isolate, name, source_code); |
1449 } | 1464 } |
1450 | 1465 |
1451 | 1466 |
1452 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { | 1467 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { |
1453 Vector<const char> name = ExperimentalNatives::GetScriptName(index); | 1468 Vector<const char> name = ExperimentalNatives::GetScriptName(index); |
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2955 | 2970 |
2956 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 2971 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
2957 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2972 isolate->counters()->contexts_created_from_scratch()->Increment(); |
2958 } | 2973 } |
2959 | 2974 |
2960 // Install experimental and extra natives. Do not include them into the | 2975 // Install experimental and extra natives. Do not include them into the |
2961 // snapshot as we should be able to turn them off at runtime. Re-installing | 2976 // snapshot as we should be able to turn them off at runtime. Re-installing |
2962 // them after they have already been deserialized would also fail. | 2977 // them after they have already been deserialized would also fail. |
2963 if (!isolate->serializer_enabled()) { | 2978 if (!isolate->serializer_enabled()) { |
2964 InitializeExperimentalGlobal(); | 2979 InitializeExperimentalGlobal(); |
| 2980 InitializeExtrasExportsObject(); |
2965 if (!InstallExperimentalNatives()) return; | 2981 if (!InstallExperimentalNatives()) return; |
2966 if (!InstallExtraNatives()) return; | 2982 if (!InstallExtraNatives()) return; |
2967 } | 2983 } |
2968 | 2984 |
2969 // The serializer cannot serialize typed arrays. Reset those typed arrays | 2985 // The serializer cannot serialize typed arrays. Reset those typed arrays |
2970 // for each new context. | 2986 // for each new context. |
2971 InitializeBuiltinTypedArrays(); | 2987 InitializeBuiltinTypedArrays(); |
2972 | 2988 |
2973 result_ = native_context(); | 2989 result_ = native_context(); |
2974 } | 2990 } |
(...skipping 21 matching lines...) Expand all Loading... |
2996 return from + sizeof(NestingCounterType); | 3012 return from + sizeof(NestingCounterType); |
2997 } | 3013 } |
2998 | 3014 |
2999 | 3015 |
3000 // Called when the top-level V8 mutex is destroyed. | 3016 // Called when the top-level V8 mutex is destroyed. |
3001 void Bootstrapper::FreeThreadResources() { | 3017 void Bootstrapper::FreeThreadResources() { |
3002 DCHECK(!IsActive()); | 3018 DCHECK(!IsActive()); |
3003 } | 3019 } |
3004 | 3020 |
3005 } } // namespace v8::internal | 3021 } } // namespace v8::internal |
OLD | NEW |