Update comments and names related to stack checks
.. and several other minor changes (branch hints, moving code around for better grouping, const). Bug: v8:7700 Change-Id: Ia07aa478a5ae5d1852e4ad2dce39f42743376e65 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4128096 Commit-Queue: Darius Mercadier <dmercadier@chromium.org> Reviewed-by: Darius Mercadier <dmercadier@chromium.org> Auto-Submit: Jakob Linke <jgruber@chromium.org> Commit-Queue: Jakob Linke <jgruber@chromium.org> Cr-Commit-Position: refs/heads/main@{#85025}
This commit is contained in:
parent
eb008c433e
commit
4914da9d01
@ -5834,18 +5834,19 @@ void Isolate::clear_cached_icu_objects() {
|
||||
|
||||
#endif // V8_INTL_SUPPORT
|
||||
|
||||
bool StackLimitCheck::HandleInterrupt(Isolate* isolate) {
|
||||
bool StackLimitCheck::HandleStackOverflowAndTerminationRequest() {
|
||||
DCHECK(InterruptRequested());
|
||||
if (HasOverflowed()) {
|
||||
isolate->StackOverflow();
|
||||
if (V8_UNLIKELY(HasOverflowed())) {
|
||||
isolate_->StackOverflow();
|
||||
return true;
|
||||
}
|
||||
if (isolate->stack_guard()->HasTerminationRequest()) {
|
||||
isolate->TerminateExecution();
|
||||
if (V8_UNLIKELY(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
|
||||
|
@ -2635,34 +2635,33 @@ class StackLimitCheck {
|
||||
}
|
||||
static bool HasOverflowed(LocalIsolate* local_isolate);
|
||||
|
||||
// Use this to check for stack-overflow when entering runtime from JS code.
|
||||
bool JsHasOverflowed(uintptr_t gap = 0) const;
|
||||
|
||||
// Use this to check for interrupt request in C++ code.
|
||||
V8_INLINE bool InterruptRequested() {
|
||||
StackGuard* stack_guard = isolate_->stack_guard();
|
||||
return GetCurrentStackPosition() < stack_guard->climit();
|
||||
}
|
||||
|
||||
// Handle interripts if InterruptRequested was true.
|
||||
// Precondition: InterruptRequested == 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;
|
||||
// which case the caller must prevent further JS execution.
|
||||
V8_EXPORT_PRIVATE bool HandleStackOverflowAndTerminationRequest();
|
||||
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
Isolate* const isolate_;
|
||||
};
|
||||
|
||||
// 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.HandleInterrupt(isolate)) { \
|
||||
return result_value; \
|
||||
} \
|
||||
} \
|
||||
#define STACK_CHECK(isolate, result_value) \
|
||||
do { \
|
||||
StackLimitCheck stack_check(isolate); \
|
||||
if (V8_UNLIKELY(stack_check.InterruptRequested()) && \
|
||||
V8_UNLIKELY(stack_check.HandleStackOverflowAndTerminationRequest())) { \
|
||||
return result_value; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
class StackTraceFailureMessage {
|
||||
|
@ -367,7 +367,6 @@ Object BytecodeBudgetInterruptWithStackCheck(Isolate* isolate,
|
||||
// We ideally wouldn't actually get StackOverflows here, since we stack
|
||||
// check on bytecode entry, but it's possible that this check fires due to
|
||||
// the runtime function call being what overflows the stack.
|
||||
// if our function entry
|
||||
return isolate->StackOverflow();
|
||||
} else if (check.InterruptRequested()) {
|
||||
Object return_value = isolate->stack_guard()->HandleInterrupts();
|
||||
|
Loading…
Reference in New Issue
Block a user