Commit da5ad432 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[ignition/sparkplug] Fold loop interrupt checks together

Fold the stack interrupt check to happen as part of the bytecode budget
interrupt, so that we can skip the stack check on JumpLoop. This is a
minor improvement for Ignition, but it's mainly for for Sparkplug code
as it means we don't have to emit additional stack interrupt checks.

TurboFan doesn't have budget interrupts, so it keeps the stack interrupt
check.

Bug: v8:11420
Change-Id: I055fe752946fda6a50ca2675fa3847999898a951
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3041674
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75851}
parent 3f641945
...@@ -2158,8 +2158,6 @@ IGNITION_HANDLER(JumpLoop, InterpreterAssembler) { ...@@ -2158,8 +2158,6 @@ IGNITION_HANDLER(JumpLoop, InterpreterAssembler) {
TNode<Int8T> osr_level = LoadOsrNestingLevel(); TNode<Int8T> osr_level = LoadOsrNestingLevel();
TNode<Context> context = GetContext(); TNode<Context> context = GetContext();
PerformStackCheck(context);
// Check if OSR points at the given {loop_depth} are armed by comparing it to // Check if OSR points at the given {loop_depth} are armed by comparing it to
// the current {osr_level} loaded from the header of the BytecodeArray. // the current {osr_level} loaded from the header of the BytecodeArray.
Label ok(this), osr_armed(this, Label::kDeferred); Label ok(this), osr_armed(this, Label::kDeferred);
...@@ -2167,6 +2165,8 @@ IGNITION_HANDLER(JumpLoop, InterpreterAssembler) { ...@@ -2167,6 +2165,8 @@ IGNITION_HANDLER(JumpLoop, InterpreterAssembler) {
Branch(condition, &ok, &osr_armed); Branch(condition, &ok, &osr_armed);
BIND(&ok); BIND(&ok);
// The backward jump can trigger a budget interrupt, which can handle stack
// interrupts, so we don't need to explicitly handle them here.
JumpBackward(relative_jump); JumpBackward(relative_jump);
BIND(&osr_armed); BIND(&osr_armed);
......
...@@ -333,6 +333,22 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterruptFromBytecode) { ...@@ -333,6 +333,22 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterruptFromBytecode) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
TRACE_EVENT0("v8.execute", "V8.BytecodeBudgetInterrupt");
// Check for stack interrupts here so that we can fold the interrupt check
// into bytecode budget interrupts.
StackLimitCheck check(isolate);
if (check.JsHasOverflowed()) {
// TODO(leszeks): We shouldn't actually get StackOverflows here, consider
// DCHECKing instead.
return isolate->StackOverflow();
} else if (check.InterruptRequested()) {
Object return_value = isolate->stack_guard()->HandleInterrupts();
if (!return_value.IsUndefined(isolate)) {
return return_value;
}
}
function->SetInterruptBudget(); function->SetInterruptBudget();
bool should_mark_for_optimization = function->has_feedback_vector(); bool should_mark_for_optimization = function->has_feedback_vector();
if (!function->has_feedback_vector()) { if (!function->has_feedback_vector()) {
...@@ -369,6 +385,9 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterruptFromCode) { ...@@ -369,6 +385,9 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterruptFromCode) {
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(FeedbackCell, feedback_cell, 0); CONVERT_ARG_HANDLE_CHECKED(FeedbackCell, feedback_cell, 0);
// TODO(leszeks): Consider checking stack interrupts here, and removing
// those checks for code that can have budget interrupts.
DCHECK(feedback_cell->value().IsFeedbackVector()); DCHECK(feedback_cell->value().IsFeedbackVector());
FeedbackVector::SetInterruptBudget(*feedback_cell); FeedbackVector::SetInterruptBudget(*feedback_cell);
......
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