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() { ...@@ -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++) { for (int i = 0; i < args.size(); i++) {
assert(args[i]->isInLocation(args[i]->arg_loc)); assert(args[i]->isInLocation(args[i]->arg_loc));
} }
...@@ -274,6 +280,8 @@ void Rewriter::_addGuard(RewriterVar* var, RewriterVar* val_constant) { ...@@ -274,6 +280,8 @@ void Rewriter::_addGuard(RewriterVar* var, RewriterVar* val_constant) {
} else { } else {
assembler->cmp(var_reg, assembler::Immediate(val)); assembler->cmp(var_reg, assembler::Immediate(val));
} }
assertArgsInPlace();
assembler->jne(assembler::JumpDestination::fromStart(rewrite->getSlotSize())); assembler->jne(assembler::JumpDestination::fromStart(rewrite->getSlotSize()));
var->bumpUse(); var->bumpUse();
...@@ -300,6 +308,8 @@ void Rewriter::_addGuardNotEq(RewriterVar* var, RewriterVar* val_constant) { ...@@ -300,6 +308,8 @@ void Rewriter::_addGuardNotEq(RewriterVar* var, RewriterVar* val_constant) {
} else { } else {
assembler->cmp(var_reg, assembler::Immediate(val)); assembler->cmp(var_reg, assembler::Immediate(val));
} }
assertArgsInPlace();
assembler->je(assembler::JumpDestination::fromStart(rewrite->getSlotSize())); assembler->je(assembler::JumpDestination::fromStart(rewrite->getSlotSize()));
var->bumpUse(); var->bumpUse();
...@@ -345,6 +355,8 @@ void Rewriter::_addAttrGuard(RewriterVar* var, int offset, RewriterVar* val_cons ...@@ -345,6 +355,8 @@ void Rewriter::_addAttrGuard(RewriterVar* var, int offset, RewriterVar* val_cons
} else { } else {
assembler->cmp(assembler::Indirect(var_reg, offset), assembler::Immediate(val)); assembler->cmp(assembler::Indirect(var_reg, offset), assembler::Immediate(val));
} }
assertArgsInPlace();
if (negate) if (negate)
assembler->je(assembler::JumpDestination::fromStart(rewrite->getSlotSize())); assembler->je(assembler::JumpDestination::fromStart(rewrite->getSlotSize()));
else else
......
...@@ -391,9 +391,11 @@ private: ...@@ -391,9 +391,11 @@ private:
return done_guarding; return done_guarding;
} }
// Make sure our original args are currently in their original positions. // Move the original IC args back into their original registers:
// ie if we are about to guard and then branch to the slowpath callsite.
void restoreArgs(); 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 // Allocates a register. dest must be of type Register or AnyReg
// If otherThan is a register, guaranteed to not use that register. // 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