Bug 1171945: IonMonkey - Part 4: Make changes to BinaryArith to work with ionmonkey, r=jandem

This commit is contained in:
Hannes Verschore 2015-08-19 15:15:52 +02:00
parent 40561aafdd
commit ee5c073336
6 changed files with 65 additions and 42 deletions

View File

@ -1612,7 +1612,7 @@ BaselineCompiler::emitBinaryArith()
frame.popRegsAndSync(2);
// Call IC
ICBinaryArith_Fallback::Compiler stubCompiler(cx);
ICBinaryArith_Fallback::Compiler stubCompiler(cx, ICStubCompiler::Engine::Baseline);
if (!emitOpIC(stubCompiler.getStub(&stubSpace_)))
return false;

View File

@ -49,14 +49,6 @@ namespace jit {
\
_(ToNumber_Fallback) \
\
_(BinaryArith_Fallback) \
_(BinaryArith_Int32) \
_(BinaryArith_Double) \
_(BinaryArith_StringConcat) \
_(BinaryArith_StringObjectConcat) \
_(BinaryArith_BooleanWithInt32) \
_(BinaryArith_DoubleWithInt32) \
\
_(UnaryArith_Fallback) \
_(UnaryArith_Int32) \
_(UnaryArith_Double) \

View File

@ -1712,6 +1712,13 @@ CodeGenerator::visitBinarySharedStub(LBinarySharedStub* lir)
{
JSOp jsop = JSOp(*lir->mir()->resumePoint()->pc());
switch (jsop) {
case JSOP_ADD:
case JSOP_SUB:
case JSOP_MUL:
case JSOP_DIV:
case JSOP_MOD:
emitSharedStub(ICStub::Kind::BinaryArith_Fallback, lir);
break;
default:
MOZ_CRASH("Unsupported jsop in shared stubs.");
}
@ -7851,6 +7858,11 @@ CodeGenerator::linkSharedStubs(JSContext* cx)
ICStub *stub = nullptr;
switch (sharedStubs_[i].kind) {
case ICStub::Kind::BinaryArith_Fallback: {
ICBinaryArith_Fallback::Compiler stubCompiler(cx, ICStubCompiler::Engine::IonMonkey);
stub = stubCompiler.getStub(&stubSpace_);
break;
}
default:
MOZ_CRASH("Unsupported shared stub.");
}

View File

@ -832,6 +832,23 @@ ICStubCompiler::emitPostWriteBarrierSlot(MacroAssembler& masm, Register obj, Val
return true;
}
static ICStubCompiler::Engine
SharedStubEngine(BaselineFrame* frame)
{
return frame ? ICStubCompiler::Engine::Baseline : ICStubCompiler::Engine::IonMonkey;
}
static JSScript*
SharedStubScript(BaselineFrame* frame, ICFallbackStub* stub)
{
ICStubCompiler::Engine engine = SharedStubEngine(frame);
if (engine == ICStubCompiler::Engine::Baseline)
return frame->script();
IonICEntry* entry = (IonICEntry*) stub->icEntry();
return entry->script();
}
//
// BinaryArith_Fallback
//
@ -840,10 +857,12 @@ static bool
DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame, ICBinaryArith_Fallback* stub_,
HandleValue lhs, HandleValue rhs, MutableHandleValue ret)
{
ICStubCompiler::Engine engine = SharedStubEngine(frame);
RootedScript script(cx, SharedStubScript(frame, stub_));
// This fallback stub may trigger debug mode toggling.
DebugModeOSRVolatileStub<ICBinaryArith_Fallback*> stub(frame, stub_);
RootedScript script(cx, frame->script());
jsbytecode* pc = stub->icEntry()->pc(script);
JSOp op = JSOp(*pc);
FallbackICSpew(cx, stub, "BinaryArith(%s,%d,%d)", js_CodeName[op],
@ -944,7 +963,7 @@ DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame, ICBinaryArith_Fallbac
if (lhs.isString() && rhs.isString()) {
JitSpew(JitSpew_BaselineIC, " Generating %s(String, String) stub", js_CodeName[op]);
MOZ_ASSERT(ret.isString());
ICBinaryArith_StringConcat::Compiler compiler(cx);
ICBinaryArith_StringConcat::Compiler compiler(cx, engine);
ICStub* strcatStub = compiler.getStub(compiler.getStubSpace(script));
if (!strcatStub)
return false;
@ -957,7 +976,7 @@ DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame, ICBinaryArith_Fallbac
lhs.isString() ? "String" : "Object",
lhs.isString() ? "Object" : "String");
MOZ_ASSERT(ret.isString());
ICBinaryArith_StringObjectConcat::Compiler compiler(cx, lhs.isString());
ICBinaryArith_StringObjectConcat::Compiler compiler(cx, engine, lhs.isString());
ICStub* strcatStub = compiler.getStub(compiler.getStubSpace(script));
if (!strcatStub)
return false;
@ -973,7 +992,8 @@ DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame, ICBinaryArith_Fallbac
{
JitSpew(JitSpew_BaselineIC, " Generating %s(%s, %s) stub", js_CodeName[op],
lhs.isBoolean() ? "Boolean" : "Int32", rhs.isBoolean() ? "Boolean" : "Int32");
ICBinaryArith_BooleanWithInt32::Compiler compiler(cx, op, lhs.isBoolean(), rhs.isBoolean());
ICBinaryArith_BooleanWithInt32::Compiler compiler(cx, op, engine,
lhs.isBoolean(), rhs.isBoolean());
ICStub* arithStub = compiler.getStub(compiler.getStubSpace(script));
if (!arithStub)
return false;
@ -1003,7 +1023,7 @@ DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame, ICBinaryArith_Fallbac
stub->unlinkStubsWithKind(cx, ICStub::BinaryArith_Int32);
JitSpew(JitSpew_BaselineIC, " Generating %s(Double, Double) stub", js_CodeName[op]);
ICBinaryArith_Double::Compiler compiler(cx, op);
ICBinaryArith_Double::Compiler compiler(cx, op, engine);
ICStub* doubleStub = compiler.getStub(compiler.getStubSpace(script));
if (!doubleStub)
return false;
@ -1021,7 +1041,7 @@ DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame, ICBinaryArith_Fallbac
stub->unlinkStubsWithKind(cx, ICStub::BinaryArith_Int32);
JitSpew(JitSpew_BaselineIC, " Generating %s(Int32, Int32%s) stub", js_CodeName[op],
allowDouble ? " => Double" : "");
ICBinaryArith_Int32::Compiler compilerInt32(cx, op, allowDouble);
ICBinaryArith_Int32::Compiler compilerInt32(cx, op, engine, allowDouble);
ICStub* int32Stub = compilerInt32.getStub(compilerInt32.getStubSpace(script));
if (!int32Stub)
return false;
@ -1040,7 +1060,7 @@ DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame, ICBinaryArith_Fallbac
JitSpew(JitSpew_BaselineIC, " Generating %s(%s, %s) stub", js_CodeName[op],
lhs.isDouble() ? "Double" : "Int32",
lhs.isDouble() ? "Int32" : "Double");
ICBinaryArith_DoubleWithInt32::Compiler compiler(cx, op, lhs.isDouble());
ICBinaryArith_DoubleWithInt32::Compiler compiler(cx, op, engine, lhs.isDouble());
ICStub* optStub = compiler.getStub(compiler.getStubSpace(script));
if (!optStub)
return false;
@ -1064,7 +1084,6 @@ static const VMFunction DoBinaryArithFallbackInfo =
bool
ICBinaryArith_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
{
MOZ_ASSERT(engine_ == Engine::Baseline);
MOZ_ASSERT(R0 == JSReturnOperand);
// Restore the tail call register.
@ -1100,8 +1119,6 @@ static const VMFunction DoConcatStringsInfo = FunctionInfo<DoConcatStringsFn>(Do
bool
ICBinaryArith_StringConcat::Compiler::generateStubCode(MacroAssembler& masm)
{
MOZ_ASSERT(engine_ == Engine::Baseline);
Label failure;
masm.branchTestString(Assembler::NotEqual, R0, &failure);
masm.branchTestString(Assembler::NotEqual, R1, &failure);
@ -1182,8 +1199,6 @@ static const VMFunction DoConcatStringObjectInfo =
bool
ICBinaryArith_StringObjectConcat::Compiler::generateStubCode(MacroAssembler& masm)
{
MOZ_ASSERT(engine_ == Engine::Baseline);
Label failure;
if (lhsIsString_) {
masm.branchTestString(Assembler::NotEqual, R0, &failure);
@ -1216,8 +1231,6 @@ ICBinaryArith_StringObjectConcat::Compiler::generateStubCode(MacroAssembler& mas
bool
ICBinaryArith_Double::Compiler::generateStubCode(MacroAssembler& masm)
{
MOZ_ASSERT(engine_ == Engine::Baseline);
Label failure;
masm.ensureDouble(R0, FloatReg0, &failure);
masm.ensureDouble(R1, FloatReg1, &failure);
@ -1258,8 +1271,6 @@ ICBinaryArith_Double::Compiler::generateStubCode(MacroAssembler& masm)
bool
ICBinaryArith_BooleanWithInt32::Compiler::generateStubCode(MacroAssembler& masm)
{
MOZ_ASSERT(engine_ == Engine::Baseline);
Label failure;
if (lhsIsBool_)
masm.branchTestBoolean(Assembler::NotEqual, R0, &failure);
@ -1335,7 +1346,6 @@ ICBinaryArith_BooleanWithInt32::Compiler::generateStubCode(MacroAssembler& masm)
bool
ICBinaryArith_DoubleWithInt32::Compiler::generateStubCode(MacroAssembler& masm)
{
MOZ_ASSERT(engine_ == Engine::Baseline);
MOZ_ASSERT(op == JSOP_BITOR || op == JSOP_BITAND || op == JSOP_BITXOR);
Label failure;
@ -1398,5 +1408,6 @@ ICBinaryArith_DoubleWithInt32::Compiler::generateStubCode(MacroAssembler& masm)
}
} // namespace jit
} // namespace js

View File

@ -1116,7 +1116,7 @@ class ICMultiStubCompiler : public ICStubCompiler
};
// BinaryArith
// JSOP_ADD
// JSOP_ADD, JSOP_SUB, JSOP_MUL, JOP_DIV, JSOP_MOD
// JSOP_BITAND, JSOP_BITXOR, JSOP_BITOR
// JSOP_LSH, JSOP_RSH, JSOP_URSH
@ -1155,8 +1155,8 @@ class ICBinaryArith_Fallback : public ICFallbackStub
bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
: ICStubCompiler(cx, ICStub::BinaryArith_Fallback, Engine::Baseline) {}
explicit Compiler(JSContext* cx, Engine engine)
: ICStubCompiler(cx, ICStub::BinaryArith_Fallback, engine) {}
ICStub* getStub(ICStubSpace* space) {
return newStub<ICBinaryArith_Fallback>(space, getStubCode());
@ -1196,8 +1196,8 @@ class ICBinaryArith_Int32 : public ICStub
}
public:
Compiler(JSContext* cx, JSOp op, bool allowDouble)
: ICStubCompiler(cx, ICStub::BinaryArith_Int32, Engine::Baseline),
Compiler(JSContext* cx, JSOp op, Engine engine, bool allowDouble)
: ICStubCompiler(cx, ICStub::BinaryArith_Int32, engine),
op_(op), allowDouble_(allowDouble) {}
ICStub* getStub(ICStubSpace* space) {
@ -1220,8 +1220,8 @@ class ICBinaryArith_StringConcat : public ICStub
bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
: ICStubCompiler(cx, ICStub::BinaryArith_StringConcat, Engine::Baseline)
explicit Compiler(JSContext* cx, Engine engine)
: ICStubCompiler(cx, ICStub::BinaryArith_StringConcat, engine)
{}
ICStub* getStub(ICStubSpace* space) {
@ -1257,8 +1257,8 @@ class ICBinaryArith_StringObjectConcat : public ICStub
}
public:
Compiler(JSContext* cx, bool lhsIsString)
: ICStubCompiler(cx, ICStub::BinaryArith_StringObjectConcat, Engine::Baseline),
Compiler(JSContext* cx, Engine engine, bool lhsIsString)
: ICStubCompiler(cx, ICStub::BinaryArith_StringObjectConcat, engine),
lhsIsString_(lhsIsString)
{}
@ -1283,8 +1283,8 @@ class ICBinaryArith_Double : public ICStub
bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op)
: ICMultiStubCompiler(cx, ICStub::BinaryArith_Double, op, Engine::Baseline)
Compiler(JSContext* cx, JSOp op, Engine engine)
: ICMultiStubCompiler(cx, ICStub::BinaryArith_Double, op, engine)
{}
ICStub* getStub(ICStubSpace* space) {
@ -1333,8 +1333,8 @@ class ICBinaryArith_BooleanWithInt32 : public ICStub
}
public:
Compiler(JSContext* cx, JSOp op, bool lhsIsBool, bool rhsIsBool)
: ICStubCompiler(cx, ICStub::BinaryArith_BooleanWithInt32, Engine::Baseline),
Compiler(JSContext* cx, JSOp op, Engine engine, bool lhsIsBool, bool rhsIsBool)
: ICStubCompiler(cx, ICStub::BinaryArith_BooleanWithInt32, engine),
op_(op), lhsIsBool_(lhsIsBool), rhsIsBool_(rhsIsBool)
{
MOZ_ASSERT(op_ == JSOP_ADD || op_ == JSOP_SUB || op_ == JSOP_BITOR ||
@ -1377,8 +1377,8 @@ class ICBinaryArith_DoubleWithInt32 : public ICStub
}
public:
Compiler(JSContext* cx, JSOp op, bool lhsIsDouble)
: ICMultiStubCompiler(cx, ICStub::BinaryArith_DoubleWithInt32, op, Engine::Baseline),
Compiler(JSContext* cx, JSOp op, Engine engine, bool lhsIsDouble)
: ICMultiStubCompiler(cx, ICStub::BinaryArith_DoubleWithInt32, op, engine),
lhsIsDouble_(lhsIsDouble)
{}

View File

@ -11,7 +11,15 @@ namespace js {
namespace jit {
// List of IC stub kinds that can run in Baseline and in IonMonkey
#define IC_SHARED_STUB_KIND_LIST(_)
#define IC_SHARED_STUB_KIND_LIST(_) \
_(BinaryArith_Fallback) \
_(BinaryArith_Int32) \
_(BinaryArith_Double) \
_(BinaryArith_StringConcat) \
_(BinaryArith_StringObjectConcat) \
_(BinaryArith_BooleanWithInt32) \
_(BinaryArith_DoubleWithInt32) \
\
} // namespace jit
} // namespace js