mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
[JAEGER] Fast-path boolean for JSOP_IFEQ, JSOP_IFNE; (577973, r=dvander).
This commit is contained in:
parent
2cc55ac57e
commit
714fefa9b1
@ -433,39 +433,7 @@ mjit::Compiler::generateMethod()
|
||||
|
||||
BEGIN_CASE(JSOP_IFEQ)
|
||||
BEGIN_CASE(JSOP_IFNE)
|
||||
{
|
||||
FrameEntry *top = frame.peek(-1);
|
||||
Jump j;
|
||||
if (top->isConstant()) {
|
||||
const Value &v = top->getValue();
|
||||
JSBool b = js_ValueToBoolean(v);
|
||||
if (op == JSOP_IFEQ)
|
||||
b = !b;
|
||||
frame.pop();
|
||||
frame.forgetEverything();
|
||||
if (b) {
|
||||
j = masm.jump();
|
||||
jumpInScript(j, PC + GET_JUMP_OFFSET(PC));
|
||||
}
|
||||
} else {
|
||||
frame.forgetEverything();
|
||||
masm.fixScriptStack(frame.frameDepth());
|
||||
masm.setupVMFrame();
|
||||
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
|
||||
masm.push(Registers::ArgReg0);
|
||||
#endif
|
||||
masm.call(JS_FUNC_TO_DATA_PTR(void *, stubs::ValueToBoolean));
|
||||
#if defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)
|
||||
masm.pop();
|
||||
#endif
|
||||
Assembler::Condition cond = (op == JSOP_IFEQ)
|
||||
? Assembler::Zero
|
||||
: Assembler::NonZero;
|
||||
j = masm.branchTest32(cond, Registers::ReturnReg, Registers::ReturnReg);
|
||||
frame.pop();
|
||||
jumpInScript(j, PC + GET_JUMP_OFFSET(PC));
|
||||
}
|
||||
}
|
||||
jsop_ifneq(op, PC + GET_JUMP_OFFSET(PC));
|
||||
END_CASE(JSOP_IFNE)
|
||||
|
||||
BEGIN_CASE(JSOP_ARGUMENTS)
|
||||
|
@ -245,6 +245,8 @@ class Compiler
|
||||
void jsop_objtostr();
|
||||
void jsop_not();
|
||||
void jsop_typeof();
|
||||
void booleanJumpScript(JSOp op, jsbytecode *target);
|
||||
void jsop_ifneq(JSOp op, jsbytecode *target);
|
||||
void jsop_andor(JSOp op, jsbytecode *target);
|
||||
void jsop_arginc(JSOp op, uint32 slot, bool popped);
|
||||
void jsop_localinc(JSOp op, uint32 slot, bool popped);
|
||||
|
@ -794,24 +794,10 @@ mjit::Compiler::jsop_typeof()
|
||||
}
|
||||
|
||||
void
|
||||
mjit::Compiler::jsop_andor(JSOp op, jsbytecode *target)
|
||||
mjit::Compiler::booleanJumpScript(JSOp op, jsbytecode *target)
|
||||
{
|
||||
FrameEntry *fe = frame.peek(-1);
|
||||
|
||||
if (fe->isConstant()) {
|
||||
JSBool b = js_ValueToBoolean(fe->getValue());
|
||||
|
||||
/* Short-circuit. */
|
||||
if ((op == JSOP_OR && b == JS_TRUE) ||
|
||||
(op == JSOP_AND && b == JS_FALSE)) {
|
||||
frame.forgetEverything();
|
||||
jumpInScript(masm.jump(), target);
|
||||
}
|
||||
|
||||
frame.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
MaybeRegisterID type;
|
||||
MaybeRegisterID data;
|
||||
|
||||
@ -824,10 +810,10 @@ mjit::Compiler::jsop_andor(JSOp op, jsbytecode *target)
|
||||
/* :FIXME: Can something more lightweight be used? */
|
||||
frame.forgetEverything();
|
||||
|
||||
Assembler::Condition cond = (op == JSOP_OR)
|
||||
Assembler::Condition cond = (op == JSOP_IFNE || op == JSOP_OR)
|
||||
? Assembler::NonZero
|
||||
: Assembler::Zero;
|
||||
Assembler::Condition ncond = (op == JSOP_OR)
|
||||
Assembler::Condition ncond = (op == JSOP_IFNE || op == JSOP_OR)
|
||||
? Assembler::Zero
|
||||
: Assembler::NonZero;
|
||||
|
||||
@ -887,6 +873,49 @@ mjit::Compiler::jsop_andor(JSOp op, jsbytecode *target)
|
||||
frame.pop();
|
||||
}
|
||||
|
||||
void
|
||||
mjit::Compiler::jsop_ifneq(JSOp op, jsbytecode *target)
|
||||
{
|
||||
FrameEntry *fe = frame.peek(-1);
|
||||
|
||||
if (fe->isConstant()) {
|
||||
JSBool b = js_ValueToBoolean(fe->getValue());
|
||||
|
||||
if (op == JSOP_IFEQ)
|
||||
b = !b;
|
||||
if (b) {
|
||||
frame.forgetEverything();
|
||||
jumpInScript(masm.jump(), target);
|
||||
}
|
||||
frame.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
booleanJumpScript(op, target);
|
||||
}
|
||||
|
||||
void
|
||||
mjit::Compiler::jsop_andor(JSOp op, jsbytecode *target)
|
||||
{
|
||||
FrameEntry *fe = frame.peek(-1);
|
||||
|
||||
if (fe->isConstant()) {
|
||||
JSBool b = js_ValueToBoolean(fe->getValue());
|
||||
|
||||
/* Short-circuit. */
|
||||
if ((op == JSOP_OR && b == JS_TRUE) ||
|
||||
(op == JSOP_AND && b == JS_FALSE)) {
|
||||
frame.forgetEverything();
|
||||
jumpInScript(masm.jump(), target);
|
||||
}
|
||||
|
||||
frame.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
booleanJumpScript(op, target);
|
||||
}
|
||||
|
||||
void
|
||||
mjit::Compiler::jsop_localinc(JSOp op, uint32 slot, bool popped)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user