42 bool Locker::active_ =
false;
50 isolate_(reinterpret_cast<i::
Isolate*>(isolate)) {
51 if (isolate_ ==
NULL) {
52 isolate_ = i::Isolate::GetDefaultIsolateForLocking();
75 internal::ExecutionAccess access(isolate_);
90 if (internal_isolate ==
NULL) {
91 internal_isolate = i::Isolate::GetDefaultIsolateForLocking();
119 : isolate_(reinterpret_cast<i::
Isolate*>(isolate)) {
120 if (isolate_ ==
NULL) {
121 isolate_ = i::Isolate::GetDefaultIsolateForLocking();
168 lazily_archived_thread_state_ =
NULL;
175 ExecutionAccess access(isolate_);
179 if (lazily_archived_thread_.IsValid()) {
180 EagerlyArchiveThread();
190 char* from = state->
data();
193 from = Relocatable::RestoreState(isolate_, from);
194 #ifdef ENABLE_DEBUGGER_SUPPORT
195 from = isolate_->debug()->RestoreDebug(from);
225 static int ArchiveSpacePerThread() {
228 #ifdef ENABLE_DEBUGGER_SUPPORT
229 Debug::ArchiveSpacePerThread() +
234 Relocatable::ArchiveSpacePerThread();
238 ThreadState::ThreadState(ThreadManager* thread_manager)
239 : id_(ThreadId::Invalid()),
240 terminate_on_restore_(
false),
243 thread_manager_(thread_manager) {
247 void ThreadState::AllocateSpace() {
248 data_ = NewArray<char>(ArchiveSpacePerThread());
253 next_->previous_ = previous_;
254 previous_->next_ = next_;
260 list ==
FREE_LIST ? thread_manager_->free_anchor_
261 : thread_manager_->in_use_anchor_;
262 next_ = flying_anchor->next_;
263 previous_ = flying_anchor;
264 flying_anchor->next_ =
this;
265 next_->previous_ =
this;
271 if (gotten == free_anchor_) {
273 new_thread_state->AllocateSpace();
274 return new_thread_state;
282 return in_use_anchor_->
Next();
287 if (next_ == thread_manager_->in_use_anchor_)
return NULL;
295 ThreadManager::ThreadManager()
296 : mutex_(
OS::CreateMutex()),
298 lazily_archived_thread_(
ThreadId::Invalid()),
299 lazily_archived_thread_state_(
NULL),
301 in_use_anchor_(
NULL) {
307 ThreadManager::~ThreadManager() {
310 delete in_use_anchor_;
321 isolate_->FindOrAllocatePerThreadDataForThisThread();
324 lazily_archived_thread_state_ = state;
331 void ThreadManager::EagerlyArchiveThread() {
333 ThreadState* state = lazily_archived_thread_state_;
335 char* to = state->
data();
340 to = Relocatable::ArchiveState(isolate_, to);
341 #ifdef ENABLE_DEBUGGER_SUPPORT
342 to = isolate_->debug()->ArchiveDebug(to);
348 lazily_archived_thread_state_ =
NULL;
355 #ifdef ENABLE_DEBUGGER_SUPPORT
374 state = state->
Next()) {
375 char* data = state->
data();
377 data = isolate_->
Iterate(v, data);
378 data = Relocatable::Iterate(v, data);
386 state = state->
Next()) {
387 char* data = state->
data();
402 state = state->
Next()) {
403 if (thread_id.Equals(state->
id())) {
410 ContextSwitcher::ContextSwitcher(
Isolate* isolate,
int every_n_ms)
411 :
Thread(
"v8:CtxtSwitcher"),
413 sleep_ms_(every_n_ms),
421 Isolate* isolate = Isolate::Current();
438 Isolate* isolate = Isolate::Current();
455 void ContextSwitcher::Run() {
456 while (keep_going_) {
char * ArchiveState(char *to)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping true
HandleScopeImplementer * handle_scope_implementer()
char * ArchiveThread(char *to)
char * RestoreThread(char *from)
static int ArchiveSpacePerThread()
void FreeThreadResources()
Bootstrapper * bootstrapper()
PerIsolateThreadData * FindPerThreadDataForThisThread()
RegExpStack * regexp_stack()
#define ASSERT(condition)
char * RestoreState(char *from)
ThreadManager * thread_manager()
Locker(Isolate *isolate=NULL)
bool IsDefaultIsolate() const
void IterateArchivedThreads(ThreadVisitor *v)
StackGuard * stack_guard()
void FreeThreadResources()
void TerminateExecution(ThreadId thread_id)
void FreeThreadResources()
char * RestoreStackGuard(char *from)
void ClearThread(const ExecutionAccess &lock)
char * ArchiveStack(char *to)
static void PreemptionReceived()
char * ArchiveStackGuard(char *to)
static ThreadId Current()
bool terminate_on_restore()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static void EnterDefaultIsolate()
void TerminateExecution()
static int ArchiveSpacePerThread()
void Iterate(ObjectVisitor *v)
char * RestoreStack(char *from)
void Iterate(ObjectVisitor *v)
static void Sleep(const int milliseconds)
void set_thread_state(ThreadState *value)
bool IsLockedByCurrentThread()
ThreadState * GetFreeThreadState()
static int ArchiveSpacePerThread()
void FreeThreadResources()
void IterateThread(ThreadVisitor *v)
static void StopPreemption()
ThreadState * thread_state() const
void FreeThreadResources()
Unlocker(Isolate *isolate=NULL)
void Iterate(v8::internal::ObjectVisitor *v)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static int ArchiveSpacePerThread()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping true
static void StartPreemption(int every_n_ms)
ContextSwitcher * context_switcher()
char * ArchiveThread(char *to)
static ThreadId Invalid()
static void StartPreemption(int every_n_ms)
char * RestoreThread(char *from)
void set_context_switcher(ContextSwitcher *switcher)
void FreeThreadResources()
static void StopPreemption()
void set_terminate_on_restore(bool terminate_on_restore)
ThreadState * FirstThreadStateInUse()
static int ArchiveSpacePerThread()
static bool IsLocked(Isolate *isolate=NULL)
void InitThread(const ExecutionAccess &lock)