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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "store-buffer.h" | 46 #include "store-buffer.h" |
47 | 47 |
48 namespace v8 { | 48 namespace v8 { |
49 namespace internal { | 49 namespace internal { |
50 | 50 |
51 V8_DECLARE_ONCE(init_once); | 51 V8_DECLARE_ONCE(init_once); |
52 | 52 |
53 bool V8::is_running_ = false; | 53 bool V8::is_running_ = false; |
54 bool V8::has_been_set_up_ = false; | 54 bool V8::has_been_set_up_ = false; |
55 bool V8::has_been_disposed_ = false; | 55 bool V8::has_been_disposed_ = false; |
56 bool V8::has_fatal_error_ = false; | |
57 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; | 56 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; |
58 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; | 57 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; |
59 | 58 |
60 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; | 59 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; |
61 | 60 |
62 static EntropySource entropy_source; | 61 static EntropySource entropy_source; |
63 | 62 |
64 | 63 |
65 bool V8::Initialize(Deserializer* des) { | 64 bool V8::Initialize(Deserializer* des) { |
66 InitializeOncePerProcess(); | 65 InitializeOncePerProcess(); |
67 | 66 |
68 // The current thread may not yet had entered an isolate to run. | 67 // The current thread may not yet had entered an isolate to run. |
69 // Note the Isolate::Current() may be non-null because for various | 68 // Note the Isolate::Current() may be non-null because for various |
70 // initialization purposes an initializing thread may be assigned an isolate | 69 // initialization purposes an initializing thread may be assigned an isolate |
71 // but not actually enter it. | 70 // but not actually enter it. |
72 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { | 71 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { |
73 i::Isolate::EnterDefaultIsolate(); | 72 i::Isolate::EnterDefaultIsolate(); |
74 } | 73 } |
75 | 74 |
76 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); | 75 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); |
77 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( | 76 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( |
78 i::ThreadId::Current())); | 77 i::ThreadId::Current())); |
79 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == | 78 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == |
80 i::Isolate::Current()); | 79 i::Isolate::Current()); |
81 | 80 |
82 if (IsDead()) return false; | |
83 | |
84 Isolate* isolate = Isolate::Current(); | 81 Isolate* isolate = Isolate::Current(); |
| 82 if (isolate->IsDead()) return false; |
85 if (isolate->IsInitialized()) return true; | 83 if (isolate->IsInitialized()) return true; |
86 | 84 |
87 is_running_ = true; | 85 is_running_ = true; |
88 has_been_set_up_ = true; | 86 has_been_set_up_ = true; |
89 has_fatal_error_ = false; | |
90 has_been_disposed_ = false; | 87 has_been_disposed_ = false; |
91 | 88 |
92 return isolate->Init(des); | 89 return isolate->Init(des); |
93 } | 90 } |
94 | 91 |
95 | 92 |
96 void V8::SetFatalError() { | |
97 is_running_ = false; | |
98 has_fatal_error_ = true; | |
99 } | |
100 | |
101 | |
102 void V8::TearDown() { | 93 void V8::TearDown() { |
103 Isolate* isolate = Isolate::Current(); | 94 Isolate* isolate = Isolate::Current(); |
104 ASSERT(isolate->IsDefaultIsolate()); | 95 ASSERT(isolate->IsDefaultIsolate()); |
105 | 96 |
106 if (!has_been_set_up_ || has_been_disposed_) return; | 97 if (!has_been_set_up_ || has_been_disposed_) return; |
107 | 98 |
108 // The isolate has to be torn down before clearing the LOperand | 99 // The isolate has to be torn down before clearing the LOperand |
109 // caches so that the optimizing compiler thread (if running) | 100 // caches so that the optimizing compiler thread (if running) |
110 // doesn't see an inconsistent view of the lithium instructions. | 101 // doesn't see an inconsistent view of the lithium instructions. |
111 isolate->TearDown(); | 102 isolate->TearDown(); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 ExternalReference::SetUp(); | 315 ExternalReference::SetUp(); |
325 Bootstrapper::InitializeOncePerProcess(); | 316 Bootstrapper::InitializeOncePerProcess(); |
326 } | 317 } |
327 | 318 |
328 | 319 |
329 void V8::InitializeOncePerProcess() { | 320 void V8::InitializeOncePerProcess() { |
330 CallOnce(&init_once, &InitializeOncePerProcessImpl); | 321 CallOnce(&init_once, &InitializeOncePerProcessImpl); |
331 } | 322 } |
332 | 323 |
333 } } // namespace v8::internal | 324 } } // namespace v8::internal |
OLD | NEW |