[JAEGER] Added JSOP_LT,LE,GT,GE,STRING with fast-paths.

This commit is contained in:
David Anderson
2010-05-31 22:44:00 -07:00
parent 10ca7030e2
commit 83fe528007
10 changed files with 336 additions and 43 deletions

View File

@@ -307,6 +307,25 @@ mjit::Compiler::generateMethod()
if (fused != JSOP_NOP)
target = next + GET_JUMP_OFFSET(next);
BoolStub stub = NULL;
switch (op) {
case JSOP_LT:
stub = stubs::LessThan;
break;
case JSOP_LE:
stub = stubs::LessEqual;
break;
case JSOP_GT:
stub = stubs::GreaterThan;
break;
case JSOP_GE:
stub = stubs::GreaterEqual;
break;
default:
JS_NOT_REACHED("WAT");
break;
}
FrameEntry *rhs = frame.peek(-1);
FrameEntry *lhs = frame.peek(-2);
@@ -336,45 +355,11 @@ mjit::Compiler::generateMethod()
}
}
} else {
prepareStubCall();
BoolStub stub = NULL;
switch (op) {
case JSOP_LT:
stub = stubs::LessThan;
break;
case JSOP_LE:
stub = stubs::LessEqual;
break;
case JSOP_GT:
stub = stubs::GreaterThan;
break;
case JSOP_GE:
stub = stubs::GreaterEqual;
break;
default:
JS_NOT_REACHED("WAT");
break;
}
stubCall(stub, Uses(2), Defs(0));
frame.pop();
frame.pop();
if (!target) {
frame.takeReg(Registers::ReturnReg);
frame.pushTypedPayload(JSVAL_MASK32_BOOLEAN, Registers::ReturnReg);
} else {
frame.forgetEverything();
Assembler::Condition cond = (fused == JSOP_IFEQ)
? Assembler::Zero
: Assembler::NonZero;
Jump j = masm.branchTest32(cond, Registers::ReturnReg,
Registers::ReturnReg);
jumpInScript(j, target);
}
emitStubCmpOp(stub, target, fused);
}
} else {
/* Anything else should go through the fast path generator. */
jsop_relational(op, target, fused);
jsop_relational(op, stub, target, fused);
}
/* Advance PC manually. */
@@ -426,6 +411,14 @@ mjit::Compiler::generateMethod()
}
END_CASE(JSOP_DOUBLE)
BEGIN_CASE(JSOP_STRING)
{
JSAtom *atom = script->getAtom(fullAtomIndex(PC));
JSString *str = ATOM_TO_STRING(atom);
frame.push(Value(StringTag(str)));
}
END_CASE(JSOP_STRING)
BEGIN_CASE(JSOP_ZERO)
frame.push(Valueify(JSVAL_ZERO));
END_CASE(JSOP_ZERO)
@@ -523,7 +516,7 @@ mjit::Compiler::generateMethod()
#undef END_CASE
#undef BEGIN_CASE
const JSC::MacroAssembler::Label &
JSC::MacroAssembler::Label
mjit::Compiler::labelOf(jsbytecode *pc)
{
uint32 offs = uint32(pc - script->code);
@@ -549,6 +542,12 @@ mjit::Compiler::fullAtomIndex(jsbytecode *pc)
#endif
}
bool
mjit::Compiler::knownJump(jsbytecode *pc)
{
return pc < PC;
}
void
mjit::Compiler::jumpInScript(Jump j, jsbytecode *pc)
{
@@ -704,3 +703,25 @@ mjit::Compiler::compareTwoValues(JSContext *cx, JSOp op, const Value &lhs, const
return false;
}
void
mjit::Compiler::emitStubCmpOp(BoolStub stub, jsbytecode *target, JSOp fused)
{
prepareStubCall();
stubCall(stub, Uses(2), Defs(0));
frame.pop();
frame.pop();
if (!target) {
frame.takeReg(Registers::ReturnReg);
frame.pushTypedPayload(JSVAL_MASK32_BOOLEAN, Registers::ReturnReg);
} else {
frame.forgetEverything();
Assembler::Condition cond = (fused == JSOP_IFEQ)
? Assembler::Zero
: Assembler::NonZero;
Jump j = masm.branchTest32(cond, Registers::ReturnReg,
Registers::ReturnReg);
jumpInScript(j, target);
}
}