Commit d0abf522 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[stackguard] Add "HasTerminationRequest" function

We sometimes have a need to check for termination requests
while we're in the middle of non-GC-safe computations, so
we can't do a full "HandleInterrupts" (which could do GC).
This CL adds a separate function to check for termination
requests (but no other interrupt reasons) in such cases.

Bug: v8:9877, v8:11515
Change-Id: I431dba193a07ba63003794639e5d3630470d6ee7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2739587
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73256}
parent 1648e050
......@@ -157,6 +157,16 @@ void StackGuard::ClearInterrupt(InterruptFlag flag) {
if (!has_pending_interrupts(access)) reset_limits(access);
}
bool StackGuard::HasTerminationRequest() {
ExecutionAccess access(isolate_);
if ((thread_local_.interrupt_flags_ & TERMINATE_EXECUTION) != 0) {
thread_local_.interrupt_flags_ &= ~TERMINATE_EXECUTION;
if (!has_pending_interrupts(access)) reset_limits(access);
return true;
}
return false;
}
int StackGuard::FetchAndClearInterrupts() {
ExecutionAccess access(isolate_);
......
......@@ -90,6 +90,11 @@ class V8_EXPORT_PRIVATE V8_NODISCARD StackGuard final {
// stack overflow, then handle the interruption accordingly.
Object HandleInterrupts();
// Special case of {HandleInterrupts}: checks for termination requests only.
// This is guaranteed to never cause GC, so can be used to interrupt
// long-running computations that are not GC-safe.
bool HasTerminationRequest();
static constexpr int kSizeInBytes = 7 * kSystemPointerSize;
static char* Iterate(RootVisitor* v, char* thread_storage) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment