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