2012-07-02 12:15:23 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/v8.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/api.h"
|
|
|
|
#include "src/bootstrapper.h"
|
|
|
|
#include "src/debug.h"
|
|
|
|
#include "src/execution.h"
|
|
|
|
#include "src/regexp-stack.h"
|
2014-06-20 08:40:11 +00:00
|
|
|
#include "src/v8threads.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
|
2009-01-23 17:22:23 +00:00
|
|
|
|
2014-10-08 08:17:04 +00:00
|
|
|
namespace {
|
|
|
|
|
2009-01-23 17:22:23 +00:00
|
|
|
// Track whether this V8 instance has ever called v8::Locker. This allows the
|
|
|
|
// API code to verify that the lock is always held when V8 is being entered.
|
2014-10-08 08:17:04 +00:00
|
|
|
base::Atomic32 g_locker_was_ever_used_ = 0;
|
|
|
|
|
|
|
|
} // namespace
|
2009-01-23 17:22:23 +00:00
|
|
|
|
|
|
|
|
2013-01-18 07:20:17 +00:00
|
|
|
// Once the Locker is initialized, the current thread will be guaranteed to have
|
|
|
|
// the lock for a given isolate.
|
|
|
|
void Locker::Initialize(v8::Isolate* isolate) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(isolate != NULL);
|
2014-12-08 08:53:07 +00:00
|
|
|
has_lock_ = false;
|
2013-01-18 07:20:17 +00:00
|
|
|
top_level_ = true;
|
|
|
|
isolate_ = reinterpret_cast<i::Isolate*>(isolate);
|
2009-01-23 17:22:23 +00:00
|
|
|
// Record that the Locker has been used at least once.
|
2014-10-08 08:17:04 +00:00
|
|
|
base::NoBarrier_Store(&g_locker_was_ever_used_, 1);
|
2008-07-03 15:10:15 +00:00
|
|
|
// Get the big lock if necessary.
|
2011-05-05 18:55:31 +00:00
|
|
|
if (!isolate_->thread_manager()->IsLockedByCurrentThread()) {
|
|
|
|
isolate_->thread_manager()->Lock();
|
2008-07-03 15:10:15 +00:00
|
|
|
has_lock_ = true;
|
2011-03-18 20:35:07 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// This may be a locker within an unlocker in which case we have to
|
|
|
|
// get the saved state for this thread and restore it.
|
2011-05-05 18:55:31 +00:00
|
|
|
if (isolate_->thread_manager()->RestoreThread()) {
|
2008-07-03 15:10:15 +00:00
|
|
|
top_level_ = false;
|
2009-10-01 10:33:05 +00:00
|
|
|
} else {
|
2011-05-05 18:55:31 +00:00
|
|
|
internal::ExecutionAccess access(isolate_);
|
|
|
|
isolate_->stack_guard()->ClearThread(access);
|
|
|
|
isolate_->stack_guard()->InitThread(access);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(isolate_->thread_manager()->IsLockedByCurrentThread());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-05 18:55:31 +00:00
|
|
|
bool Locker::IsLocked(v8::Isolate* isolate) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(isolate != NULL);
|
2011-05-05 18:55:31 +00:00
|
|
|
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
|
|
|
return internal_isolate->thread_manager()->IsLockedByCurrentThread();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-08 09:34:18 +00:00
|
|
|
bool Locker::IsActive() {
|
2014-10-08 08:17:04 +00:00
|
|
|
return !!base::NoBarrier_Load(&g_locker_was_ever_used_);
|
2011-08-08 09:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
Locker::~Locker() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(isolate_->thread_manager()->IsLockedByCurrentThread());
|
2008-07-03 15:10:15 +00:00
|
|
|
if (has_lock_) {
|
2009-09-28 12:25:21 +00:00
|
|
|
if (top_level_) {
|
2011-05-05 18:55:31 +00:00
|
|
|
isolate_->thread_manager()->FreeThreadResources();
|
2009-09-28 12:25:21 +00:00
|
|
|
} else {
|
2011-05-05 18:55:31 +00:00
|
|
|
isolate_->thread_manager()->ArchiveThread();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-05-05 18:55:31 +00:00
|
|
|
isolate_->thread_manager()->Unlock();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-18 07:20:17 +00:00
|
|
|
void Unlocker::Initialize(v8::Isolate* isolate) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(isolate != NULL);
|
2013-01-18 07:20:17 +00:00
|
|
|
isolate_ = reinterpret_cast<i::Isolate*>(isolate);
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(isolate_->thread_manager()->IsLockedByCurrentThread());
|
2011-05-05 18:55:31 +00:00
|
|
|
isolate_->thread_manager()->ArchiveThread();
|
|
|
|
isolate_->thread_manager()->Unlock();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Unlocker::~Unlocker() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(!isolate_->thread_manager()->IsLockedByCurrentThread());
|
2011-05-05 18:55:31 +00:00
|
|
|
isolate_->thread_manager()->Lock();
|
|
|
|
isolate_->thread_manager()->RestoreThread();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
|
|
bool ThreadManager::RestoreThread() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(IsLockedByCurrentThread());
|
2012-01-16 12:38:59 +00:00
|
|
|
// First check whether the current thread has been 'lazily archived', i.e.
|
2008-07-03 15:10:15 +00:00
|
|
|
// not archived at all. If that is the case we put the state storage we
|
|
|
|
// had prepared back in the free list, since we didn't need it after all.
|
2011-04-11 23:46:22 +00:00
|
|
|
if (lazily_archived_thread_.Equals(ThreadId::Current())) {
|
|
|
|
lazily_archived_thread_ = ThreadId::Invalid();
|
2011-05-05 18:55:31 +00:00
|
|
|
Isolate::PerIsolateThreadData* per_thread =
|
|
|
|
isolate_->FindPerThreadDataForThisThread();
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(per_thread != NULL);
|
|
|
|
DCHECK(per_thread->thread_state() == lazily_archived_thread_state_);
|
2011-04-11 23:46:22 +00:00
|
|
|
lazily_archived_thread_state_->set_id(ThreadId::Invalid());
|
2008-07-03 15:10:15 +00:00
|
|
|
lazily_archived_thread_state_->LinkInto(ThreadState::FREE_LIST);
|
|
|
|
lazily_archived_thread_state_ = NULL;
|
2011-05-05 18:55:31 +00:00
|
|
|
per_thread->set_thread_state(NULL);
|
2008-07-03 15:10:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-01-26 18:23:01 +00:00
|
|
|
|
2009-01-26 18:09:46 +00:00
|
|
|
// Make sure that the preemption thread cannot modify the thread state while
|
|
|
|
// it is being archived or restored.
|
2011-03-18 20:35:07 +00:00
|
|
|
ExecutionAccess access(isolate_);
|
2009-01-26 18:23:01 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// If there is another thread that was lazily archived then we have to really
|
|
|
|
// archive it now.
|
|
|
|
if (lazily_archived_thread_.IsValid()) {
|
|
|
|
EagerlyArchiveThread();
|
|
|
|
}
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate::PerIsolateThreadData* per_thread =
|
2011-05-05 18:55:31 +00:00
|
|
|
isolate_->FindPerThreadDataForThisThread();
|
2011-03-18 20:35:07 +00:00
|
|
|
if (per_thread == NULL || per_thread->thread_state() == NULL) {
|
2009-10-01 10:33:05 +00:00
|
|
|
// This is a new thread.
|
2011-03-18 20:35:07 +00:00
|
|
|
isolate_->stack_guard()->InitThread(access);
|
2008-07-03 15:10:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-03-18 20:35:07 +00:00
|
|
|
ThreadState* state = per_thread->thread_state();
|
2008-07-03 15:10:15 +00:00
|
|
|
char* from = state->data();
|
2011-03-18 20:35:07 +00:00
|
|
|
from = isolate_->handle_scope_implementer()->RestoreThread(from);
|
|
|
|
from = isolate_->RestoreThread(from);
|
2011-05-05 18:55:31 +00:00
|
|
|
from = Relocatable::RestoreState(isolate_, from);
|
2011-03-18 20:35:07 +00:00
|
|
|
from = isolate_->debug()->RestoreDebug(from);
|
|
|
|
from = isolate_->stack_guard()->RestoreStackGuard(from);
|
|
|
|
from = isolate_->regexp_stack()->RestoreStack(from);
|
|
|
|
from = isolate_->bootstrapper()->RestoreState(from);
|
|
|
|
per_thread->set_thread_state(NULL);
|
2009-08-19 15:14:11 +00:00
|
|
|
if (state->terminate_on_restore()) {
|
2014-05-09 09:13:12 +00:00
|
|
|
isolate_->stack_guard()->RequestTerminateExecution();
|
2009-08-19 15:14:11 +00:00
|
|
|
state->set_terminate_on_restore(false);
|
|
|
|
}
|
2011-04-11 23:46:22 +00:00
|
|
|
state->set_id(ThreadId::Invalid());
|
2008-07-03 15:10:15 +00:00
|
|
|
state->Unlink();
|
|
|
|
state->LinkInto(ThreadState::FREE_LIST);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadManager::Lock() {
|
2013-08-29 09:58:30 +00:00
|
|
|
mutex_.Lock();
|
2011-04-11 23:46:22 +00:00
|
|
|
mutex_owner_ = ThreadId::Current();
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(IsLockedByCurrentThread());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadManager::Unlock() {
|
2011-04-11 23:46:22 +00:00
|
|
|
mutex_owner_ = ThreadId::Invalid();
|
2013-08-29 09:58:30 +00:00
|
|
|
mutex_.Unlock();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-04 11:09:55 +00:00
|
|
|
static int ArchiveSpacePerThread() {
|
2008-07-03 15:10:15 +00:00
|
|
|
return HandleScopeImplementer::ArchiveSpacePerThread() +
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate::ArchiveSpacePerThread() +
|
2008-07-03 15:10:15 +00:00
|
|
|
Debug::ArchiveSpacePerThread() +
|
2009-01-12 13:05:23 +00:00
|
|
|
StackGuard::ArchiveSpacePerThread() +
|
2009-01-26 18:09:46 +00:00
|
|
|
RegExpStack::ArchiveSpacePerThread() +
|
2009-09-30 12:25:46 +00:00
|
|
|
Bootstrapper::ArchiveSpacePerThread() +
|
2013-09-04 11:09:55 +00:00
|
|
|
Relocatable::ArchiveSpacePerThread();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
ThreadState::ThreadState(ThreadManager* thread_manager)
|
2011-04-11 23:46:22 +00:00
|
|
|
: id_(ThreadId::Invalid()),
|
2011-03-18 20:35:07 +00:00
|
|
|
terminate_on_restore_(false),
|
2012-07-02 12:15:23 +00:00
|
|
|
data_(NULL),
|
2011-03-18 20:35:07 +00:00
|
|
|
next_(this),
|
|
|
|
previous_(this),
|
|
|
|
thread_manager_(thread_manager) {
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-02 12:15:23 +00:00
|
|
|
ThreadState::~ThreadState() {
|
|
|
|
DeleteArray<char>(data_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
void ThreadState::AllocateSpace() {
|
2013-09-04 11:09:55 +00:00
|
|
|
data_ = NewArray<char>(ArchiveSpacePerThread());
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadState::Unlink() {
|
|
|
|
next_->previous_ = previous_;
|
|
|
|
previous_->next_ = next_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadState::LinkInto(List list) {
|
|
|
|
ThreadState* flying_anchor =
|
2011-03-18 20:35:07 +00:00
|
|
|
list == FREE_LIST ? thread_manager_->free_anchor_
|
|
|
|
: thread_manager_->in_use_anchor_;
|
2008-07-03 15:10:15 +00:00
|
|
|
next_ = flying_anchor->next_;
|
|
|
|
previous_ = flying_anchor;
|
|
|
|
flying_anchor->next_ = this;
|
|
|
|
next_->previous_ = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
ThreadState* ThreadManager::GetFreeThreadState() {
|
2008-07-03 15:10:15 +00:00
|
|
|
ThreadState* gotten = free_anchor_->next_;
|
|
|
|
if (gotten == free_anchor_) {
|
2011-03-18 20:35:07 +00:00
|
|
|
ThreadState* new_thread_state = new ThreadState(this);
|
2008-07-03 15:10:15 +00:00
|
|
|
new_thread_state->AllocateSpace();
|
|
|
|
return new_thread_state;
|
|
|
|
}
|
|
|
|
return gotten;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Gets the first in the list of archived threads.
|
2011-03-18 20:35:07 +00:00
|
|
|
ThreadState* ThreadManager::FirstThreadStateInUse() {
|
2008-07-03 15:10:15 +00:00
|
|
|
return in_use_anchor_->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThreadState* ThreadState::Next() {
|
2011-03-18 20:35:07 +00:00
|
|
|
if (next_ == thread_manager_->in_use_anchor_) return NULL;
|
2008-07-03 15:10:15 +00:00
|
|
|
return next_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-04 11:16:51 +00:00
|
|
|
// Thread ids must start with 1, because in TLS having thread id 0 can't
|
|
|
|
// be distinguished from not having a thread id at all (since NULL is
|
|
|
|
// defined as 0.)
|
2011-03-18 20:35:07 +00:00
|
|
|
ThreadManager::ThreadManager()
|
2013-08-29 09:58:30 +00:00
|
|
|
: mutex_owner_(ThreadId::Invalid()),
|
2011-04-11 23:46:22 +00:00
|
|
|
lazily_archived_thread_(ThreadId::Invalid()),
|
2011-03-18 20:35:07 +00:00
|
|
|
lazily_archived_thread_state_(NULL),
|
|
|
|
free_anchor_(NULL),
|
|
|
|
in_use_anchor_(NULL) {
|
|
|
|
free_anchor_ = new ThreadState(this);
|
|
|
|
in_use_anchor_ = new ThreadState(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThreadManager::~ThreadManager() {
|
2012-07-02 12:15:23 +00:00
|
|
|
DeleteThreadStateList(free_anchor_);
|
|
|
|
DeleteThreadStateList(in_use_anchor_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadManager::DeleteThreadStateList(ThreadState* anchor) {
|
|
|
|
// The list starts and ends with the anchor.
|
|
|
|
for (ThreadState* current = anchor->next_; current != anchor;) {
|
|
|
|
ThreadState* next = current->next_;
|
|
|
|
delete current;
|
|
|
|
current = next;
|
|
|
|
}
|
|
|
|
delete anchor;
|
2011-03-18 20:35:07 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ThreadManager::ArchiveThread() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(lazily_archived_thread_.Equals(ThreadId::Invalid()));
|
|
|
|
DCHECK(!IsArchived());
|
|
|
|
DCHECK(IsLockedByCurrentThread());
|
2011-03-18 20:35:07 +00:00
|
|
|
ThreadState* state = GetFreeThreadState();
|
2008-07-03 15:10:15 +00:00
|
|
|
state->Unlink();
|
2011-05-05 18:55:31 +00:00
|
|
|
Isolate::PerIsolateThreadData* per_thread =
|
|
|
|
isolate_->FindOrAllocatePerThreadDataForThisThread();
|
|
|
|
per_thread->set_thread_state(state);
|
2011-04-11 23:46:22 +00:00
|
|
|
lazily_archived_thread_ = ThreadId::Current();
|
2008-07-03 15:10:15 +00:00
|
|
|
lazily_archived_thread_state_ = state;
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(state->id().Equals(ThreadId::Invalid()));
|
2009-03-17 11:40:47 +00:00
|
|
|
state->set_id(CurrentId());
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(!state->id().Equals(ThreadId::Invalid()));
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadManager::EagerlyArchiveThread() {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(IsLockedByCurrentThread());
|
2008-07-03 15:10:15 +00:00
|
|
|
ThreadState* state = lazily_archived_thread_state_;
|
|
|
|
state->LinkInto(ThreadState::IN_USE_LIST);
|
|
|
|
char* to = state->data();
|
2009-05-20 08:05:12 +00:00
|
|
|
// Ensure that data containing GC roots are archived first, and handle them
|
|
|
|
// in ThreadManager::Iterate(ObjectVisitor*).
|
2011-03-18 20:35:07 +00:00
|
|
|
to = isolate_->handle_scope_implementer()->ArchiveThread(to);
|
|
|
|
to = isolate_->ArchiveThread(to);
|
2011-05-05 18:55:31 +00:00
|
|
|
to = Relocatable::ArchiveState(isolate_, to);
|
2011-03-18 20:35:07 +00:00
|
|
|
to = isolate_->debug()->ArchiveDebug(to);
|
|
|
|
to = isolate_->stack_guard()->ArchiveStackGuard(to);
|
|
|
|
to = isolate_->regexp_stack()->ArchiveStack(to);
|
|
|
|
to = isolate_->bootstrapper()->ArchiveState(to);
|
2011-04-11 23:46:22 +00:00
|
|
|
lazily_archived_thread_ = ThreadId::Invalid();
|
2008-07-03 15:10:15 +00:00
|
|
|
lazily_archived_thread_state_ = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-28 12:25:21 +00:00
|
|
|
void ThreadManager::FreeThreadResources() {
|
2014-08-13 11:14:35 +00:00
|
|
|
DCHECK(!isolate_->has_pending_exception());
|
|
|
|
DCHECK(!isolate_->external_caught_exception());
|
|
|
|
DCHECK(isolate_->try_catch_handler() == NULL);
|
2011-03-18 20:35:07 +00:00
|
|
|
isolate_->handle_scope_implementer()->FreeThreadResources();
|
|
|
|
isolate_->FreeThreadResources();
|
|
|
|
isolate_->debug()->FreeThreadResources();
|
|
|
|
isolate_->stack_guard()->FreeThreadResources();
|
|
|
|
isolate_->regexp_stack()->FreeThreadResources();
|
|
|
|
isolate_->bootstrapper()->FreeThreadResources();
|
2009-09-28 12:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-04 11:16:51 +00:00
|
|
|
bool ThreadManager::IsArchived() {
|
2011-05-05 18:55:31 +00:00
|
|
|
Isolate::PerIsolateThreadData* data =
|
|
|
|
isolate_->FindPerThreadDataForThisThread();
|
2011-03-18 20:35:07 +00:00
|
|
|
return data != NULL && data->thread_state() != NULL;
|
2009-09-04 11:16:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
void ThreadManager::Iterate(ObjectVisitor* v) {
|
|
|
|
// Expecting no threads during serialization/deserialization
|
2011-03-18 20:35:07 +00:00
|
|
|
for (ThreadState* state = FirstThreadStateInUse();
|
2008-07-03 15:10:15 +00:00
|
|
|
state != NULL;
|
|
|
|
state = state->Next()) {
|
|
|
|
char* data = state->data();
|
|
|
|
data = HandleScopeImplementer::Iterate(v, data);
|
2011-03-18 20:35:07 +00:00
|
|
|
data = isolate_->Iterate(v, data);
|
2013-09-04 11:09:55 +00:00
|
|
|
data = Relocatable::Iterate(v, data);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-04 11:57:01 +00:00
|
|
|
void ThreadManager::IterateArchivedThreads(ThreadVisitor* v) {
|
2011-03-18 20:35:07 +00:00
|
|
|
for (ThreadState* state = FirstThreadStateInUse();
|
2010-03-20 22:37:15 +00:00
|
|
|
state != NULL;
|
|
|
|
state = state->Next()) {
|
|
|
|
char* data = state->data();
|
|
|
|
data += HandleScopeImplementer::ArchiveSpacePerThread();
|
2011-03-18 20:35:07 +00:00
|
|
|
isolate_->IterateThread(v, data);
|
2010-03-20 22:37:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-11 23:46:22 +00:00
|
|
|
ThreadId ThreadManager::CurrentId() {
|
|
|
|
return ThreadId::Current();
|
2009-09-04 11:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-11 23:46:22 +00:00
|
|
|
void ThreadManager::TerminateExecution(ThreadId thread_id) {
|
2011-03-18 20:35:07 +00:00
|
|
|
for (ThreadState* state = FirstThreadStateInUse();
|
2009-08-19 15:14:11 +00:00
|
|
|
state != NULL;
|
|
|
|
state = state->Next()) {
|
2011-04-11 23:46:22 +00:00
|
|
|
if (thread_id.Equals(state->id())) {
|
2009-08-19 15:14:11 +00:00
|
|
|
state->set_terminate_on_restore(true);
|
|
|
|
}
|
2009-03-17 11:40:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|