[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:
Leszek Swirski 2017-08-30 15:34:59 +01:00 committed by Commit Bot
parent 9286415434
commit 769b259750

View File

@ -1026,7 +1026,8 @@ Node* InterpreterAssembler::CallRuntimeN(Node* function_id, Node* context,
} }
void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) { void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) {
Label ok(this), interrupt_check(this, Label::kDeferred), end(this); Comment("[ UpdateInterruptBudget");
Node* budget_offset = Node* budget_offset =
IntPtrConstant(BytecodeArray::kInterruptBudgetOffset - kHeapObjectTag); 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. // Make sure we include the current bytecode in the budget calculation.
Node* budget_after_bytecode = Node* budget_after_bytecode =
Int32Sub(old_budget, Int32Constant(CurrentBytecodeSize())); Int32Sub(old_budget, Int32Constant(CurrentBytecodeSize()));
if (backward) { if (backward) {
new_budget.Bind(Int32Sub(budget_after_bytecode, weight)); 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. Node* condition =
BIND(&interrupt_check); Int32GreaterThanOrEqual(new_budget.value(), Int32Constant(0));
{ Label ok(this), interrupt_check(this, Label::kDeferred);
CallRuntime(Runtime::kInterrupt, GetContext()); Branch(condition, &ok, &interrupt_check);
new_budget.Bind(Int32Constant(Interpreter::InterruptBudget()));
Goto(&ok); // 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. // Update budget.
BIND(&ok);
StoreNoWriteBarrier(MachineRepresentation::kWord32, StoreNoWriteBarrier(MachineRepresentation::kWord32,
BytecodeArrayTaggedPointer(), budget_offset, BytecodeArrayTaggedPointer(), budget_offset,
new_budget.value()); new_budget.value());
Comment("] UpdateInterruptBudget");
} }
Node* InterpreterAssembler::Advance() { return Advance(CurrentBytecodeSize()); } Node* InterpreterAssembler::Advance() { return Advance(CurrentBytecodeSize()); }