From 47248cc5fe2b5d7da707faace084ceade40842c1 Mon Sep 17 00:00:00 2001 From: "mikhail.naganov@gmail.com" Date: Fri, 10 Jun 2011 09:42:08 +0000 Subject: [PATCH] Revert accidental r8254..r8256 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8257 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 2 +- samples/shell.cc | 2 +- src/api.cc | 7 ++-- src/cpu-profiler.cc | 7 ++-- src/cpu-profiler.h | 3 +- src/debug-agent.cc | 2 +- src/debug-agent.h | 8 ++--- src/debug.cc | 4 +-- src/isolate.cc | 6 ++-- src/log.cc | 8 ++--- src/platform-linux.cc | 9 +++-- src/platform.h | 8 +++-- src/v8threads.cc | 5 ++- src/v8threads.h | 7 ++-- test/cctest/cctest.h | 4 +-- test/cctest/test-api.cc | 28 ++++++++-------- test/cctest/test-circular-queue.cc | 12 ++++--- test/cctest/test-cpu-profiler.cc | 8 ++--- test/cctest/test-debug.cc | 60 ++++++++++++++++++++-------------- test/cctest/test-lockers.cc | 6 ++-- test/cctest/test-platform-tls.cc | 2 +- test/cctest/test-sockets.cc | 7 ++-- test/cctest/test-thread-termination.cc | 15 ++++----- test/cctest/test-threads.cc | 10 +++--- 24 files changed, 123 insertions(+), 107 deletions(-) diff --git a/include/v8.h b/include/v8.h index e3e51ec..443e064 100644 --- a/include/v8.h +++ b/include/v8.h @@ -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 diff --git a/samples/shell.cc b/samples/shell.cc index 950370a..e253fba 100644 --- a/samples/shell.cc +++ b/samples/shell.cc @@ -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(); diff --git a/src/api.cc b/src/api.cc index ec1cb6f..91e4618 100644 --- a/src/api.cc +++ b/src/api.cc @@ -4902,10 +4902,9 @@ void V8::TerminateExecution(Isolate* isolate) { } -bool V8::IsExecutionTerminating(Isolate* isolate) { - i::Isolate* i_isolate = isolate != NULL ? - reinterpret_cast(isolate) : i::Isolate::Current(); - return IsExecutionTerminatingCheck(i_isolate); +bool V8::IsExecutionTerminating() { + i::Isolate* isolate = i::Isolate::Current(); + return IsExecutionTerminatingCheck(isolate); } diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc index 2b62212..f54e3e8 100644 --- a/src/cpu-profiler.cc +++ b/src/cpu-profiler.cc @@ -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. diff --git a/src/cpu-profiler.h b/src/cpu-profiler.h index ad4bc2e..f9f6167 100644 --- a/src/cpu-profiler.h +++ b/src/cpu-profiler.h @@ -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. diff --git a/src/debug-agent.cc b/src/debug-agent.cc index 24984cd..498b88a 100644 --- a/src/debug-agent.cc +++ b/src/debug-agent.cc @@ -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(); } diff --git a/src/debug-agent.h b/src/debug-agent.h index 783cf97..a25002e 100644 --- a/src/debug-agent.h +++ b/src/debug-agent.h @@ -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 message); diff --git a/src/debug.cc b/src/debug.cc index d4c0d7e..85c4b5e 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -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) { } diff --git a/src/isolate.cc b/src/isolate.cc index 7b07117..1d8a825 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -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(); } diff --git a/src/log.cc b/src/log.cc index ce6f65c..298ef6e 100644 --- a/src/log.cc +++ b/src/log.cc @@ -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 { diff --git a/src/platform-linux.cc b/src/platform-linux.cc index 228d6f4..0723a58 100644 --- a/src/platform-linux.cc +++ b/src/platform-linux.cc @@ -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) {} diff --git a/src/platform.h b/src/platform.h index 31f727c..725008a 100644 --- a/src/platform.h +++ b/src/platform.h @@ -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_; diff --git a/src/v8threads.cc b/src/v8threads.cc index 978e2dd..c1e5913 100644 --- a/src/v8threads.cc +++ b/src/v8threads.cc @@ -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) { } diff --git a/src/v8threads.h b/src/v8threads.h index 1370454..d8a923e 100644 --- a/src/v8threads.h +++ b/src/v8threads.h @@ -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 diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h index b0b8eb7..e4052d6 100644 --- a/test/cctest/cctest.h +++ b/test/cctest/cctest.h @@ -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) { diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index bc0ce12..9c3a91e 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -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) { } diff --git a/test/cctest/test-circular-queue.cc b/test/cctest/test-circular-queue.cc index c4e5c4c..9dd4981 100644 --- a/test/cctest/test-circular-queue.cc +++ b/test/cctest/test-circular-queue.cc @@ -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(); diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 7d898ce..beb73c5 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -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, diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 570c9cc..d8c1876 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -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(); diff --git a/test/cctest/test-lockers.cc b/test/cctest/test-lockers.cc index 1f17051..1b46887 100644 --- a/test/cctest/test-lockers.cc +++ b/test/cctest/test-lockers.cc @@ -64,7 +64,7 @@ class KangarooThread : public v8::internal::Thread { public: KangarooThread(v8::Isolate* isolate, v8::Handle 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) { } diff --git a/test/cctest/test-platform-tls.cc b/test/cctest/test-platform-tls.cc index 7f33aa2..b2cb101 100644 --- a/test/cctest/test-platform-tls.cc +++ b/test/cctest/test-platform-tls.cc @@ -48,7 +48,7 @@ static void DoTest() { class TestThread : public Thread { public: - TestThread() : Thread("TestThread") {} + TestThread() : Thread(NULL, "TestThread") {} virtual void Run() { DoTest(); diff --git a/test/cctest/test-sockets.cc b/test/cctest/test-sockets.cc index 4af55db..5246d09 100644 --- a/test/cctest/test-sockets.cc +++ b/test/cctest/test-sockets.cc @@ -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(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(); diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc index 1aa57e3..1e8a627 100644 --- a/test/cctest/test-thread-termination.cc +++ b/test/cctest/test-thread-termination.cc @@ -161,16 +161,12 @@ TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) { class TerminatorThread : public v8::internal::Thread { public: explicit TerminatorThread(i::Isolate* isolate) - : Thread("TerminatorThread"), - isolate_(reinterpret_cast(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 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(); diff --git a/test/cctest/test-threads.cc b/test/cctest/test-threads.cc index 59d27ab..c6d5cb0 100644 --- a/test/cctest/test-threads.cc +++ b/test/cctest/test-threads.cc @@ -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* 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) { } -- 2.7.4