#include "src/execution/interrupts-scope.h"
#include "src/execution/isolate.h"
namespace v8 {
namespace internal {
bool InterruptsScope::Intercept(StackGuard::InterruptFlag flag) {
InterruptsScope* last_postpone_scope = nullptr;
for (InterruptsScope* current = this; current; current = current->prev_) {
if (!(current->intercept_mask_ & flag)) continue;
if (current->mode_ == kRunInterrupts) {
break;
} else {
DCHECK_EQ(current->mode_, kPostponeInterrupts);
last_postpone_scope = current;
}
}
if (!last_postpone_scope) return false;
last_postpone_scope->intercepted_flags_ |= flag;
return true;
}
}
}