remove isolate reference from threads
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8254 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
bc4156ca7c
commit
f05fd92994
@ -170,7 +170,7 @@ class SourceGroup {
|
|||||||
class IsolateThread : public v8::internal::Thread {
|
class IsolateThread : public v8::internal::Thread {
|
||||||
public:
|
public:
|
||||||
explicit IsolateThread(SourceGroup* group)
|
explicit IsolateThread(SourceGroup* group)
|
||||||
: v8::internal::Thread(NULL, GetThreadOptions()), group_(group) {}
|
: v8::internal::Thread(GetThreadOptions()), group_(group) {}
|
||||||
|
|
||||||
virtual void Run() {
|
virtual void Run() {
|
||||||
group_->ExecuteInThread();
|
group_->ExecuteInThread();
|
||||||
|
@ -46,9 +46,8 @@ static const int kTickSamplesBufferChunkSize = 64*KB;
|
|||||||
static const int kTickSamplesBufferChunksCount = 16;
|
static const int kTickSamplesBufferChunksCount = 16;
|
||||||
|
|
||||||
|
|
||||||
ProfilerEventsProcessor::ProfilerEventsProcessor(Isolate* isolate,
|
ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator)
|
||||||
ProfileGenerator* generator)
|
: Thread("v8:ProfEvntProc"),
|
||||||
: Thread(isolate, "v8:ProfEvntProc"),
|
|
||||||
generator_(generator),
|
generator_(generator),
|
||||||
running_(true),
|
running_(true),
|
||||||
ticks_buffer_(sizeof(TickSampleEventRecord),
|
ticks_buffer_(sizeof(TickSampleEventRecord),
|
||||||
@ -507,7 +506,7 @@ void CpuProfiler::StartProcessorIfNotStarted() {
|
|||||||
saved_logging_nesting_ = isolate->logger()->logging_nesting_;
|
saved_logging_nesting_ = isolate->logger()->logging_nesting_;
|
||||||
isolate->logger()->logging_nesting_ = 0;
|
isolate->logger()->logging_nesting_ = 0;
|
||||||
generator_ = new ProfileGenerator(profiles_);
|
generator_ = new ProfileGenerator(profiles_);
|
||||||
processor_ = new ProfilerEventsProcessor(isolate, generator_);
|
processor_ = new ProfilerEventsProcessor(generator_);
|
||||||
NoBarrier_Store(&is_profiling_, true);
|
NoBarrier_Store(&is_profiling_, true);
|
||||||
processor_->Start();
|
processor_->Start();
|
||||||
// Enumerate stuff we already have in the heap.
|
// Enumerate stuff we already have in the heap.
|
||||||
|
@ -134,8 +134,7 @@ class TickSampleEventRecord BASE_EMBEDDED {
|
|||||||
// methods called by event producers: VM and stack sampler threads.
|
// methods called by event producers: VM and stack sampler threads.
|
||||||
class ProfilerEventsProcessor : public Thread {
|
class ProfilerEventsProcessor : public Thread {
|
||||||
public:
|
public:
|
||||||
ProfilerEventsProcessor(Isolate* isolate,
|
explicit ProfilerEventsProcessor(ProfileGenerator* generator);
|
||||||
ProfileGenerator* generator);
|
|
||||||
virtual ~ProfilerEventsProcessor() {}
|
virtual ~ProfilerEventsProcessor() {}
|
||||||
|
|
||||||
// Thread control.
|
// Thread control.
|
||||||
|
@ -116,7 +116,7 @@ void DebuggerAgent::CreateSession(Socket* client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new session and hook up the debug message handler.
|
// Create a new session and hook up the debug message handler.
|
||||||
session_ = new DebuggerAgentSession(isolate(), this, client);
|
session_ = new DebuggerAgentSession(this, client);
|
||||||
v8::Debug::SetMessageHandler2(DebuggerAgentMessageHandler);
|
v8::Debug::SetMessageHandler2(DebuggerAgentMessageHandler);
|
||||||
session_->Start();
|
session_->Start();
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@ class DebuggerAgentSession;
|
|||||||
// handles connection from a remote debugger.
|
// handles connection from a remote debugger.
|
||||||
class DebuggerAgent: public Thread {
|
class DebuggerAgent: public Thread {
|
||||||
public:
|
public:
|
||||||
DebuggerAgent(Isolate* isolate, const char* name, int port)
|
DebuggerAgent(const char* name, int port)
|
||||||
: Thread(isolate, name),
|
: Thread(name),
|
||||||
name_(StrDup(name)), port_(port),
|
name_(StrDup(name)), port_(port),
|
||||||
server_(OS::CreateSocket()), terminate_(false),
|
server_(OS::CreateSocket()), terminate_(false),
|
||||||
session_access_(OS::CreateMutex()), session_(NULL),
|
session_access_(OS::CreateMutex()), session_(NULL),
|
||||||
@ -88,8 +88,8 @@ class DebuggerAgent: public Thread {
|
|||||||
// debugger and sends debugger events/responses to the remote debugger.
|
// debugger and sends debugger events/responses to the remote debugger.
|
||||||
class DebuggerAgentSession: public Thread {
|
class DebuggerAgentSession: public Thread {
|
||||||
public:
|
public:
|
||||||
DebuggerAgentSession(Isolate* isolate, DebuggerAgent* agent, Socket* client)
|
DebuggerAgentSession(DebuggerAgent* agent, Socket* client)
|
||||||
: Thread(isolate, "v8:DbgAgntSessn"),
|
: Thread("v8:DbgAgntSessn"),
|
||||||
agent_(agent), client_(client) {}
|
agent_(agent), client_(client) {}
|
||||||
|
|
||||||
void DebuggerMessage(Vector<uint16_t> message);
|
void DebuggerMessage(Vector<uint16_t> message);
|
||||||
|
@ -2820,7 +2820,7 @@ bool Debugger::StartAgent(const char* name, int port,
|
|||||||
|
|
||||||
if (Socket::Setup()) {
|
if (Socket::Setup()) {
|
||||||
if (agent_ == NULL) {
|
if (agent_ == NULL) {
|
||||||
agent_ = new DebuggerAgent(isolate_, name, port);
|
agent_ = new DebuggerAgent(name, port);
|
||||||
agent_->Start();
|
agent_->Start();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -3122,7 +3122,7 @@ void LockingCommandMessageQueue::Clear() {
|
|||||||
|
|
||||||
|
|
||||||
MessageDispatchHelperThread::MessageDispatchHelperThread(Isolate* isolate)
|
MessageDispatchHelperThread::MessageDispatchHelperThread(Isolate* isolate)
|
||||||
: Thread(isolate, "v8:MsgDispHelpr"),
|
: Thread("v8:MsgDispHelpr"),
|
||||||
sem_(OS::CreateSemaphore(0)), mutex_(OS::CreateMutex()),
|
sem_(OS::CreateSemaphore(0)), mutex_(OS::CreateMutex()),
|
||||||
already_signalled_(false) {
|
already_signalled_(false) {
|
||||||
}
|
}
|
||||||
|
@ -190,8 +190,8 @@ class PreallocatedMemoryThread: public Thread {
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit PreallocatedMemoryThread(Isolate* isolate)
|
PreallocatedMemoryThread()
|
||||||
: Thread(isolate, "v8:PreallocMem"),
|
: Thread("v8:PreallocMem"),
|
||||||
keep_running_(true),
|
keep_running_(true),
|
||||||
wait_for_ever_semaphore_(OS::CreateSemaphore(0)),
|
wait_for_ever_semaphore_(OS::CreateSemaphore(0)),
|
||||||
data_ready_semaphore_(OS::CreateSemaphore(0)),
|
data_ready_semaphore_(OS::CreateSemaphore(0)),
|
||||||
@ -219,7 +219,7 @@ class PreallocatedMemoryThread: public Thread {
|
|||||||
|
|
||||||
void Isolate::PreallocatedMemoryThreadStart() {
|
void Isolate::PreallocatedMemoryThreadStart() {
|
||||||
if (preallocated_memory_thread_ != NULL) return;
|
if (preallocated_memory_thread_ != NULL) return;
|
||||||
preallocated_memory_thread_ = new PreallocatedMemoryThread(this);
|
preallocated_memory_thread_ = new PreallocatedMemoryThread();
|
||||||
preallocated_memory_thread_->Start();
|
preallocated_memory_thread_->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class SlidingStateWindow {
|
|||||||
//
|
//
|
||||||
class Profiler: public Thread {
|
class Profiler: public Thread {
|
||||||
public:
|
public:
|
||||||
explicit Profiler(Isolate* isolate);
|
Profiler();
|
||||||
void Engage();
|
void Engage();
|
||||||
void Disengage();
|
void Disengage();
|
||||||
|
|
||||||
@ -270,8 +270,8 @@ void SlidingStateWindow::AddState(StateTag state) {
|
|||||||
//
|
//
|
||||||
// Profiler implementation.
|
// Profiler implementation.
|
||||||
//
|
//
|
||||||
Profiler::Profiler(Isolate* isolate)
|
Profiler::Profiler()
|
||||||
: Thread(isolate, "v8:Profiler"),
|
: Thread("v8:Profiler"),
|
||||||
head_(0),
|
head_(0),
|
||||||
tail_(0),
|
tail_(0),
|
||||||
overflow_(false),
|
overflow_(false),
|
||||||
@ -1858,7 +1858,7 @@ bool Logger::Setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FLAG_prof) {
|
if (FLAG_prof) {
|
||||||
profiler_ = new Profiler(isolate);
|
profiler_ = new Profiler();
|
||||||
if (!FLAG_prof_auto) {
|
if (!FLAG_prof_auto) {
|
||||||
profiler_->pause();
|
profiler_->pause();
|
||||||
} else {
|
} else {
|
||||||
|
@ -653,17 +653,15 @@ class Thread::PlatformData : public Malloced {
|
|||||||
pthread_t thread_; // Thread handle for pthread.
|
pthread_t thread_; // Thread handle for pthread.
|
||||||
};
|
};
|
||||||
|
|
||||||
Thread::Thread(Isolate* isolate, const Options& options)
|
Thread::Thread(const Options& options)
|
||||||
: data_(new PlatformData()),
|
: data_(new PlatformData()),
|
||||||
isolate_(isolate),
|
|
||||||
stack_size_(options.stack_size) {
|
stack_size_(options.stack_size) {
|
||||||
set_name(options.name);
|
set_name(options.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Thread::Thread(Isolate* isolate, const char* name)
|
Thread::Thread(const char* name)
|
||||||
: data_(new PlatformData()),
|
: data_(new PlatformData()),
|
||||||
isolate_(isolate),
|
|
||||||
stack_size_(0) {
|
stack_size_(0) {
|
||||||
set_name(name);
|
set_name(name);
|
||||||
}
|
}
|
||||||
@ -684,7 +682,6 @@ static void* ThreadEntry(void* arg) {
|
|||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
thread->data()->thread_ = pthread_self();
|
thread->data()->thread_ = pthread_self();
|
||||||
ASSERT(thread->data()->thread_ != kNoThread);
|
ASSERT(thread->data()->thread_ != kNoThread);
|
||||||
Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
|
|
||||||
thread->Run();
|
thread->Run();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -974,7 +971,7 @@ class SignalSender : public Thread {
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit SignalSender(int interval)
|
explicit SignalSender(int interval)
|
||||||
: Thread(NULL, "SignalSender"),
|
: Thread("SignalSender"),
|
||||||
vm_tgid_(getpid()),
|
vm_tgid_(getpid()),
|
||||||
interval_(interval) {}
|
interval_(interval) {}
|
||||||
|
|
||||||
|
@ -384,9 +384,9 @@ class Thread {
|
|||||||
int stack_size;
|
int stack_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create new thread (with a value for storing in the TLS isolate field).
|
// Create new thread.
|
||||||
Thread(Isolate* isolate, const Options& options);
|
explicit Thread(const Options& options);
|
||||||
Thread(Isolate* isolate, const char* name);
|
explicit Thread(const char* name);
|
||||||
virtual ~Thread();
|
virtual ~Thread();
|
||||||
|
|
||||||
// Start new thread by calling the Run() method in the new thread.
|
// Start new thread by calling the Run() method in the new thread.
|
||||||
@ -433,7 +433,6 @@ class Thread {
|
|||||||
// A hint to the scheduler to let another thread run.
|
// A hint to the scheduler to let another thread run.
|
||||||
static void YieldCPU();
|
static void YieldCPU();
|
||||||
|
|
||||||
Isolate* isolate() const { return isolate_; }
|
|
||||||
|
|
||||||
// The thread name length is limited to 16 based on Linux's implementation of
|
// The thread name length is limited to 16 based on Linux's implementation of
|
||||||
// prctl().
|
// prctl().
|
||||||
@ -447,7 +446,6 @@ class Thread {
|
|||||||
|
|
||||||
PlatformData* data_;
|
PlatformData* data_;
|
||||||
|
|
||||||
Isolate* isolate_;
|
|
||||||
char name_[kMaxThreadNameLength];
|
char name_[kMaxThreadNameLength];
|
||||||
int stack_size_;
|
int stack_size_;
|
||||||
|
|
||||||
|
@ -401,9 +401,10 @@ void ThreadManager::TerminateExecution(ThreadId thread_id) {
|
|||||||
|
|
||||||
|
|
||||||
ContextSwitcher::ContextSwitcher(Isolate* isolate, int every_n_ms)
|
ContextSwitcher::ContextSwitcher(Isolate* isolate, int every_n_ms)
|
||||||
: Thread(isolate, "v8:CtxtSwitcher"),
|
: Thread("v8:CtxtSwitcher"),
|
||||||
keep_going_(true),
|
keep_going_(true),
|
||||||
sleep_ms_(every_n_ms) {
|
sleep_ms_(every_n_ms),
|
||||||
|
isolate_(isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,12 +152,15 @@ class ContextSwitcher: public Thread {
|
|||||||
static void PreemptionReceived();
|
static void PreemptionReceived();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ContextSwitcher(Isolate* isolate, int every_n_ms);
|
ContextSwitcher(Isolate* isolate, int every_n_ms);
|
||||||
|
|
||||||
|
Isolate* isolate() const { return isolate_; }
|
||||||
|
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
bool keep_going_;
|
bool keep_going_;
|
||||||
int sleep_ms_;
|
int sleep_ms_;
|
||||||
|
Isolate* isolate_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} } // namespace v8::internal
|
} } // namespace v8::internal
|
||||||
|
Loading…
Reference in New Issue
Block a user