diff options
Diffstat (limited to 'deps/v8/src/execution/stack-guard.cc')
-rw-r--r-- | deps/v8/src/execution/stack-guard.cc | 62 |
1 files changed, 16 insertions, 46 deletions
diff --git a/deps/v8/src/execution/stack-guard.cc b/deps/v8/src/execution/stack-guard.cc index e5c24cef1e..1cf4c4605a 100644 --- a/deps/v8/src/execution/stack-guard.cc +++ b/deps/v8/src/execution/stack-guard.cc @@ -21,14 +21,12 @@ void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) { DCHECK_NOT_NULL(isolate_); thread_local_.set_jslimit(kInterruptLimit); thread_local_.set_climit(kInterruptLimit); - isolate_->heap()->SetStackLimits(); } void StackGuard::reset_limits(const ExecutionAccess& lock) { DCHECK_NOT_NULL(isolate_); thread_local_.set_jslimit(thread_local_.real_jslimit_); thread_local_.set_climit(thread_local_.real_climit_); - isolate_->heap()->SetStackLimits(); } void StackGuard::SetStackLimit(uintptr_t limit) { @@ -54,7 +52,6 @@ void StackGuard::AdjustStackLimitForSimulator() { uintptr_t jslimit = SimulatorStack::JsLimitFromCLimit(isolate_, climit); if (thread_local_.jslimit() == thread_local_.real_jslimit_) { thread_local_.set_jslimit(jslimit); - isolate_->heap()->SetStackLimits(); } } @@ -75,7 +72,8 @@ void StackGuard::PushInterruptsScope(InterruptsScope* scope) { DCHECK_NE(scope->mode_, InterruptsScope::kNoop); if (scope->mode_ == InterruptsScope::kPostponeInterrupts) { // Intercept already requested interrupts. - int intercepted = thread_local_.interrupt_flags_ & scope->intercept_mask_; + intptr_t intercepted = + thread_local_.interrupt_flags_ & scope->intercept_mask_; scope->intercepted_flags_ = intercepted; thread_local_.interrupt_flags_ &= ~intercepted; } else { @@ -124,7 +122,7 @@ void StackGuard::PopInterruptsScope() { bool StackGuard::CheckInterrupt(InterruptFlag flag) { ExecutionAccess access(isolate_); - return thread_local_.interrupt_flags_ & flag; + return (thread_local_.interrupt_flags_ & flag) != 0; } void StackGuard::RequestInterrupt(InterruptFlag flag) { @@ -160,7 +158,7 @@ int StackGuard::FetchAndClearInterrupts() { ExecutionAccess access(isolate_); int result = 0; - if (thread_local_.interrupt_flags_ & TERMINATE_EXECUTION) { + if ((thread_local_.interrupt_flags_ & TERMINATE_EXECUTION) != 0) { // The TERMINATE_EXECUTION interrupt is special, since it terminates // execution but should leave V8 in a resumable state. If it exists, we only // fetch and clear that bit. On resume, V8 can continue processing other @@ -169,7 +167,7 @@ int StackGuard::FetchAndClearInterrupts() { thread_local_.interrupt_flags_ &= ~TERMINATE_EXECUTION; if (!has_pending_interrupts(access)) reset_limits(access); } else { - result = thread_local_.interrupt_flags_; + result = static_cast<int>(thread_local_.interrupt_flags_); thread_local_.interrupt_flags_ = 0; reset_limits(access); } @@ -180,23 +178,13 @@ int StackGuard::FetchAndClearInterrupts() { char* StackGuard::ArchiveStackGuard(char* to) { ExecutionAccess access(isolate_); MemCopy(to, reinterpret_cast<char*>(&thread_local_), sizeof(ThreadLocal)); - ThreadLocal blank; - - // Set the stack limits using the old thread_local_. - // TODO(isolates): This was the old semantics of constructing a ThreadLocal - // (as the ctor called SetStackLimits, which looked at the - // current thread_local_ from StackGuard)-- but is this - // really what was intended? - isolate_->heap()->SetStackLimits(); - thread_local_ = blank; - + thread_local_ = {}; return to + sizeof(ThreadLocal); } char* StackGuard::RestoreStackGuard(char* from) { ExecutionAccess access(isolate_); MemCopy(reinterpret_cast<char*>(&thread_local_), from, sizeof(ThreadLocal)); - isolate_->heap()->SetStackLimits(); return from + sizeof(ThreadLocal); } @@ -206,39 +194,21 @@ void StackGuard::FreeThreadResources() { per_thread->set_stack_limit(thread_local_.real_climit_); } -void StackGuard::ThreadLocal::Clear() { - real_jslimit_ = kIllegalLimit; - set_jslimit(kIllegalLimit); - real_climit_ = kIllegalLimit; - set_climit(kIllegalLimit); +void StackGuard::ThreadLocal::Initialize(Isolate* isolate, + const ExecutionAccess& lock) { + const uintptr_t kLimitSize = FLAG_stack_size * KB; + DCHECK_GT(GetCurrentStackPosition(), kLimitSize); + uintptr_t limit = GetCurrentStackPosition() - kLimitSize; + real_jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit); + set_jslimit(SimulatorStack::JsLimitFromCLimit(isolate, limit)); + real_climit_ = limit; + set_climit(limit); interrupt_scopes_ = nullptr; interrupt_flags_ = 0; } -bool StackGuard::ThreadLocal::Initialize(Isolate* isolate) { - bool should_set_stack_limits = false; - if (real_climit_ == kIllegalLimit) { - const uintptr_t kLimitSize = FLAG_stack_size * KB; - DCHECK_GT(GetCurrentStackPosition(), kLimitSize); - uintptr_t limit = GetCurrentStackPosition() - kLimitSize; - real_jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit); - set_jslimit(SimulatorStack::JsLimitFromCLimit(isolate, limit)); - real_climit_ = limit; - set_climit(limit); - should_set_stack_limits = true; - } - interrupt_scopes_ = nullptr; - interrupt_flags_ = 0; - return should_set_stack_limits; -} - -void StackGuard::ClearThread(const ExecutionAccess& lock) { - thread_local_.Clear(); - isolate_->heap()->SetStackLimits(); -} - void StackGuard::InitThread(const ExecutionAccess& lock) { - if (thread_local_.Initialize(isolate_)) isolate_->heap()->SetStackLimits(); + thread_local_.Initialize(isolate_, lock); Isolate::PerIsolateThreadData* per_thread = isolate_->FindOrAllocatePerThreadDataForThisThread(); uintptr_t stored_limit = per_thread->stack_limit(); |