OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 delegate->shared()->DontAdaptArguments(); | 1309 delegate->shared()->DontAdaptArguments(); |
1310 } | 1310 } |
1311 | 1311 |
1312 // Initialize the out of memory slot. | 1312 // Initialize the out of memory slot. |
1313 native_context()->set_out_of_memory(heap->false_value()); | 1313 native_context()->set_out_of_memory(heap->false_value()); |
1314 | 1314 |
1315 // Initialize the embedder data slot. | 1315 // Initialize the embedder data slot. |
1316 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); | 1316 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); |
1317 native_context()->set_embedder_data(*embedder_data); | 1317 native_context()->set_embedder_data(*embedder_data); |
1318 | 1318 |
1319 { | 1319 // Allocate the random seed slot. |
1320 // Initialize the random seed slot. | 1320 Handle<ByteArray> random_seed = factory->NewByteArray(kRandomStateSize); |
1321 Handle<ByteArray> zeroed_byte_array( | 1321 native_context()->set_random_seed(*random_seed); |
1322 factory->NewByteArray(kRandomStateSize)); | |
1323 native_context()->set_random_seed(*zeroed_byte_array); | |
1324 memset(zeroed_byte_array->GetDataStartAddress(), 0, kRandomStateSize); | |
1325 } | |
1326 } | 1322 } |
1327 | 1323 |
1328 | 1324 |
1329 Handle<JSFunction> Genesis::InstallTypedArray( | 1325 Handle<JSFunction> Genesis::InstallTypedArray( |
1330 const char* name, ElementsKind elementsKind) { | 1326 const char* name, ElementsKind elementsKind) { |
1331 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1327 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
1332 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, | 1328 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, |
1333 JSTypedArray::kSize, isolate()->initial_object_prototype(), | 1329 JSTypedArray::kSize, isolate()->initial_object_prototype(), |
1334 Builtins::kIllegal, false, true); | 1330 Builtins::kIllegal, false, true); |
1335 | 1331 |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 MakeFunctionInstancePrototypeWritable(); | 2636 MakeFunctionInstancePrototypeWritable(); |
2641 | 2637 |
2642 if (!ConfigureGlobalObjects(global_template)) return; | 2638 if (!ConfigureGlobalObjects(global_template)) return; |
2643 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2639 isolate->counters()->contexts_created_from_scratch()->Increment(); |
2644 } | 2640 } |
2645 | 2641 |
2646 // Initialize experimental globals and install experimental natives. | 2642 // Initialize experimental globals and install experimental natives. |
2647 InitializeExperimentalGlobal(); | 2643 InitializeExperimentalGlobal(); |
2648 if (!InstallExperimentalNatives()) return; | 2644 if (!InstallExperimentalNatives()) return; |
2649 | 2645 |
| 2646 // Initially seed the per-context random number generator |
| 2647 // using the per-isolate random number generator. |
| 2648 uint32_t* state = reinterpret_cast<uint32_t*>( |
| 2649 native_context()->random_seed()->GetDataStartAddress()); |
| 2650 do { |
| 2651 isolate->random_number_generator()->NextBytes(state, kRandomStateSize); |
| 2652 } while (state[0] == 0 || state[1] == 0); |
| 2653 |
2650 result_ = native_context(); | 2654 result_ = native_context(); |
2651 } | 2655 } |
2652 | 2656 |
2653 | 2657 |
2654 // Support for thread preemption. | 2658 // Support for thread preemption. |
2655 | 2659 |
2656 // Reserve space for statics needing saving and restoring. | 2660 // Reserve space for statics needing saving and restoring. |
2657 int Bootstrapper::ArchiveSpacePerThread() { | 2661 int Bootstrapper::ArchiveSpacePerThread() { |
2658 return sizeof(NestingCounterType); | 2662 return sizeof(NestingCounterType); |
2659 } | 2663 } |
(...skipping 13 matching lines...) Expand all Loading... |
2673 return from + sizeof(NestingCounterType); | 2677 return from + sizeof(NestingCounterType); |
2674 } | 2678 } |
2675 | 2679 |
2676 | 2680 |
2677 // Called when the top-level V8 mutex is destroyed. | 2681 // Called when the top-level V8 mutex is destroyed. |
2678 void Bootstrapper::FreeThreadResources() { | 2682 void Bootstrapper::FreeThreadResources() { |
2679 ASSERT(!IsActive()); | 2683 ASSERT(!IsActive()); |
2680 } | 2684 } |
2681 | 2685 |
2682 } } // namespace v8::internal | 2686 } } // namespace v8::internal |
OLD | NEW |