52 bool V8::is_running_ =
false;
53 bool V8::has_been_set_up_ =
false;
54 bool V8::has_been_disposed_ =
false;
55 bool V8::has_fatal_error_ =
false;
56 bool V8::use_crankshaft_ =
true;
57 List<CallCompletedCallback>* V8::call_completed_callbacks_ =
NULL;
65 FlagList::EnforceFlagImplications();
67 InitializeOncePerProcess();
81 i::Isolate::Current());
83 if (
IsDead())
return false;
85 Isolate* isolate = Isolate::Current();
89 has_been_set_up_ =
true;
90 has_fatal_error_ =
false;
91 has_been_disposed_ =
false;
93 return isolate->
Init(des);
99 has_fatal_error_ =
true;
104 Isolate* isolate = Isolate::Current();
107 if (!has_been_set_up_ || has_been_disposed_)
return;
117 has_been_disposed_ =
true;
119 delete call_completed_callbacks_;
120 call_completed_callbacks_ =
NULL;
126 static void seed_random(uint32_t* state) {
127 for (
int i = 0; i < 2; ++i) {
128 if (FLAG_random_seed != 0) {
129 state[i] = FLAG_random_seed;
130 }
else if (entropy_source !=
NULL) {
132 ScopedLock lock(entropy_mutex.
Pointer());
133 entropy_source(reinterpret_cast<unsigned char*>(&val),
sizeof(uint32_t));
143 static uint32_t random_base(uint32_t* state) {
146 if (state[0] == 0) seed_random(state);
149 state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16);
150 state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16);
152 return (state[0] << 14) + (state[1] & 0x3FFFF);
157 entropy_source = source;
163 StackFrame::SetReturnAddressLocationResolver(resolver);
169 ASSERT(context->IsGlobalContext());
171 return random_base(reinterpret_cast<uint32_t*>(seed->GetDataStartAddress()));
179 ASSERT(isolate == Isolate::Current());
180 return random_base(isolate->private_random_seed());
187 if (!FLAG_use_idle_notification)
return true;
190 return HEAP->IdleNotification(hint);
195 if (call_completed_callbacks_ ==
NULL) {
198 for (
int i = 0; i < call_completed_callbacks_->length(); i++) {
199 if (callback == call_completed_callbacks_->
at(i))
return;
201 call_completed_callbacks_->
Add(callback);
206 if (call_completed_callbacks_ ==
NULL)
return;
207 for (
int i = 0; i < call_completed_callbacks_->length(); i++) {
208 if (callback == call_completed_callbacks_->
at(i)) {
209 call_completed_callbacks_->
Remove(i);
216 if (call_completed_callbacks_ ==
NULL)
return;
222 for (
int i = 0; i < call_completed_callbacks_->length(); i++) {
223 call_completed_callbacks_->
at(i)();
239 uint64_t random_bits =
Random(context);
243 static const double binary_million = 1048576.0;
252 void V8::InitializeOncePerProcessImpl() {
255 use_crankshaft_ = FLAG_crankshaft;
258 use_crankshaft_ =
false;
263 use_crankshaft_ =
false;
272 if (FLAG_stress_compaction) {
273 FLAG_force_marking_deque_overflows =
true;
274 FLAG_gc_global =
true;
281 ExternalReference::SetUp();
284 void V8::InitializeOncePerProcess() {
285 CallOnce(&init_once, &InitializeOncePerProcessImpl);
static bool Initialize(Deserializer *des)
void(* CallCompletedCallback)()
static void TearDownCaches()
HandleScopeImplementer * handle_scope_implementer()
V8_DECLARE_ONCE(initialize_gc_once)
static void SetFatalError()
static void FireCallCompletedCallback(Isolate *isolate)
void CallOnce(OnceType *once, NoArgFunction init_func)
bool Init(Deserializer *des)
static Object * FillHeapNumberWithRandom(Object *heap_number, Context *context)
#define ASSERT(condition)
static PerIsolateThreadData * CurrentPerIsolateThreadData()
static void SetUpCaches()
bool IsDefaultIsolate() const
static bool IdleNotification(int hint)
static void SetEntropySource(EntropySource source)
static ThreadId Current()
static void EnterDefaultIsolate()
void IncrementCallDepth()
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
static void InitializeOncePerProcess()
static void RemoveCallCompletedCallback(CallCompletedCallback callback)
static void UnregisterAll()
static bool SupportsCrankshaft()
static void GlobalSetUp()
LazyDynamicInstance< Mutex, CreateMutexTrait, ThreadSafeInitOnceTrait >::type LazyMutex
static HeapNumber * cast(Object *obj)
void set_value(double value)
void SetUpJSCallerSavedCodeData()
static uint32_t RandomPrivate(Isolate *isolate)
static void AddCallCompletedCallback(CallCompletedCallback callback)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver resolver)
bool(* EntropySource)(unsigned char *buffer, size_t length)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
void DecrementCallDepth()
static uint32_t Random(Context *context)