Revision: 5200
Author: [email protected]
Date: Fri Aug  6 13:27:40 2010
Log: [Isolates] A fix for 2 crashing tests in arm simulator (post-API patch).
Need to keep a per-isolate/per-thread instance of Simulator,
rather then have one Simulator per thread as was before.
Also, need to enter default isolate in Simulator::current() since
APIs like SetResourceConstraints require a Simulator before V8::Initialize.

Review URL: http://codereview.chromium.org/3076032
http://code.google.com/p/v8/source/detail?r=5200

Modified:
 /branches/experimental/isolates/src/arm/simulator-arm.cc
 /branches/experimental/isolates/src/isolate.cc
 /branches/experimental/isolates/src/isolate.h

=======================================
--- /branches/experimental/isolates/src/arm/simulator-arm.cc Thu Jul 15 20:09:25 2010 +++ /branches/experimental/isolates/src/arm/simulator-arm.cc Fri Aug 6 13:27:40 2010
@@ -695,15 +695,19 @@

 // Get the active Simulator for the current thread.
 Simulator* Simulator::current(Isolate* isolate) {
-  v8::internal::Thread::LocalStorageKey* simulator_key =
-      Isolate::Current()->simulator_key();
-  Initialize();
-  Simulator* sim = reinterpret_cast<Simulator*>(
-      v8::internal::Thread::GetThreadLocal(*simulator_key));
+  v8::internal::Isolate::PerIsolateThreadData* isolate_data =
+      Isolate::CurrentPerIsolateThreadData();
+  if (isolate_data == NULL) {
+    Isolate::EnterDefaultIsolate();
+    isolate_data = Isolate::CurrentPerIsolateThreadData();
+  }
+  ASSERT(isolate_data != NULL);
+
+  Simulator* sim = isolate_data->simulator();
   if (sim == NULL) {
-    // TODO(146): delete the simulator object when a thread goes away.
+ // TODO(146): delete the simulator object when a thread/isolate goes away.
     sim = new Simulator();
-    v8::internal::Thread::SetThreadLocal(*simulator_key, sim);
+    isolate_data->set_simulator(sim);
   }
   return sim;
 }
=======================================
--- /branches/experimental/isolates/src/isolate.cc      Mon Aug  2 17:41:48 2010
+++ /branches/experimental/isolates/src/isolate.cc      Fri Aug  6 13:27:40 2010
@@ -168,9 +168,6 @@
 Thread::LocalStorageKey Isolate::isolate_key_;
 Thread::LocalStorageKey Isolate::thread_id_key_;
 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_;
-#if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__)
-Thread::LocalStorageKey Isolate::simulator_key_;
-#endif
 Mutex* Isolate::process_wide_mutex_ = NULL;
 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL;
 Isolate::ThreadId Isolate::highest_thread_id_ = 0;
@@ -247,9 +244,6 @@
     isolate_key_ = Thread::CreateThreadLocalKey();
     thread_id_key_ = Thread::CreateThreadLocalKey();
     per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
-#if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__)
-    simulator_key_ = Thread::CreateThreadLocalKey();
-#endif
     thread_data_table_ = new Isolate::ThreadDataTable();
     default_isolate_ = new Isolate();
   }
=======================================
--- /branches/experimental/isolates/src/isolate.h       Thu Aug  5 13:38:56 2010
+++ /branches/experimental/isolates/src/isolate.h       Fri Aug  6 13:27:40 2010
@@ -48,6 +48,7 @@
 namespace assembler {
 namespace arm {
 class Redirection;
+class Simulator;
 }
 }
 #endif
@@ -310,6 +311,9 @@
           thread_id_(thread_id),
           stack_limit_(0),
           thread_state_(NULL),
+#if !defined(__arm__) && defined(V8_TARGET_ARCH_ARM)
+          simulator_(NULL),
+#endif
           next_(NULL),
           prev_(NULL) { }
     Isolate* isolate() const { return isolate_; }
@@ -318,6 +322,14 @@
     uintptr_t stack_limit() const { return stack_limit_; }
     ThreadState* thread_state() const { return thread_state_; }
     void set_thread_state(ThreadState* value) { thread_state_ = value; }
+
+#if !defined(__arm__) && defined(V8_TARGET_ARCH_ARM)
+    assembler::arm::Simulator* simulator() const { return simulator_; }
+    void set_simulator(assembler::arm::Simulator* simulator) {
+      simulator_ = simulator;
+    }
+#endif
+
     bool Matches(Isolate* isolate, ThreadId thread_id) const {
       return isolate_ == isolate && thread_id_ == thread_id;
     }
@@ -328,6 +340,10 @@
     uintptr_t stack_limit_;
     ThreadState* thread_state_;

+#if !defined(__arm__) && defined(V8_TARGET_ARCH_ARM)
+    assembler::arm::Simulator* simulator_;
+#endif
+
     PerIsolateThreadData* next_;
     PerIsolateThreadData* prev_;

@@ -791,10 +807,6 @@
 #endif

 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__)
-  static v8::internal::Thread::LocalStorageKey* simulator_key() {
-    return &simulator_key_;
-  }
-
   bool simulator_initialized() { return simulator_initialized_; }
   void set_simulator_initialized(bool initialized) {
     simulator_initialized_ = initialized;
@@ -984,8 +996,6 @@
   AtomicWord vm_state_;

 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__)
-  // Create one simulator per thread and keep it in thread local storage.
-  static v8::internal::Thread::LocalStorageKey simulator_key_;
   bool simulator_initialized_;
   HashMap* simulator_i_cache_;
   assembler::arm::Redirection* simulator_redirection_;

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

Reply via email to