Reviewers: Mads Ager,

Description:
Initialize ThreadLocalTop.

ThreadLocalTop used to be static and was zero initialized by the
linker. With isolates we have to give it a constructor.

BUG=http://crbug.com/79393

Please review this at http://codereview.chromium.org/6862005/

Affected files:
  M src/isolate.h
  M src/top.cc


Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index 01b721dc269048ae134148e21120532c1e7f8dcb..35ffcb4445cf594546b62f12bac74a7afb3025b1 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -185,6 +185,10 @@ class ThreadId {

 class ThreadLocalTop BASE_EMBEDDED {
  public:
+  // Does early low-level initialization that does not depend on the
+  // isolate being present.
+  ThreadLocalTop();
+
   // Initialize the thread data.
   void Initialize();

@@ -264,6 +268,8 @@ class ThreadLocalTop BASE_EMBEDDED {
   v8::FailedAccessCheckCallback failed_access_check_callback_;

  private:
+  void InitializeInternal();
+
   Address try_catch_handler_address_;
 };

Index: src/top.cc
diff --git a/src/top.cc b/src/top.cc
index 899dfbe252c47e06750ccb17e8135fd4d6550c01..f44de7ad68d41c308f27fa9674925d91d08294ad 100644
--- a/src/top.cc
+++ b/src/top.cc
@@ -45,20 +45,16 @@
 namespace v8 {
 namespace internal {

-v8::TryCatch* ThreadLocalTop::TryCatchHandler() {
-  return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address());
+ThreadLocalTop::ThreadLocalTop() {
+  InitializeInternal();
 }


-void ThreadLocalTop::Initialize() {
+void ThreadLocalTop::InitializeInternal() {
   c_entry_fp_ = 0;
   handler_ = 0;
 #ifdef USE_SIMULATOR
-#ifdef V8_TARGET_ARCH_ARM
-  simulator_ = Simulator::current(Isolate::Current());
-#elif V8_TARGET_ARCH_MIPS
-  simulator_ = Simulator::current(Isolate::Current());
-#endif
+  simulator_ = NULL;
 #endif
 #ifdef ENABLE_LOGGING_AND_PROFILING
   js_entry_sp_ = NULL;
@@ -69,7 +65,7 @@ void ThreadLocalTop::Initialize() {
 #endif
   try_catch_handler_address_ = NULL;
   context_ = NULL;
-  thread_id_ = ThreadId::Current();
+  thread_id_ = ThreadId::Invalid();
   external_caught_exception_ = false;
   failed_access_check_callback_ = NULL;
   save_context_ = NULL;
@@ -77,6 +73,24 @@ void ThreadLocalTop::Initialize() {
 }


+void ThreadLocalTop::Initialize() {
+  InitializeInternal();
+#ifdef USE_SIMULATOR
+#ifdef V8_TARGET_ARCH_ARM
+  simulator_ = Simulator::current(Isolate::Current());
+#elif V8_TARGET_ARCH_MIPS
+  simulator_ = Simulator::current(Isolate::Current());
+#endif
+#endif
+  thread_id_ = ThreadId::Current();
+}
+
+
+v8::TryCatch* ThreadLocalTop::TryCatchHandler() {
+  return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address());
+}
+
+
 Address Isolate::get_address_from_id(Isolate::AddressId id) {
   return isolate_addresses_[id];
 }


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to