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 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 // Reset property cell type before (re)initializing. | 1795 // Reset property cell type before (re)initializing. |
1796 JSBuiltinsObject::InvalidatePropertyCell(builtins, name_string); | 1796 JSBuiltinsObject::InvalidatePropertyCell(builtins, name_string); |
1797 JSObject::SetOwnPropertyIgnoreAttributes(builtins, name_string, typed_array, | 1797 JSObject::SetOwnPropertyIgnoreAttributes(builtins, name_string, typed_array, |
1798 FROZEN) | 1798 FROZEN) |
1799 .Assert(); | 1799 .Assert(); |
1800 return data; | 1800 return data; |
1801 } | 1801 } |
1802 | 1802 |
1803 | 1803 |
1804 void Genesis::InitializeBuiltinTypedArrays() { | 1804 void Genesis::InitializeBuiltinTypedArrays() { |
1805 // The serializer cannot serialize typed arrays. Reset those typed arrays | |
1806 // for each new context. | |
1807 DCHECK(!isolate()->serializer_enabled()); | |
1808 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); | 1805 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); |
1809 { // Initially seed the per-context random number generator using the | 1806 { // Initially seed the per-context random number generator using the |
1810 // per-isolate random number generator. | 1807 // per-isolate random number generator. |
1811 const size_t num_elements = 2; | 1808 const size_t num_elements = 2; |
1812 const size_t num_bytes = num_elements * sizeof(uint32_t); | 1809 const size_t num_bytes = num_elements * sizeof(uint32_t); |
1813 uint32_t* state = SetBuiltinTypedArray<uint32_t>(isolate(), builtins, | 1810 uint32_t* state = SetBuiltinTypedArray<uint32_t>(isolate(), builtins, |
1814 kExternalUint32Array, NULL, | 1811 kExternalUint32Array, NULL, |
1815 num_elements, "rngstate"); | 1812 num_elements, "rngstate"); |
1816 do { | 1813 do { |
1817 isolate()->random_number_generator()->NextBytes(state, num_bytes); | 1814 isolate()->random_number_generator()->NextBytes(state, num_bytes); |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3226 | 3223 |
3227 if (context_type != THIN_CONTEXT) { | 3224 if (context_type != THIN_CONTEXT) { |
3228 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 3225 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
3229 } | 3226 } |
3230 isolate->counters()->contexts_created_from_scratch()->Increment(); | 3227 isolate->counters()->contexts_created_from_scratch()->Increment(); |
3231 } | 3228 } |
3232 | 3229 |
3233 // Install experimental and extra natives. Do not include them into the | 3230 // Install experimental and extra natives. Do not include them into the |
3234 // snapshot as we should be able to turn them off at runtime. Re-installing | 3231 // snapshot as we should be able to turn them off at runtime. Re-installing |
3235 // them after they have already been deserialized would also fail. | 3232 // them after they have already been deserialized would also fail. |
3236 if (!isolate->serializer_enabled() && context_type != THIN_CONTEXT) { | 3233 if (context_type == FULL_CONTEXT) { |
3237 InitializeExperimentalGlobal(); | 3234 if (!isolate->serializer_enabled()) { |
3238 InitializeBuiltinTypedArrays(); | 3235 InitializeExperimentalGlobal(); |
3239 if (context_type == FULL_CONTEXT) { | |
3240 if (!InstallExperimentalNatives()) return; | 3236 if (!InstallExperimentalNatives()) return; |
3241 if (!InstallExtraNatives()) return; | 3237 if (!InstallExtraNatives()) return; |
3242 // By now the utils object is useless and can be removed. | 3238 // By now the utils object is useless and can be removed. |
3243 native_context()->set_natives_utils_object( | 3239 native_context()->set_natives_utils_object( |
3244 isolate->heap()->undefined_value()); | 3240 isolate->heap()->undefined_value()); |
3245 InitializeBuiltinTypedArrays(); | |
3246 } else { | |
3247 DCHECK_EQ(DEBUG_CONTEXT, context_type); | |
3248 if (!InstallDebuggerNatives()) return; | |
3249 } | 3241 } |
| 3242 |
| 3243 // The serializer cannot serialize typed arrays. Reset those typed arrays |
| 3244 // for each new context. |
| 3245 InitializeBuiltinTypedArrays(); |
| 3246 } else if (context_type == DEBUG_CONTEXT) { |
| 3247 DCHECK(!isolate->serializer_enabled()); |
| 3248 InitializeExperimentalGlobal(); |
| 3249 if (!InstallDebuggerNatives()) return; |
3250 } | 3250 } |
| 3251 |
3251 result_ = native_context(); | 3252 result_ = native_context(); |
3252 } | 3253 } |
3253 | 3254 |
3254 | 3255 |
3255 // Support for thread preemption. | 3256 // Support for thread preemption. |
3256 | 3257 |
3257 // Reserve space for statics needing saving and restoring. | 3258 // Reserve space for statics needing saving and restoring. |
3258 int Bootstrapper::ArchiveSpacePerThread() { | 3259 int Bootstrapper::ArchiveSpacePerThread() { |
3259 return sizeof(NestingCounterType); | 3260 return sizeof(NestingCounterType); |
3260 } | 3261 } |
(...skipping 14 matching lines...) Expand all Loading... |
3275 } | 3276 } |
3276 | 3277 |
3277 | 3278 |
3278 // Called when the top-level V8 mutex is destroyed. | 3279 // Called when the top-level V8 mutex is destroyed. |
3279 void Bootstrapper::FreeThreadResources() { | 3280 void Bootstrapper::FreeThreadResources() { |
3280 DCHECK(!IsActive()); | 3281 DCHECK(!IsActive()); |
3281 } | 3282 } |
3282 | 3283 |
3283 } // namespace internal | 3284 } // namespace internal |
3284 } // namespace v8 | 3285 } // namespace v8 |
OLD | NEW |