Commit 4d4eeeab authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add additional args-in-place check right before jumps

We would check that they're in the right place as part of
restoreArgs (ie putting them in the right place), but then we
would do some other work (loading the value to check, loading
the constant) which could potentially spill registers.

So add an additional check right before we emit the actual
jump instruction.  I'm surprised this never failed.
parent c121fa51
......@@ -251,6 +251,12 @@ void Rewriter::restoreArgs() {
}
}
assertArgsInPlace();
}
void Rewriter::assertArgsInPlace() {
ASSERT(!done_guarding, "this will probably work but why are we calling this at this time");
for (int i = 0; i < args.size(); i++) {
assert(args[i]->isInLocation(args[i]->arg_loc));
}
......@@ -274,6 +280,8 @@ void Rewriter::_addGuard(RewriterVar* var, RewriterVar* val_constant) {
} else {
assembler->cmp(var_reg, assembler::Immediate(val));
}
assertArgsInPlace();
assembler->jne(assembler::JumpDestination::fromStart(rewrite->getSlotSize()));
var->bumpUse();
......@@ -300,6 +308,8 @@ void Rewriter::_addGuardNotEq(RewriterVar* var, RewriterVar* val_constant) {
} else {
assembler->cmp(var_reg, assembler::Immediate(val));
}
assertArgsInPlace();
assembler->je(assembler::JumpDestination::fromStart(rewrite->getSlotSize()));
var->bumpUse();
......@@ -345,6 +355,8 @@ void Rewriter::_addAttrGuard(RewriterVar* var, int offset, RewriterVar* val_cons
} else {
assembler->cmp(assembler::Indirect(var_reg, offset), assembler::Immediate(val));
}
assertArgsInPlace();
if (negate)
assembler->je(assembler::JumpDestination::fromStart(rewrite->getSlotSize()));
else
......
......@@ -391,9 +391,11 @@ private:
return done_guarding;
}
// Make sure our original args are currently in their original positions.
// ie if we are about to guard and then branch to the slowpath callsite.
// Move the original IC args back into their original registers:
void restoreArgs();
// Assert that our original args are correctly placed in case we need to
// bail out of the IC:
void assertArgsInPlace();
// Allocates a register. dest must be of type Register or AnyReg
// If otherThan is a register, guaranteed to not use that register.
......
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