Commit 2ee9b293 authored by Camillo's avatar Camillo Committed by V8 LUCI CQ

[runtime] Reduce STACK_CHECK code footprint

Add outlined StackLimitCheck::HandleInterrupt helper for the uncommon
path.

Change-Id: Ib13dc84ac632f3455d5933748428f9550a23d435
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3829088Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82560}
parent 3e825c77
......@@ -5568,6 +5568,18 @@ void Isolate::clear_cached_icu_objects() {
#endif // V8_INTL_SUPPORT
bool StackLimitCheck::HandleInterrupt(Isolate* isolate) {
DCHECK(InterruptRequested());
if (HasOverflowed()) {
isolate->StackOverflow();
return true;
}
if (isolate->stack_guard()->HasTerminationRequest()) {
isolate->TerminateExecution();
return true;
}
return false;
}
bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const {
StackGuard* stack_guard = isolate_->stack_guard();
#ifdef USE_SIMULATOR
......
......@@ -2581,11 +2581,16 @@ class StackLimitCheck {
static bool HasOverflowed(LocalIsolate* local_isolate);
// Use this to check for interrupt request in C++ code.
bool InterruptRequested() {
V8_INLINE bool InterruptRequested() {
StackGuard* stack_guard = isolate_->stack_guard();
return GetCurrentStackPosition() < stack_guard->climit();
}
// Handle interripts if InterruptRequested was true.
// Returns true if any interrupt (overflow or termination) was handled, in
// which case the caller should prevent further JS execution.
V8_EXPORT_PRIVATE bool HandleInterrupt(Isolate* isolate);
// Use this to check for stack-overflow when entering runtime from JS code.
bool JsHasOverflowed(uintptr_t gap = 0) const;
......@@ -2595,19 +2600,14 @@ class StackLimitCheck {
// This macro may be used in context that disallows JS execution.
// That is why it checks only for a stack overflow and termination.
#define STACK_CHECK(isolate, result_value) \
do { \
StackLimitCheck stack_check(isolate); \
if (stack_check.InterruptRequested()) { \
if (stack_check.HasOverflowed()) { \
isolate->StackOverflow(); \
return result_value; \
} \
if (isolate->stack_guard()->HasTerminationRequest()) { \
isolate->TerminateExecution(); \
return result_value; \
} \
} \
#define STACK_CHECK(isolate, result_value) \
do { \
StackLimitCheck stack_check(isolate); \
if (stack_check.InterruptRequested()) { \
if (stack_check.HandleInterrupt(isolate)) { \
return result_value; \
} \
} \
} while (false)
class StackTraceFailureMessage {
......
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