Reviewers: Yang,

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

[email protected]

Please review this at https://codereview.chromium.org/23549010/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/api.cc
  M src/isolate.h
  M src/isolate.cc
  M src/v8.h
  M src/v8.cc


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 3e1f9fec982dbcc6231edcdd3bec8a85b8f601ab..6216e5cc5c2f7483e5ecb3560acf8a205ab65a19 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -220,7 +220,7 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
     // HeapIterator here without doing a special GC.
     isolate->heap()->RecordStats(&heap_stats, false);
   }
-  i::V8::SetFatalError();
+  isolate->SignalFatalError();
   FatalErrorCallback callback = GetFatalErrorHandler();
   const char* message = "Allocation failed - process out of memory";
   callback(location, message);
@@ -232,13 +232,15 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
 bool Utils::ReportApiFailure(const char* location, const char* message) {
   FatalErrorCallback callback = GetFatalErrorHandler();
   callback(location, message);
-  i::V8::SetFatalError();
+  i::Isolate* isolate = i::Isolate::Current();
+  isolate->SignalFatalError();
   return false;
 }


 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) {
  */
 static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) {
   return !isolate->IsInitialized()
-      && i::V8::IsDead() ? ReportV8Dead(location) : false;
+      && isolate->IsDead() ? ReportV8Dead(location) : false;
 }


@@ -2843,7 +2845,7 @@ Local<Integer> Value::ToInteger() const {

 void i::Internals::CheckInitializedImpl(v8::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()",
            "Isolate is not initialized or V8 has died");
 }
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index bcccae498411394604611ccc8879ea3c4b319c53..4157c72bdca81653df831cdd54b930dbd48bd436 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1792,6 +1792,7 @@ Isolate::Isolate()
       regexp_stack_(NULL),
       date_cache_(NULL),
       code_stub_interface_descriptors_(NULL),
+      has_fatal_error_(false),
       use_crankshaft_(true),
       initialized_from_snapshot_(false),
       cpu_profiler_(NULL),
@@ -2148,6 +2149,8 @@ bool Isolate::Init(Deserializer* des) {

   stress_deopt_count_ = FLAG_deopt_every_n_times;

+  has_fatal_error_ = false;
+
   use_crankshaft_ = FLAG_crankshaft
       && !Serializer::enabled()
       && CPU::SupportsCrankshaft();
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index 9220a6a93d6718889add651968ecc712c6a54737..5de7f82b52ad97468076b3c11e468961cb2dabc5 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -1059,6 +1059,9 @@ class Isolate {
     thread_local_top_.top_lookup_result_ = top;
   }

+  bool IsDead() { return has_fatal_error_; }
+  void SignalFatalError() { has_fatal_error_ = true; }
+
   bool use_crankshaft() { return use_crankshaft_; }

   bool initialized_from_snapshot() { return initialized_from_snapshot_; }
@@ -1302,6 +1305,9 @@ class Isolate {
unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
   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.
   bool use_crankshaft_;

Index: src/v8.cc
diff --git a/src/v8.cc b/src/v8.cc
index 31d2dd579d66e880dd294b0d45efd8903cb7c701..65b2830884f216de759ae610ce31b2603f83a783 100644
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -53,7 +53,6 @@ V8_DECLARE_ONCE(init_once);
 bool V8::is_running_ = false;
 bool V8::has_been_set_up_ = false;
 bool V8::has_been_disposed_ = false;
-bool V8::has_fatal_error_ = false;
 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL;
 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL;

@@ -79,26 +78,18 @@ bool V8::Initialize(Deserializer* des) {
   ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() ==
          i::Isolate::Current());

-  if (IsDead()) return false;
-
   Isolate* isolate = Isolate::Current();
+  if (isolate->IsDead()) return false;
   if (isolate->IsInitialized()) return true;

   is_running_ = true;
   has_been_set_up_ = true;
-  has_fatal_error_ = false;
   has_been_disposed_ = false;

   return isolate->Init(des);
 }


-void V8::SetFatalError() {
-  is_running_ = false;
-  has_fatal_error_ = true;
-}
-
-
 void V8::TearDown() {
   Isolate* isolate = Isolate::Current();
   ASSERT(isolate->IsDefaultIsolate());
Index: src/v8.h
diff --git a/src/v8.h b/src/v8.h
index aee4890aa066a9a949346d522b3106174fba9ae3..3258f2a66875cfb68f3f8d891bdf34e028a282c7 100644
--- a/src/v8.h
+++ b/src/v8.h
@@ -83,10 +83,6 @@ class V8 : public AllStatic {
   static bool Initialize(Deserializer* des);
   static void TearDown();
   static bool IsRunning() { return is_running_; }
-  // 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.
   static void FatalProcessOutOfMemory(const char* location,
@@ -134,9 +130,6 @@ class V8 : public AllStatic {
   static bool is_running_;
   // True if V8 has ever been run
   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
   // (reset if engine is restarted)
   static bool has_been_disposed_;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to