Bug 883748 - Specialize MUrsh as double if needed. r=bhackett

This commit is contained in:
Jan de Mooij 2013-06-18 13:44:01 +02:00
parent 8d08a9c8e1
commit cba41605d1
6 changed files with 29 additions and 18 deletions

View File

@ -2549,9 +2549,10 @@ DoBinaryArithFallback(JSContext *cx, BaselineFrame *frame, ICBinaryArith_Fallbac
}
}
// TODO: unlink previous !allowDouble stub.
if (lhs.isInt32() && rhs.isInt32()) {
bool allowDouble = ret.isDouble();
if (allowDouble)
stub->unlinkStubsWithKind(cx, ICStub::BinaryArith_Int32);
IonSpew(IonSpew_BaselineIC, " Generating %s(Int32, Int32%s) stub", js_CodeName[op],
allowDouble ? " => Double" : "");
ICBinaryArith_Int32::Compiler compilerInt32(cx, op, allowDouble);

View File

@ -2405,14 +2405,20 @@ class ICBinaryArith_Int32 : public ICStub
{
friend class ICStubSpace;
ICBinaryArith_Int32(IonCode *stubCode)
: ICStub(BinaryArith_Int32, stubCode) {}
ICBinaryArith_Int32(IonCode *stubCode, bool allowDouble)
: ICStub(BinaryArith_Int32, stubCode)
{
extra_ = allowDouble;
}
public:
static inline ICBinaryArith_Int32 *New(ICStubSpace *space, IonCode *code) {
static inline ICBinaryArith_Int32 *New(ICStubSpace *space, IonCode *code, bool allowDouble) {
if (!code)
return NULL;
return space->allocate<ICBinaryArith_Int32>(code);
return space->allocate<ICBinaryArith_Int32>(code, allowDouble);
}
bool allowDouble() const {
return extra_;
}
// Compiler for this stub kind.
@ -2435,7 +2441,7 @@ class ICBinaryArith_Int32 : public ICStub
op_(op), allowDouble_(allowDouble) {}
ICStub *getStub(ICStubSpace *space) {
return ICBinaryArith_Int32::New(space, getStubCode());
return ICBinaryArith_Int32::New(space, getStubCode(), allowDouble_);
}
};
};

View File

@ -160,6 +160,9 @@ BaselineInspector::expectedResultType(jsbytecode *pc)
switch (stub->kind()) {
case ICStub::BinaryArith_Int32:
if (stub->toBinaryArith_Int32()->allowDouble())
return MIRType_Double;
return MIRType_Int32;
case ICStub::BinaryArith_BooleanWithInt32:
case ICStub::UnaryArith_Int32:
return MIRType_Int32;

View File

@ -3264,7 +3264,7 @@ IonBuilder::jsop_bitop(JSOp op)
}
current->add(ins);
ins->infer();
ins->infer(inspector, pc);
current->push(ins);
if (ins->isEffectful() && !resumeAfter(ins))
@ -6469,7 +6469,7 @@ IonBuilder::convertShiftToMaskForStaticTypedArray(MDefinition *id,
MConstant *mask = MConstant::New(Int32Value(~((1 << value.toInt32()) - 1)));
MBitAnd *ptr = MBitAnd::New(id->getOperand(0), mask);
ptr->infer();
ptr->infer(NULL, NULL);
JS_ASSERT(!ptr->isEffectful());
current->add(mask);

View File

@ -919,7 +919,7 @@ MBinaryBitwiseInstruction::foldUnnecessaryBitop()
}
void
MBinaryBitwiseInstruction::infer()
MBinaryBitwiseInstruction::infer(BaselineInspector *, jsbytecode *)
{
if (getOperand(0)->mightBeType(MIRType_Object) || getOperand(1)->mightBeType(MIRType_Object)) {
specialization_ = MIRType_None;
@ -938,7 +938,7 @@ MBinaryBitwiseInstruction::specializeForAsmJS()
}
void
MShiftInstruction::infer()
MShiftInstruction::infer(BaselineInspector *, jsbytecode *)
{
if (getOperand(0)->mightBeType(MIRType_Object) || getOperand(1)->mightBeType(MIRType_Object))
specialization_ = MIRType_None;
@ -947,7 +947,7 @@ MShiftInstruction::infer()
}
void
MUrsh::infer()
MUrsh::infer(BaselineInspector *inspector, jsbytecode *pc)
{
if (getOperand(0)->mightBeType(MIRType_Object) || getOperand(1)->mightBeType(MIRType_Object)) {
specialization_ = MIRType_None;
@ -955,13 +955,14 @@ MUrsh::infer()
return;
}
if (type() == MIRType_Int32) {
specialization_ = MIRType_Int32;
if (inspector->expectedResultType(pc) == MIRType_Double) {
specialization_ = MIRType_Double;
setResultType(MIRType_Double);
return;
}
specialization_ = MIRType_Double;
setResultType(MIRType_Double);
specialization_ = MIRType_Int32;
setResultType(MIRType_Int32);
}
static inline bool

View File

@ -2716,7 +2716,7 @@ class MBinaryBitwiseInstruction
virtual MDefinition *foldIfZero(size_t operand) = 0;
virtual MDefinition *foldIfNegOne(size_t operand) = 0;
virtual MDefinition *foldIfEqual() = 0;
virtual void infer();
virtual void infer(BaselineInspector *inspector, jsbytecode *pc);
bool congruentTo(MDefinition *const &ins) const {
return congruentIfOperandsEqual(ins);
@ -2812,7 +2812,7 @@ class MShiftInstruction
MDefinition *foldIfEqual() {
return this;
}
virtual void infer();
virtual void infer(BaselineInspector *inspector, jsbytecode *pc);
};
class MLsh : public MShiftInstruction
@ -2876,7 +2876,7 @@ class MUrsh : public MShiftInstruction
return this;
}
void infer();
void infer(BaselineInspector *inspector, jsbytecode *pc);
bool canOverflow() {
// solution is only negative when lhs < 0 and rhs & 0x1f == 0