Move global V8::IsDead() into the Isolate.

R=yangguo@chromium.org
BUG=v8:2744

Review URL: https://codereview.chromium.org/23549010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16496 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c41cb4be
...@@ -220,7 +220,7 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { ...@@ -220,7 +220,7 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
// HeapIterator here without doing a special GC. // HeapIterator here without doing a special GC.
isolate->heap()->RecordStats(&heap_stats, false); isolate->heap()->RecordStats(&heap_stats, false);
} }
i::V8::SetFatalError(); isolate->SignalFatalError();
FatalErrorCallback callback = GetFatalErrorHandler(); FatalErrorCallback callback = GetFatalErrorHandler();
const char* message = "Allocation failed - process out of memory"; const char* message = "Allocation failed - process out of memory";
callback(location, message); callback(location, message);
...@@ -232,13 +232,15 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { ...@@ -232,13 +232,15 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
bool Utils::ReportApiFailure(const char* location, const char* message) { bool Utils::ReportApiFailure(const char* location, const char* message) {
FatalErrorCallback callback = GetFatalErrorHandler(); FatalErrorCallback callback = GetFatalErrorHandler();
callback(location, message); callback(location, message);
i::V8::SetFatalError(); i::Isolate* isolate = i::Isolate::Current();
isolate->SignalFatalError();
return false; return false;
} }
bool V8::IsDead() { bool V8::IsDead() {
return i::V8::IsDead(); i::Isolate* isolate = i::Isolate::Current();
return isolate->IsDead();
} }
...@@ -277,7 +279,7 @@ static bool ReportEmptyHandle(const char* location) { ...@@ -277,7 +279,7 @@ static bool ReportEmptyHandle(const char* location) {
*/ */
static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) { static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) {
return !isolate->IsInitialized() return !isolate->IsInitialized()
&& i::V8::IsDead() ? ReportV8Dead(location) : false; && isolate->IsDead() ? ReportV8Dead(location) : false;
} }
...@@ -2843,7 +2845,7 @@ Local<Integer> Value::ToInteger() const { ...@@ -2843,7 +2845,7 @@ Local<Integer> Value::ToInteger() const {
void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
ApiCheck(isolate != NULL && isolate->IsInitialized() && !i::V8::IsDead(), ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(),
"v8::internal::Internals::CheckInitialized()", "v8::internal::Internals::CheckInitialized()",
"Isolate is not initialized or V8 has died"); "Isolate is not initialized or V8 has died");
} }
......
...@@ -1793,6 +1793,7 @@ Isolate::Isolate() ...@@ -1793,6 +1793,7 @@ Isolate::Isolate()
regexp_stack_(NULL), regexp_stack_(NULL),
date_cache_(NULL), date_cache_(NULL),
code_stub_interface_descriptors_(NULL), code_stub_interface_descriptors_(NULL),
has_fatal_error_(false),
use_crankshaft_(true), use_crankshaft_(true),
initialized_from_snapshot_(false), initialized_from_snapshot_(false),
cpu_profiler_(NULL), cpu_profiler_(NULL),
...@@ -2149,6 +2150,8 @@ bool Isolate::Init(Deserializer* des) { ...@@ -2149,6 +2150,8 @@ bool Isolate::Init(Deserializer* des) {
stress_deopt_count_ = FLAG_deopt_every_n_times; stress_deopt_count_ = FLAG_deopt_every_n_times;
has_fatal_error_ = false;
use_crankshaft_ = FLAG_crankshaft use_crankshaft_ = FLAG_crankshaft
&& !Serializer::enabled() && !Serializer::enabled()
&& CPU::SupportsCrankshaft(); && CPU::SupportsCrankshaft();
......
...@@ -1059,6 +1059,9 @@ class Isolate { ...@@ -1059,6 +1059,9 @@ class Isolate {
thread_local_top_.top_lookup_result_ = top; thread_local_top_.top_lookup_result_ = top;
} }
bool IsDead() { return has_fatal_error_; }
void SignalFatalError() { has_fatal_error_ = true; }
bool use_crankshaft() const { return use_crankshaft_; } bool use_crankshaft() const { return use_crankshaft_; }
bool initialized_from_snapshot() { return initialized_from_snapshot_; } bool initialized_from_snapshot() { return initialized_from_snapshot_; }
...@@ -1302,6 +1305,9 @@ class Isolate { ...@@ -1302,6 +1305,9 @@ class Isolate {
unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_; unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
CodeStubInterfaceDescriptor* code_stub_interface_descriptors_; CodeStubInterfaceDescriptor* code_stub_interface_descriptors_;
// True if fatal error has been signaled for this isolate.
bool has_fatal_error_;
// True if we are using the Crankshaft optimizing compiler. // True if we are using the Crankshaft optimizing compiler.
bool use_crankshaft_; bool use_crankshaft_;
......
...@@ -52,7 +52,6 @@ V8_DECLARE_ONCE(init_once); ...@@ -52,7 +52,6 @@ V8_DECLARE_ONCE(init_once);
bool V8::has_been_set_up_ = false; bool V8::has_been_set_up_ = false;
bool V8::has_been_disposed_ = false; bool V8::has_been_disposed_ = false;
bool V8::has_fatal_error_ = false;
List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL;
v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL;
...@@ -78,24 +77,17 @@ bool V8::Initialize(Deserializer* des) { ...@@ -78,24 +77,17 @@ bool V8::Initialize(Deserializer* des) {
ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() ==
i::Isolate::Current()); i::Isolate::Current());
if (IsDead()) return false;
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
if (isolate->IsDead()) return false;
if (isolate->IsInitialized()) return true; if (isolate->IsInitialized()) return true;
has_been_set_up_ = true; has_been_set_up_ = true;
has_fatal_error_ = false;
has_been_disposed_ = false; has_been_disposed_ = false;
return isolate->Init(des); return isolate->Init(des);
} }
void V8::SetFatalError() {
has_fatal_error_ = true;
}
void V8::TearDown() { void V8::TearDown() {
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
ASSERT(isolate->IsDefaultIsolate()); ASSERT(isolate->IsDefaultIsolate());
......
...@@ -82,10 +82,6 @@ class V8 : public AllStatic { ...@@ -82,10 +82,6 @@ class V8 : public AllStatic {
// empty heap. // empty heap.
static bool Initialize(Deserializer* des); static bool Initialize(Deserializer* des);
static void TearDown(); static void TearDown();
// To be dead you have to have lived
// TODO(isolates): move IsDead to Isolate.
static bool IsDead() { return has_fatal_error_ || has_been_disposed_; }
static void SetFatalError();
// Report process out of memory. Implementation found in api.cc. // Report process out of memory. Implementation found in api.cc.
static void FatalProcessOutOfMemory(const char* location, static void FatalProcessOutOfMemory(const char* location,
...@@ -131,9 +127,6 @@ class V8 : public AllStatic { ...@@ -131,9 +127,6 @@ class V8 : public AllStatic {
// True if V8 has ever been run // True if V8 has ever been run
static bool has_been_set_up_; static bool has_been_set_up_;
// True if error has been signaled for current engine
// (reset to false if engine is restarted)
static bool has_fatal_error_;
// True if engine has been shut down // True if engine has been shut down
// (reset if engine is restarted) // (reset if engine is restarted)
static bool has_been_disposed_; static bool has_been_disposed_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment