Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Unified Diff: src/execution.cc

Issue 359963004: Reland "Add mechanism to postpone interrupts selectively." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/execution.h ('k') | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/execution.cc
diff --git a/src/execution.cc b/src/execution.cc
index 2766e76b8caa5454923542d8861a6a581977f946..b88c0cfff3c06d2408997fa8d724d7bdaf0cd333 100644
--- a/src/execution.cc
+++ b/src/execution.cc
@@ -20,8 +20,6 @@ StackGuard::StackGuard()
void StackGuard::set_interrupt_limits(const ExecutionAccess& lock) {
ASSERT(isolate_ != NULL);
- // Ignore attempts to interrupt when interrupts are postponed.
- if (should_postpone_interrupts(lock)) return;
thread_local_.jslimit_ = kInterruptLimit;
thread_local_.climit_ = kInterruptLimit;
isolate_->heap()->SetStackLimits();
@@ -337,36 +335,71 @@ void StackGuard::DisableInterrupts() {
}
-bool StackGuard::CheckInterrupt(int flagbit) {
+void StackGuard::PushPostponeInterruptsScope(PostponeInterruptsScope* scope) {
ExecutionAccess access(isolate_);
- return thread_local_.interrupt_flags_ & flagbit;
+ // Intercept already requested interrupts.
+ int intercepted = thread_local_.interrupt_flags_ & scope->intercept_mask_;
+ scope->intercepted_flags_ = intercepted;
+ thread_local_.interrupt_flags_ &= ~intercepted;
+ if (!has_pending_interrupts(access)) reset_limits(access);
+ // Add scope to the chain.
+ scope->prev_ = thread_local_.postpone_interrupts_;
+ thread_local_.postpone_interrupts_ = scope;
}
-void StackGuard::RequestInterrupt(int flagbit) {
+void StackGuard::PopPostponeInterruptsScope() {
ExecutionAccess access(isolate_);
- thread_local_.interrupt_flags_ |= flagbit;
+ PostponeInterruptsScope* top = thread_local_.postpone_interrupts_;
+ // Make intercepted interrupts active.
+ ASSERT((thread_local_.interrupt_flags_ & top->intercept_mask_) == 0);
+ thread_local_.interrupt_flags_ |= top->intercepted_flags_;
+ if (has_pending_interrupts(access)) set_interrupt_limits(access);
+ // Remove scope from chain.
+ thread_local_.postpone_interrupts_ = top->prev_;
+}
+
+
+bool StackGuard::CheckInterrupt(InterruptFlag flag) {
+ ExecutionAccess access(isolate_);
+ return thread_local_.interrupt_flags_ & flag;
+}
+
+
+void StackGuard::RequestInterrupt(InterruptFlag flag) {
+ ExecutionAccess access(isolate_);
+ // Check the chain of PostponeInterruptsScopes for interception.
+ if (thread_local_.postpone_interrupts_ &&
+ thread_local_.postpone_interrupts_->Intercept(flag)) {
+ return;
+ }
+
+ // Not intercepted. Set as active interrupt flag.
+ thread_local_.interrupt_flags_ |= flag;
set_interrupt_limits(access);
}
-void StackGuard::ClearInterrupt(int flagbit) {
+void StackGuard::ClearInterrupt(InterruptFlag flag) {
ExecutionAccess access(isolate_);
- thread_local_.interrupt_flags_ &= ~flagbit;
- if (!should_postpone_interrupts(access) && !has_pending_interrupts(access)) {
- reset_limits(access);
+ // Clear the interrupt flag from the chain of PostponeInterruptsScopes.
+ for (PostponeInterruptsScope* current = thread_local_.postpone_interrupts_;
+ current != NULL;
+ current = current->prev_) {
+ current->intercepted_flags_ &= ~flag;
}
+
+ // Clear the interrupt flag from the active interrupt flags.
+ thread_local_.interrupt_flags_ &= ~flag;
+ if (!has_pending_interrupts(access)) reset_limits(access);
}
bool StackGuard::CheckAndClearInterrupt(InterruptFlag flag) {
ExecutionAccess access(isolate_);
- int flagbit = 1 << flag;
- bool result = (thread_local_.interrupt_flags_ & flagbit);
- thread_local_.interrupt_flags_ &= ~flagbit;
- if (!should_postpone_interrupts(access) && !has_pending_interrupts(access)) {
- reset_limits(access);
- }
+ bool result = (thread_local_.interrupt_flags_ & flag);
+ thread_local_.interrupt_flags_ &= ~flag;
+ if (!has_pending_interrupts(access)) reset_limits(access);
return result;
}
@@ -408,8 +441,7 @@ void StackGuard::ThreadLocal::Clear() {
jslimit_ = kIllegalLimit;
real_climit_ = kIllegalLimit;
climit_ = kIllegalLimit;
- nesting_ = 0;
- postpone_interrupts_nesting_ = 0;
+ postpone_interrupts_ = NULL;
interrupt_flags_ = 0;
}
@@ -428,8 +460,7 @@ bool StackGuard::ThreadLocal::Initialize(Isolate* isolate) {
climit_ = limit;
should_set_stack_limits = true;
}
- nesting_ = 0;
- postpone_interrupts_nesting_ = 0;
+ postpone_interrupts_ = NULL;
interrupt_flags_ = 0;
return should_set_stack_limits;
}
@@ -648,13 +679,6 @@ Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
Object* StackGuard::HandleInterrupts() {
- {
- ExecutionAccess access(isolate_);
- if (should_postpone_interrupts(access)) {
- return isolate_->heap()->undefined_value();
- }
- }
-
if (CheckAndClearInterrupt(GC_REQUEST)) {
isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt");
}
« no previous file with comments | « src/execution.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698