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 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 } | 2399 } |
2404 | 2400 |
2405 | 2401 |
2406 bool Genesis::ConfigureGlobalObjects( | 2402 bool Genesis::ConfigureGlobalObjects( |
2407 v8::Handle<v8::ObjectTemplate> global_proxy_template) { | 2403 v8::Handle<v8::ObjectTemplate> global_proxy_template) { |
2408 Handle<JSObject> global_proxy( | 2404 Handle<JSObject> global_proxy( |
2409 JSObject::cast(native_context()->global_proxy())); | 2405 JSObject::cast(native_context()->global_proxy())); |
2410 Handle<JSObject> inner_global( | 2406 Handle<JSObject> inner_global( |
2411 JSObject::cast(native_context()->global_object())); | 2407 JSObject::cast(native_context()->global_object())); |
2412 | 2408 |
| 2409 // Initially seed the per-context random number generator |
| 2410 // using the per-isolate random number generator. |
| 2411 uint32_t* state = reinterpret_cast<uint32_t*>( |
| 2412 native_context()->random_seed()->GetDataStartAddress()); |
| 2413 do { |
| 2414 isolate()->random_number_generator()->NextBytes(state, kRandomStateSize); |
| 2415 } while (state[0] == 0 || state[1] == 0); |
| 2416 |
2413 if (!global_proxy_template.IsEmpty()) { | 2417 if (!global_proxy_template.IsEmpty()) { |
2414 // Configure the global proxy object. | 2418 // Configure the global proxy object. |
2415 Handle<ObjectTemplateInfo> proxy_data = | 2419 Handle<ObjectTemplateInfo> proxy_data = |
2416 v8::Utils::OpenHandle(*global_proxy_template); | 2420 v8::Utils::OpenHandle(*global_proxy_template); |
2417 if (!ConfigureApiObject(global_proxy, proxy_data)) return false; | 2421 if (!ConfigureApiObject(global_proxy, proxy_data)) return false; |
2418 | 2422 |
2419 // Configure the inner global object. | 2423 // Configure the inner global object. |
2420 Handle<FunctionTemplateInfo> proxy_constructor( | 2424 Handle<FunctionTemplateInfo> proxy_constructor( |
2421 FunctionTemplateInfo::cast(proxy_data->constructor())); | 2425 FunctionTemplateInfo::cast(proxy_data->constructor())); |
2422 if (!proxy_constructor->prototype_template()->IsUndefined()) { | 2426 if (!proxy_constructor->prototype_template()->IsUndefined()) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |