Commit 8904bcee authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[sparkplug] Adjust interrupt weight by current bytecode size

The interpreter always adjusts the current interrupt budget down by the
current bytecode size as well. This aligns the optimization heuristics.

Bug: v8:11420
Change-Id: I0cc78d004779b393a3d8fb46e44bdd7465fcf4ed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2726496
Auto-Submit: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73130}
parent 6e234e9d
......@@ -485,22 +485,25 @@ INTRINSICS_LIST(DECLARE_VISITOR)
void BaselineCompiler::UpdateInterruptBudgetAndJumpToLabel(
int weight, Label* label, Label* skip_interrupt_label) {
__ RecordComment("[ Update Interrupt Budget");
__ AddToInterruptBudget(weight);
if (weight < 0) {
// Use compare flags set by AddToInterruptBudget
__ JumpIf(Condition::kGreaterThanEqual, skip_interrupt_label);
SaveAccumulatorScope accumulator_scope(&basm_);
CallRuntime(Runtime::kBytecodeBudgetInterruptFromBytecode,
__ FunctionOperand());
if (weight != 0) {
__ RecordComment("[ Update Interrupt Budget");
__ AddToInterruptBudget(weight);
if (weight < 0) {
// Use compare flags set by AddToInterruptBudget
__ JumpIf(Condition::kGreaterThanEqual, skip_interrupt_label);
SaveAccumulatorScope accumulator_scope(&basm_);
CallRuntime(Runtime::kBytecodeBudgetInterruptFromBytecode,
__ FunctionOperand());
}
}
if (label) __ Jump(label);
__ RecordComment("]");
if (weight != 0) __ RecordComment("]");
}
void BaselineCompiler::UpdateInterruptBudgetAndDoInterpreterJump() {
int weight = iterator().GetRelativeJumpTargetOffset();
int weight = iterator().GetRelativeJumpTargetOffset() -
iterator().current_bytecode_size_without_prefix();
UpdateInterruptBudgetAndJumpToLabel(weight, BuildForwardJumpLabel(), nullptr);
}
......@@ -1763,7 +1766,8 @@ void BaselineCompiler::VisitJumpLoop() {
__ Bind(&osr_not_armed);
Label* label = &labels_[iterator().GetJumpTargetOffset()]->unlinked;
int weight = iterator().GetRelativeJumpTargetOffset();
int weight = iterator().GetRelativeJumpTargetOffset() -
iterator().current_bytecode_size_without_prefix();
// We can pass in the same label twice since it's a back edge and thus already
// bound.
DCHECK(label->is_bound());
......@@ -1960,7 +1964,8 @@ void BaselineCompiler::VisitReThrow() {
void BaselineCompiler::VisitReturn() {
__ RecordComment("[ Return");
int profiling_weight = iterator().current_offset();
int profiling_weight = iterator().current_offset() +
iterator().current_bytecode_size_without_prefix();
int parameter_count = bytecode_->parameter_count();
// We must pop all arguments from the stack (including the receiver). This
......
......@@ -54,8 +54,11 @@ void BytecodeArrayIterator::ApplyDebugBreak() {
}
int BytecodeArrayIterator::current_bytecode_size() const {
return prefix_size_ +
Bytecodes::Size(current_bytecode(), current_operand_scale());
return prefix_size_ + current_bytecode_size_without_prefix();
}
int BytecodeArrayIterator::current_bytecode_size_without_prefix() const {
return Bytecodes::Size(current_bytecode(), current_operand_scale());
}
uint32_t BytecodeArrayIterator::GetUnsignedOperand(
......
......@@ -93,6 +93,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayIterator {
return current_bytecode;
}
int current_bytecode_size() const;
int current_bytecode_size_without_prefix() const;
int current_offset() const {
return static_cast<int>(cursor_ - start_ - prefix_size_);
}
......
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