[ignition] Only perform interrupt checks for backward jumps
Jumps (and returns) in Ignition update the interrupt budget, and call into the runtime if the budget drops below zero. Since forward jumps only ever increase the budget, we don't need to generate this check or the call for them at all. Change-Id: I8c4ae15edab39a3a5725a98f38efba3a16243d91 Reviewed-on: https://chromium-review.googlesource.com/643209 Reviewed-by: Mythri Alle <mythria@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#47720}
This commit is contained in:
parent
9286415434
commit
769b259750
@ -1026,7 +1026,8 @@ Node* InterpreterAssembler::CallRuntimeN(Node* function_id, Node* context,
|
||||
}
|
||||
|
||||
void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) {
|
||||
Label ok(this), interrupt_check(this, Label::kDeferred), end(this);
|
||||
Comment("[ UpdateInterruptBudget");
|
||||
|
||||
Node* budget_offset =
|
||||
IntPtrConstant(BytecodeArray::kInterruptBudgetOffset - kHeapObjectTag);
|
||||
|
||||
@ -1041,28 +1042,35 @@ void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) {
|
||||
// Make sure we include the current bytecode in the budget calculation.
|
||||
Node* budget_after_bytecode =
|
||||
Int32Sub(old_budget, Int32Constant(CurrentBytecodeSize()));
|
||||
|
||||
if (backward) {
|
||||
new_budget.Bind(Int32Sub(budget_after_bytecode, weight));
|
||||
} else {
|
||||
new_budget.Bind(Int32Add(budget_after_bytecode, weight));
|
||||
}
|
||||
Node* condition =
|
||||
Int32GreaterThanOrEqual(new_budget.value(), Int32Constant(0));
|
||||
Branch(condition, &ok, &interrupt_check);
|
||||
|
||||
// Perform interrupt and reset budget.
|
||||
BIND(&interrupt_check);
|
||||
{
|
||||
CallRuntime(Runtime::kInterrupt, GetContext());
|
||||
new_budget.Bind(Int32Constant(Interpreter::InterruptBudget()));
|
||||
Goto(&ok);
|
||||
Node* condition =
|
||||
Int32GreaterThanOrEqual(new_budget.value(), Int32Constant(0));
|
||||
Label ok(this), interrupt_check(this, Label::kDeferred);
|
||||
Branch(condition, &ok, &interrupt_check);
|
||||
|
||||
// Perform interrupt and reset budget.
|
||||
BIND(&interrupt_check);
|
||||
{
|
||||
CallRuntime(Runtime::kInterrupt, GetContext());
|
||||
new_budget.Bind(Int32Constant(Interpreter::InterruptBudget()));
|
||||
Goto(&ok);
|
||||
}
|
||||
|
||||
BIND(&ok);
|
||||
} else {
|
||||
// For a forward jump, we know we only increase the interrupt budget, so
|
||||
// no need to check if it's below zero.
|
||||
new_budget.Bind(Int32Add(budget_after_bytecode, weight));
|
||||
}
|
||||
|
||||
// Update budget.
|
||||
BIND(&ok);
|
||||
StoreNoWriteBarrier(MachineRepresentation::kWord32,
|
||||
BytecodeArrayTaggedPointer(), budget_offset,
|
||||
new_budget.value());
|
||||
Comment("] UpdateInterruptBudget");
|
||||
}
|
||||
|
||||
Node* InterpreterAssembler::Advance() { return Advance(CurrentBytecodeSize()); }
|
||||
|
Loading…
Reference in New Issue
Block a user