| Index: src/v8.cc
|
| diff --git a/src/v8.cc b/src/v8.cc
|
| index 8153372fbbafb1dde15f8cfc687da6a117f00bad..f89ed838ce1839b07175bad884427e99ce933c6b 100644
|
| --- a/src/v8.cc
|
| +++ b/src/v8.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2006-2009 the V8 project authors. All rights reserved.
|
| +// Copyright 2011 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -41,6 +41,9 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +static Mutex* init_once_mutex = OS::CreateMutex();
|
| +static bool init_once_called = false;
|
| +
|
| bool V8::is_running_ = false;
|
| bool V8::has_been_setup_ = false;
|
| bool V8::has_been_disposed_ = false;
|
| @@ -49,6 +52,8 @@ bool V8::use_crankshaft_ = true;
|
|
|
|
|
| bool V8::Initialize(Deserializer* des) {
|
| + InitializeOncePerProcess();
|
| +
|
| // The current thread may not yet had entered an isolate to run.
|
| // Note the Isolate::Current() may be non-null because for various
|
| // initialization purposes an initializing thread may be assigned an isolate
|
| @@ -68,15 +73,6 @@ bool V8::Initialize(Deserializer* des) {
|
| Isolate* isolate = Isolate::Current();
|
| if (isolate->IsInitialized()) return true;
|
|
|
| -#if defined(V8_TARGET_ARCH_ARM) && !defined(USE_ARM_EABI)
|
| - use_crankshaft_ = false;
|
| -#else
|
| - use_crankshaft_ = FLAG_crankshaft;
|
| -#endif
|
| -
|
| - // Peephole optimization might interfere with deoptimization.
|
| - FLAG_peephole_optimization = !use_crankshaft_;
|
| -
|
| is_running_ = true;
|
| has_been_setup_ = true;
|
| has_fatal_error_ = false;
|
| @@ -171,8 +167,8 @@ typedef union {
|
| } double_int_union;
|
|
|
|
|
| -Object* V8::FillHeapNumberWithRandom(Object* heap_number) {
|
| - uint64_t random_bits = Random(Isolate::Current());
|
| +Object* V8::FillHeapNumberWithRandom(Object* heap_number, Isolate* isolate) {
|
| + uint64_t random_bits = Random(isolate);
|
| // Make a double* from address (heap_number + sizeof(double)).
|
| double_int_union* r = reinterpret_cast<double_int_union*>(
|
| reinterpret_cast<char*>(heap_number) +
|
| @@ -188,4 +184,32 @@ Object* V8::FillHeapNumberWithRandom(Object* heap_number) {
|
| return heap_number;
|
| }
|
|
|
| +
|
| +void V8::InitializeOncePerProcess() {
|
| + ScopedLock lock(init_once_mutex);
|
| + if (init_once_called) return;
|
| + init_once_called = true;
|
| +
|
| + // Setup the platform OS support.
|
| + OS::Setup();
|
| +
|
| +#if defined(V8_TARGET_ARCH_ARM) && !defined(USE_ARM_EABI)
|
| + use_crankshaft_ = false;
|
| +#else
|
| + use_crankshaft_ = FLAG_crankshaft;
|
| +#endif
|
| +
|
| + if (Serializer::enabled()) {
|
| + use_crankshaft_ = false;
|
| + }
|
| +
|
| + CPU::Setup();
|
| + if (!CPU::SupportsCrankshaft()) {
|
| + use_crankshaft_ = false;
|
| + }
|
| +
|
| + // Peephole optimization might interfere with deoptimization.
|
| + FLAG_peephole_optimization = !use_crankshaft_;
|
| +}
|
| +
|
| } } // namespace v8::internal
|
|
|