Revert accidental r8254..r8256
authormikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 10 Jun 2011 09:42:08 +0000 (09:42 +0000)
committermikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 10 Jun 2011 09:42:08 +0000 (09:42 +0000)
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8257 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

24 files changed:
include/v8.h
samples/shell.cc
src/api.cc
src/cpu-profiler.cc
src/cpu-profiler.h
src/debug-agent.cc
src/debug-agent.h
src/debug.cc
src/isolate.cc
src/log.cc
src/platform-linux.cc
src/platform.h
src/v8threads.cc
src/v8threads.h
test/cctest/cctest.h
test/cctest/test-api.cc
test/cctest/test-circular-queue.cc
test/cctest/test-cpu-profiler.cc
test/cctest/test-debug.cc
test/cctest/test-lockers.cc
test/cctest/test-platform-tls.cc
test/cctest/test-sockets.cc
test/cctest/test-thread-termination.cc
test/cctest/test-threads.cc

index e3e51ec..443e064 100644 (file)
@@ -3099,7 +3099,7 @@ class V8EXPORT V8 {
    * still JavaScript frames on the stack and the termination
    * exception is still active.
    */
-  static bool IsExecutionTerminating(Isolate* isolate = NULL);
+  static bool IsExecutionTerminating();
 
   /**
    * Releases any resources used by v8 and stops any utility threads
index 950370a..e253fba 100644 (file)
@@ -170,7 +170,7 @@ class SourceGroup {
   class IsolateThread : public v8::internal::Thread {
    public:
     explicit IsolateThread(SourceGroup* group)
-        : v8::internal::Thread(GetThreadOptions()), group_(group) {}
+        : v8::internal::Thread(NULL, GetThreadOptions()), group_(group) {}
 
     virtual void Run() {
       group_->ExecuteInThread();
index ec1cb6f..91e4618 100644 (file)
@@ -4902,10 +4902,9 @@ void V8::TerminateExecution(Isolate* isolate) {
 }
 
 
-bool V8::IsExecutionTerminating(Isolate* isolate) {
-  i::Isolate* i_isolate = isolate != NULL ?
-      reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current();
-  return IsExecutionTerminatingCheck(i_isolate);
+bool V8::IsExecutionTerminating() {
+  i::Isolate* isolate = i::Isolate::Current();
+  return IsExecutionTerminatingCheck(isolate);
 }
 
 
index 2b62212..f54e3e8 100644 (file)
@@ -46,8 +46,9 @@ static const int kTickSamplesBufferChunkSize = 64*KB;
 static const int kTickSamplesBufferChunksCount = 16;
 
 
-ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator)
-    : Thread("v8:ProfEvntProc"),
+ProfilerEventsProcessor::ProfilerEventsProcessor(Isolate* isolate,
+                                                 ProfileGenerator* generator)
+    : Thread(isolate, "v8:ProfEvntProc"),
       generator_(generator),
       running_(true),
       ticks_buffer_(sizeof(TickSampleEventRecord),
@@ -506,7 +507,7 @@ void CpuProfiler::StartProcessorIfNotStarted() {
     saved_logging_nesting_ = isolate->logger()->logging_nesting_;
     isolate->logger()->logging_nesting_ = 0;
     generator_ = new ProfileGenerator(profiles_);
-    processor_ = new ProfilerEventsProcessor(generator_);
+    processor_ = new ProfilerEventsProcessor(isolate, generator_);
     NoBarrier_Store(&is_profiling_, true);
     processor_->Start();
     // Enumerate stuff we already have in the heap.
index ad4bc2e..f9f6167 100644 (file)
@@ -134,7 +134,8 @@ class TickSampleEventRecord BASE_EMBEDDED {
 // methods called by event producers: VM and stack sampler threads.
 class ProfilerEventsProcessor : public Thread {
  public:
-  explicit ProfilerEventsProcessor(ProfileGenerator* generator);
+  ProfilerEventsProcessor(Isolate* isolate,
+                          ProfileGenerator* generator);
   virtual ~ProfilerEventsProcessor() {}
 
   // Thread control.
index 24984cd..498b88a 100644 (file)
@@ -116,7 +116,7 @@ void DebuggerAgent::CreateSession(Socket* client) {
   }
 
   // Create a new session and hook up the debug message handler.
-  session_ = new DebuggerAgentSession(this, client);
+  session_ = new DebuggerAgentSession(isolate(), this, client);
   v8::Debug::SetMessageHandler2(DebuggerAgentMessageHandler);
   session_->Start();
 }
index 783cf97..a25002e 100644 (file)
@@ -43,8 +43,8 @@ class DebuggerAgentSession;
 // handles connection from a remote debugger.
 class DebuggerAgent: public Thread {
  public:
-  DebuggerAgent(const char* name, int port)
-      : Thread(name),
+  DebuggerAgent(Isolate* isolate, const char* name, int port)
+      : Thread(isolate, name),
         name_(StrDup(name)), port_(port),
         server_(OS::CreateSocket()), terminate_(false),
         session_access_(OS::CreateMutex()), session_(NULL),
@@ -88,8 +88,8 @@ class DebuggerAgent: public Thread {
 // debugger and sends debugger events/responses to the remote debugger.
 class DebuggerAgentSession: public Thread {
  public:
-  DebuggerAgentSession(DebuggerAgent* agent, Socket* client)
-      : Thread("v8:DbgAgntSessn"),
+  DebuggerAgentSession(Isolate* isolate, DebuggerAgent* agent, Socket* client)
+      : Thread(isolate, "v8:DbgAgntSessn"),
         agent_(agent), client_(client) {}
 
   void DebuggerMessage(Vector<uint16_t> message);
index d4c0d7e..85c4b5e 100644 (file)
@@ -2820,7 +2820,7 @@ bool Debugger::StartAgent(const char* name, int port,
 
   if (Socket::Setup()) {
     if (agent_ == NULL) {
-      agent_ = new DebuggerAgent(name, port);
+      agent_ = new DebuggerAgent(isolate_, name, port);
       agent_->Start();
     }
     return true;
@@ -3122,7 +3122,7 @@ void LockingCommandMessageQueue::Clear() {
 
 
 MessageDispatchHelperThread::MessageDispatchHelperThread(Isolate* isolate)
-    : Thread("v8:MsgDispHelpr"),
+    : Thread(isolate, "v8:MsgDispHelpr"),
       sem_(OS::CreateSemaphore(0)), mutex_(OS::CreateMutex()),
       already_signalled_(false) {
 }
index 7b07117..1d8a825 100644 (file)
@@ -190,8 +190,8 @@ class PreallocatedMemoryThread: public Thread {
 
 
  private:
-  PreallocatedMemoryThread()
-      : Thread("v8:PreallocMem"),
+  explicit PreallocatedMemoryThread(Isolate* isolate)
+      : Thread(isolate, "v8:PreallocMem"),
         keep_running_(true),
         wait_for_ever_semaphore_(OS::CreateSemaphore(0)),
         data_ready_semaphore_(OS::CreateSemaphore(0)),
@@ -219,7 +219,7 @@ class PreallocatedMemoryThread: public Thread {
 
 void Isolate::PreallocatedMemoryThreadStart() {
   if (preallocated_memory_thread_ != NULL) return;
-  preallocated_memory_thread_ = new PreallocatedMemoryThread();
+  preallocated_memory_thread_ = new PreallocatedMemoryThread(this);
   preallocated_memory_thread_->Start();
 }
 
index ce6f65c..298ef6e 100644 (file)
@@ -83,7 +83,7 @@ class SlidingStateWindow {
 //
 class Profiler: public Thread {
  public:
-  Profiler();
+  explicit Profiler(Isolate* isolate);
   void Engage();
   void Disengage();
 
@@ -270,8 +270,8 @@ void SlidingStateWindow::AddState(StateTag state) {
 //
 // Profiler implementation.
 //
-Profiler::Profiler()
-    : Thread("v8:Profiler"),
+Profiler::Profiler(Isolate* isolate)
+    : Thread(isolate, "v8:Profiler"),
       head_(0),
       tail_(0),
       overflow_(false),
@@ -1858,7 +1858,7 @@ bool Logger::Setup() {
   }
 
   if (FLAG_prof) {
-    profiler_ = new Profiler();
+    profiler_ = new Profiler(isolate);
     if (!FLAG_prof_auto) {
       profiler_->pause();
     } else {
index 228d6f4..0723a58 100644 (file)
@@ -653,15 +653,17 @@ class Thread::PlatformData : public Malloced {
   pthread_t thread_;  // Thread handle for pthread.
 };
 
-Thread::Thread(const Options& options)
+Thread::Thread(Isolate* isolate, const Options& options)
     : data_(new PlatformData()),
+      isolate_(isolate),
       stack_size_(options.stack_size) {
   set_name(options.name);
 }
 
 
-Thread::Thread(const char* name)
+Thread::Thread(Isolate* isolate, const char* name)
     : data_(new PlatformData()),
+      isolate_(isolate),
       stack_size_(0) {
   set_name(name);
 }
@@ -682,6 +684,7 @@ static void* ThreadEntry(void* arg) {
         0, 0, 0);
   thread->data()->thread_ = pthread_self();
   ASSERT(thread->data()->thread_ != kNoThread);
+  Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
   thread->Run();
   return NULL;
 }
@@ -971,7 +974,7 @@ class SignalSender : public Thread {
   };
 
   explicit SignalSender(int interval)
-      : Thread("SignalSender"),
+      : Thread(NULL, "SignalSender"),
         vm_tgid_(getpid()),
         interval_(interval) {}
 
index 31f727c..725008a 100644 (file)
@@ -384,9 +384,9 @@ class Thread {
     int stack_size;
   };
 
-  // Create new thread.
-  explicit Thread(const Options& options);
-  explicit Thread(const char* name);
+  // Create new thread (with a value for storing in the TLS isolate field).
+  Thread(Isolate* isolate, const Options& options);
+  Thread(Isolate* isolate, const char* name);
   virtual ~Thread();
 
   // Start new thread by calling the Run() method in the new thread.
@@ -433,6 +433,7 @@ class Thread {
   // A hint to the scheduler to let another thread run.
   static void YieldCPU();
 
+  Isolate* isolate() const { return isolate_; }
 
   // The thread name length is limited to 16 based on Linux's implementation of
   // prctl().
@@ -446,6 +447,7 @@ class Thread {
 
   PlatformData* data_;
 
+  Isolate* isolate_;
   char name_[kMaxThreadNameLength];
   int stack_size_;
 
index 978e2dd..c1e5913 100644 (file)
@@ -401,10 +401,9 @@ void ThreadManager::TerminateExecution(ThreadId thread_id) {
 
 
 ContextSwitcher::ContextSwitcher(Isolate* isolate, int every_n_ms)
-  : Thread("v8:CtxtSwitcher"),
+  : Thread(isolate, "v8:CtxtSwitcher"),
     keep_going_(true),
-    sleep_ms_(every_n_ms),
-    isolate_(isolate) {
+    sleep_ms_(every_n_ms) {
 }
 
 
index 1370454..d8a923e 100644 (file)
@@ -150,17 +150,14 @@ class ContextSwitcher: public Thread {
   // Preempted thread needs to call back to the ContextSwitcher to acknowledge
   // the handling of a preemption request.
   static void PreemptionReceived();
-  
- private:
-  ContextSwitcher(Isolate* isolate, int every_n_ms);
 
-  Isolate* isolate() const { return isolate_; }
+ private:
+  explicit ContextSwitcher(Isolate* isolate, int every_n_ms);
 
   void Run();
 
   bool keep_going_;
   int sleep_ms_;
-  Isolate* isolate_;
 };
 
 } }  // namespace v8::internal
index b0b8eb7..e4052d6 100644 (file)
@@ -87,8 +87,8 @@ class CcTest {
 class ApiTestFuzzer: public v8::internal::Thread {
  public:
   void CallTest();
-  explicit ApiTestFuzzer(int num)
-      : Thread("ApiTestFuzzer"),
+  explicit ApiTestFuzzer(v8::internal::Isolate* isolate, int num)
+      : Thread(isolate, "ApiTestFuzzer"),
         test_number_(num),
         gate_(v8::internal::OS::CreateSemaphore(0)),
         active_(true) {
index bc0ce12..9c3a91e 100644 (file)
@@ -9342,7 +9342,8 @@ void ApiTestFuzzer::Setup(PartOfTest part) {
   int end = (count * (part + 1) / (LAST_PART + 1)) - 1;
   active_tests_ = tests_being_run_ = end - start + 1;
   for (int i = 0; i < tests_being_run_; i++) {
-    RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(i + start);
+    RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(
+        i::Isolate::Current(), i + start);
   }
   for (int i = 0; i < active_tests_; i++) {
     RegisterThreadedTest::nth(i)->fuzzer_->Start();
@@ -10458,7 +10459,7 @@ class RegExpInterruptTest {
     gc_during_regexp_ = 0;
     regexp_success_ = false;
     gc_success_ = false;
-    GCThread gc_thread(this);
+    GCThread gc_thread(i::Isolate::Current(), this);
     gc_thread.Start();
     v8::Locker::StartPreemption(1);
 
@@ -10478,8 +10479,8 @@ class RegExpInterruptTest {
 
   class GCThread : public i::Thread {
    public:
-    GCThread(RegExpInterruptTest* test)
-        : Thread("GCThread"), test_(test) {}
+    explicit GCThread(i::Isolate* isolate, RegExpInterruptTest* test)
+        : Thread(isolate, "GCThread"), test_(test) {}
     virtual void Run() {
       test_->CollectGarbage();
     }
@@ -10581,7 +10582,7 @@ class ApplyInterruptTest {
     gc_during_apply_ = 0;
     apply_success_ = false;
     gc_success_ = false;
-    GCThread gc_thread(this);
+    GCThread gc_thread(i::Isolate::Current(), this);
     gc_thread.Start();
     v8::Locker::StartPreemption(1);
 
@@ -10601,8 +10602,8 @@ class ApplyInterruptTest {
 
   class GCThread : public i::Thread {
    public:
-    explicit GCThread(ApplyInterruptTest* test)
-        : Thread("GCThread"), test_(test) {}
+    explicit GCThread(i::Isolate* isolate, ApplyInterruptTest* test)
+        : Thread(isolate, "GCThread"), test_(test) {}
     virtual void Run() {
       test_->CollectGarbage();
     }
@@ -10876,7 +10877,7 @@ class RegExpStringModificationTest {
         NONE,
         i::kNonStrictMode)->ToObjectChecked();
 
-    MorphThread morph_thread(this);
+    MorphThread morph_thread(i::Isolate::Current(), this);
     morph_thread.Start();
     v8::Locker::StartPreemption(1);
     LongRunningRegExp();
@@ -10896,8 +10897,9 @@ class RegExpStringModificationTest {
 
   class MorphThread : public i::Thread {
    public:
-    explicit MorphThread(RegExpStringModificationTest* test)
-        : Thread("MorphThread"), test_(test) {}
+    explicit MorphThread(i::Isolate* isolate,
+                         RegExpStringModificationTest* test)
+        : Thread(isolate, "MorphThread"), test_(test) {}
     virtual void Run() {
       test_->MorphString();
     }
@@ -13714,8 +13716,8 @@ static int CalcFibonacci(v8::Isolate* isolate, int limit) {
 
 class IsolateThread : public v8::internal::Thread {
  public:
-  IsolateThread(v8::Isolate* isolate, int fib_limit)
-      : Thread("IsolateThread"),
+  explicit IsolateThread(v8::Isolate* isolate, int fib_limit)
+      : Thread(NULL, "IsolateThread"),
         isolate_(isolate),
         fib_limit_(fib_limit),
         result_(0) { }
@@ -13795,7 +13797,7 @@ class InitDefaultIsolateThread : public v8::internal::Thread {
   };
 
   explicit InitDefaultIsolateThread(TestCase testCase)
-      : Thread("InitDefaultIsolateThread"),
+      : Thread(NULL, "InitDefaultIsolateThread"),
         testCase_(testCase),
         result_(false) { }
 
index c4e5c4c..9dd4981 100644 (file)
@@ -84,11 +84,12 @@ class ProducerThread: public i::Thread {
  public:
   typedef SamplingCircularQueue::Cell Record;
 
-  ProducerThread(SamplingCircularQueue* scq,
+  ProducerThread(i::Isolate* isolate,
+                 SamplingCircularQueue* scq,
                  int records_per_chunk,
                  Record value,
                  i::Semaphore* finished)
-      : Thread("producer"),
+      : Thread(isolate, "producer"),
         scq_(scq),
         records_per_chunk_(records_per_chunk),
         value_(value),
@@ -132,9 +133,10 @@ TEST(SamplingCircularQueueMultithreading) {
   // Check that we are using non-reserved values.
   CHECK_NE(SamplingCircularQueue::kClear, 1);
   CHECK_NE(SamplingCircularQueue::kEnd, 1);
-  ProducerThread producer1(&scq, kRecordsPerChunk, 1, semaphore);
-  ProducerThread producer2(&scq, kRecordsPerChunk, 10, semaphore);
-  ProducerThread producer3(&scq, kRecordsPerChunk, 20, semaphore);
+  i::Isolate* isolate = i::Isolate::Current();
+  ProducerThread producer1(isolate, &scq, kRecordsPerChunk, 1, semaphore);
+  ProducerThread producer2(isolate, &scq, kRecordsPerChunk, 10, semaphore);
+  ProducerThread producer3(isolate, &scq, kRecordsPerChunk, 20, semaphore);
 
   CHECK_EQ(NULL, scq.StartDequeue());
   producer1.Start();
index 7d898ce..beb73c5 100644 (file)
@@ -24,7 +24,7 @@ using i::TokenEnumerator;
 TEST(StartStop) {
   CpuProfilesCollection profiles;
   ProfileGenerator generator(&profiles);
-  ProfilerEventsProcessor processor(&generator);
+  ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
   processor.Start();
   processor.Stop();
   processor.Join();
@@ -85,7 +85,7 @@ TEST(CodeEvents) {
   CpuProfilesCollection profiles;
   profiles.StartProfiling("", 1);
   ProfileGenerator generator(&profiles);
-  ProfilerEventsProcessor processor(&generator);
+  ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
   processor.Start();
 
   // Enqueue code creation events.
@@ -146,7 +146,7 @@ TEST(TickEvents) {
   CpuProfilesCollection profiles;
   profiles.StartProfiling("", 1);
   ProfileGenerator generator(&profiles);
-  ProfilerEventsProcessor processor(&generator);
+  ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
   processor.Start();
 
   processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
@@ -236,7 +236,7 @@ TEST(Issue1398) {
   CpuProfilesCollection profiles;
   profiles.StartProfiling("", 1);
   ProfileGenerator generator(&profiles);
-  ProfilerEventsProcessor processor(&generator);
+  ProfilerEventsProcessor processor(i::Isolate::Current(), &generator);
   processor.Start();
 
   processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
index 570c9cc..d8c1876 100644 (file)
@@ -4728,8 +4728,8 @@ Barriers message_queue_barriers;
 // placing JSON debugger commands in the queue.
 class MessageQueueDebuggerThread : public v8::internal::Thread {
  public:
-  MessageQueueDebuggerThread()
-      : Thread("MessageQueueDebuggerThread") { }
+  explicit MessageQueueDebuggerThread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "MessageQueueDebuggerThread") { }
   void Run();
 };
 
@@ -4832,7 +4832,8 @@ void MessageQueueDebuggerThread::Run() {
 
 // This thread runs the v8 engine.
 TEST(MessageQueues) {
-  MessageQueueDebuggerThread message_queue_debugger_thread;
+  MessageQueueDebuggerThread message_queue_debugger_thread(
+      i::Isolate::Current());
 
   // Create a V8 environment
   v8::HandleScope scope;
@@ -4979,13 +4980,15 @@ Barriers threaded_debugging_barriers;
 
 class V8Thread : public v8::internal::Thread {
  public:
-  V8Thread() : Thread("V8Thread") { }
+  explicit V8Thread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "V8Thread") { }
   void Run();
 };
 
 class DebuggerThread : public v8::internal::Thread {
  public:
-  DebuggerThread() : Thread("DebuggerThread") { }
+  explicit DebuggerThread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "DebuggerThread") { }
   void Run();
 };
 
@@ -5062,8 +5065,8 @@ void DebuggerThread::Run() {
 
 
 TEST(ThreadedDebugging) {
-  DebuggerThread debugger_thread;
-  V8Thread v8_thread;
+  DebuggerThread debugger_thread(i::Isolate::Current());
+  V8Thread v8_thread(i::Isolate::Current());
 
   // Create a V8 environment
   threaded_debugging_barriers.Initialize();
@@ -5084,14 +5087,16 @@ TEST(ThreadedDebugging) {
 
 class BreakpointsV8Thread : public v8::internal::Thread {
  public:
-  BreakpointsV8Thread() : Thread("BreakpointsV8Thread") { }
+  explicit BreakpointsV8Thread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "BreakpointsV8Thread") { }
   void Run();
 };
 
 class BreakpointsDebuggerThread : public v8::internal::Thread {
  public:
-  explicit BreakpointsDebuggerThread(bool global_evaluate)
-      : Thread("BreakpointsDebuggerThread"),
+  explicit BreakpointsDebuggerThread(v8::internal::Isolate* isolate,
+                                     bool global_evaluate)
+      : Thread(isolate, "BreakpointsDebuggerThread"),
         global_evaluate_(global_evaluate) {}
   void Run();
 
@@ -5268,8 +5273,9 @@ void BreakpointsDebuggerThread::Run() {
 void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
   i::FLAG_debugger_auto_break = true;
 
-  BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate);
-  BreakpointsV8Thread breakpoints_v8_thread;
+  BreakpointsDebuggerThread breakpoints_debugger_thread(i::Isolate::Current(),
+      global_evaluate);
+  BreakpointsV8Thread breakpoints_v8_thread(i::Isolate::Current());
 
   // Create a V8 environment
   Barriers stack_allocated_breakpoints_barriers;
@@ -5651,13 +5657,15 @@ TEST(DebuggerClearMessageHandlerWhileActive) {
 
 class HostDispatchV8Thread : public v8::internal::Thread {
  public:
-  HostDispatchV8Thread() : Thread("HostDispatchV8Thread") { }
+  explicit HostDispatchV8Thread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "HostDispatchV8Thread") { }
   void Run();
 };
 
 class HostDispatchDebuggerThread : public v8::internal::Thread {
  public:
-  HostDispatchDebuggerThread() : Thread("HostDispatchDebuggerThread") { }
+  explicit HostDispatchDebuggerThread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "HostDispatchDebuggerThread") { }
   void Run();
 };
 
@@ -5729,8 +5737,9 @@ void HostDispatchDebuggerThread::Run() {
 
 
 TEST(DebuggerHostDispatch) {
-  HostDispatchDebuggerThread host_dispatch_debugger_thread;
-  HostDispatchV8Thread host_dispatch_v8_thread;
+  HostDispatchDebuggerThread host_dispatch_debugger_thread(
+      i::Isolate::Current());
+  HostDispatchV8Thread host_dispatch_v8_thread(i::Isolate::Current());
   i::FLAG_debugger_auto_break = true;
 
   // Create a V8 environment
@@ -5754,14 +5763,15 @@ TEST(DebuggerHostDispatch) {
 
 class DebugMessageDispatchV8Thread : public v8::internal::Thread {
  public:
-  DebugMessageDispatchV8Thread() : Thread("DebugMessageDispatchV8Thread") { }
+  explicit DebugMessageDispatchV8Thread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "DebugMessageDispatchV8Thread") { }
   void Run();
 };
 
 class DebugMessageDispatchDebuggerThread : public v8::internal::Thread {
  public:
-  DebugMessageDispatchDebuggerThread()
-      : Thread("DebugMessageDispatchDebuggerThread") { }
+  explicit DebugMessageDispatchDebuggerThread(v8::internal::Isolate* isolate)
+      : Thread(isolate, "DebugMessageDispatchDebuggerThread") { }
   void Run();
 };
 
@@ -5795,8 +5805,10 @@ void DebugMessageDispatchDebuggerThread::Run() {
 
 
 TEST(DebuggerDebugMessageDispatch) {
-  DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread;
-  DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread;
+  DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread(
+      i::Isolate::Current());
+  DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread(
+      i::Isolate::Current());
 
   i::FLAG_debugger_auto_break = true;
 
@@ -5861,8 +5873,8 @@ TEST(DebuggerAgent) {
 
 class DebuggerAgentProtocolServerThread : public i::Thread {
  public:
-  explicit DebuggerAgentProtocolServerThread(int port)
-      : Thread("DebuggerAgentProtocolServerThread"),
+  explicit DebuggerAgentProtocolServerThread(i::Isolate* isolate, int port)
+      : Thread(isolate, "DebuggerAgentProtocolServerThread"),
         port_(port),
         server_(NULL),
         client_(NULL),
@@ -5927,7 +5939,7 @@ TEST(DebuggerAgentProtocolOverflowHeader) {
 
   // Create a socket server to receive a debugger agent message.
   DebuggerAgentProtocolServerThread* server =
-      new DebuggerAgentProtocolServerThread(kPort);
+      new DebuggerAgentProtocolServerThread(i::Isolate::Current(), kPort);
   server->Start();
   server->WaitForListening();
 
index 1f17051..1b46887 100644 (file)
@@ -64,7 +64,7 @@ class KangarooThread : public v8::internal::Thread {
  public:
   KangarooThread(v8::Isolate* isolate,
                  v8::Handle<v8::Context> context, int value)
-      : Thread("KangarooThread"),
+      : Thread(NULL, "KangarooThread"),
         isolate_(isolate), context_(context), value_(value) {
   }
 
@@ -149,8 +149,8 @@ class JoinableThread {
  private:
   class ThreadWithSemaphore : public i::Thread {
    public:
-    ThreadWithSemaphore(JoinableThread* joinable_thread)
-      : Thread(joinable_thread->name_),
+    explicit ThreadWithSemaphore(JoinableThread* joinable_thread)
+      : Thread(NULL, joinable_thread->name_),
         joinable_thread_(joinable_thread) {
     }
 
index 7f33aa2..b2cb101 100644 (file)
@@ -48,7 +48,7 @@ static void DoTest() {
 
 class TestThread : public Thread {
  public:
-  TestThread() : Thread("TestThread") {}
+  TestThread() : Thread(NULL, "TestThread") {}
 
   virtual void Run() {
     DoTest();
index 4af55db..5246d09 100644 (file)
@@ -10,8 +10,8 @@ using namespace ::v8::internal;
 
 class SocketListenerThread : public Thread {
  public:
-  SocketListenerThread(int port, int data_size)
-      : Thread("SocketListenerThread"),
+  explicit SocketListenerThread(Isolate* isolate, int port, int data_size)
+      : Thread(isolate, "SocketListenerThread"),
         port_(port),
         data_size_(data_size),
         server_(NULL),
@@ -92,7 +92,8 @@ static void SendAndReceive(int port, char *data, int len) {
   OS::SNPrintF(Vector<char>(port_str, kPortBuferLen), "%d", port);
 
   // Create a socket listener.
-  SocketListenerThread* listener = new SocketListenerThread(port, len);
+  SocketListenerThread* listener = new SocketListenerThread(Isolate::Current(),
+      port, len);
   listener->Start();
   listener->WaitForListening();
 
index 1aa57e3..1e8a627 100644 (file)
@@ -161,16 +161,12 @@ TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) {
 class TerminatorThread : public v8::internal::Thread {
  public:
   explicit TerminatorThread(i::Isolate* isolate)
-      : Thread("TerminatorThread"),
-        isolate_(reinterpret_cast<v8::Isolate*>(isolate)) { }
+      : Thread(isolate, "TerminatorThread") { }
   void Run() {
     semaphore->Wait();
-    CHECK(!v8::V8::IsExecutionTerminating(isolate_));
-    v8::V8::TerminateExecution(isolate_);
+    CHECK(!v8::V8::IsExecutionTerminating());
+    v8::V8::TerminateExecution();
   }
-
- private:
-  v8::Isolate* isolate_;
 };
 
 
@@ -200,7 +196,8 @@ TEST(TerminateOnlyV8ThreadFromOtherThread) {
 
 class LoopingThread : public v8::internal::Thread {
  public:
-  LoopingThread() : Thread("LoopingThread") { }
+  explicit LoopingThread(i::Isolate* isolate)
+      : Thread(isolate, "LoopingThread") { }
   void Run() {
     v8::Locker locker;
     v8::HandleScope scope;
@@ -236,7 +233,7 @@ TEST(TerminateMultipleV8ThreadsDefaultIsolate) {
   const int kThreads = 2;
   i::List<LoopingThread*> threads(kThreads);
   for (int i = 0; i < kThreads; i++) {
-    threads.Add(new LoopingThread());
+    threads.Add(new LoopingThread(i::Isolate::Current()));
   }
   for (int i = 0; i < kThreads; i++) {
     threads[i]->Start();
index 59d27ab..c6d5cb0 100644 (file)
@@ -65,7 +65,7 @@ static Turn turn = FILL_CACHE;
 
 class ThreadA: public v8::internal::Thread {
  public:
-  ThreadA() : Thread("ThreadA") { }
+  explicit ThreadA(i::Isolate* isolate) : Thread(isolate, "ThreadA") { }
   void Run() {
     v8::Locker locker;
     v8::HandleScope scope;
@@ -101,7 +101,7 @@ class ThreadA: public v8::internal::Thread {
 
 class ThreadB: public v8::internal::Thread {
  public:
-  ThreadB() : Thread("ThreadB") { }
+  explicit ThreadB(i::Isolate* isolate) : Thread(isolate, "ThreadB") { }
   void Run() {
     do {
       {
@@ -126,8 +126,8 @@ class ThreadB: public v8::internal::Thread {
 TEST(JSFunctionResultCachesInTwoThreads) {
   v8::V8::Initialize();
 
-  ThreadA threadA;
-  ThreadB threadB;
+  ThreadA threadA(i::Isolate::Current());
+  ThreadB threadB(i::Isolate::Current());
 
   threadA.Start();
   threadB.Start();
@@ -144,7 +144,7 @@ class ThreadIdValidationThread : public v8::internal::Thread {
                            i::List<i::ThreadId>* refs,
                            unsigned int thread_no,
                            i::Semaphore* semaphore)
-    : Thread("ThreadRefValidationThread"),
+    : Thread(NULL, "ThreadRefValidationThread"),
       refs_(refs), thread_no_(thread_no), thread_to_start_(thread_to_start),
       semaphore_(semaphore) {
   }