Bug 862103 - Address review comments, r=jandem.

This commit is contained in:
Brian Hackett 2013-04-18 07:39:33 -06:00
parent 598edcfbee
commit 220a7d9c7f
3 changed files with 32 additions and 27 deletions

View File

@ -120,3 +120,28 @@ BaselineInspector::expectedResultType(jsbytecode *pc)
return MIRType_None; return MIRType_None;
} }
} }
// Whether a baseline stub kind is suitable for a double comparison that
// converts its operands to doubles.
static bool
CanUseDoubleCompare(ICStub::Kind kind)
{
return kind == ICStub::Compare_Double || kind == ICStub::Compare_NumberWithUndefined;
}
MCompare::CompareType
BaselineInspector::expectedCompareType(jsbytecode *pc)
{
ICStub::Kind kind = monomorphicStubKind(pc);
if (CanUseDoubleCompare(kind))
return MCompare::Compare_Double;
ICStub::Kind first, second;
if (dimorphicStubKind(pc, &first, &second)) {
if (CanUseDoubleCompare(first) && CanUseDoubleCompare(second))
return MCompare::Compare_Double;
}
return MCompare::Compare_Unknown;
}

View File

@ -13,6 +13,7 @@
#include "BaselineJIT.h" #include "BaselineJIT.h"
#include "BaselineIC.h" #include "BaselineIC.h"
#include "MIR.h"
namespace js { namespace js {
namespace ion { namespace ion {
@ -89,6 +90,9 @@ class BaselineInspector
return ICInspectorType(this, pc, ent); return ICInspectorType(this, pc, ent);
} }
ICStub::Kind monomorphicStubKind(jsbytecode *pc);
bool dimorphicStubKind(jsbytecode *pc, ICStub::Kind *pfirst, ICStub::Kind *psecond);
public: public:
RawShape maybeMonomorphicShapeForPropertyOp(jsbytecode *pc); RawShape maybeMonomorphicShapeForPropertyOp(jsbytecode *pc);
@ -96,10 +100,8 @@ class BaselineInspector
return makeICInspector<SetElemICInspector>(pc, ICStub::SetElem_Fallback); return makeICInspector<SetElemICInspector>(pc, ICStub::SetElem_Fallback);
} }
ICStub::Kind monomorphicStubKind(jsbytecode *pc);
bool dimorphicStubKind(jsbytecode *pc, ICStub::Kind *pfirst, ICStub::Kind *psecond);
MIRType expectedResultType(jsbytecode *pc); MIRType expectedResultType(jsbytecode *pc);
MCompare::CompareType expectedCompareType(jsbytecode *pc);
}; };
} // namespace ion } // namespace ion

View File

@ -1383,14 +1383,6 @@ MCompare::inputType()
} }
} }
// Whether a baseline stub kind is suitable for a double comparison that
// converts its operands to doubles.
static bool
CanUseDoubleCompare(ICStub::Kind kind)
{
return kind == ICStub::Compare_Double || kind == ICStub::Compare_NumberWithUndefined;
}
void void
MCompare::infer(JSContext *cx, BaselineInspector *inspector, jsbytecode *pc) MCompare::infer(JSContext *cx, BaselineInspector *inspector, jsbytecode *pc)
{ {
@ -1505,22 +1497,8 @@ MCompare::infer(JSContext *cx, BaselineInspector *inspector, jsbytecode *pc)
// instruction's type policy to insert fallible unboxes to the appropriate // instruction's type policy to insert fallible unboxes to the appropriate
// input types. // input types.
if (!strictEq) { if (!strictEq)
ICStub::Kind kind = inspector->monomorphicStubKind(pc); compareType_ = inspector->expectedCompareType(pc);
if (CanUseDoubleCompare(kind)) {
compareType_ = Compare_Double;
return;
}
ICStub::Kind first, second;
if (inspector->dimorphicStubKind(pc, &first, &second)) {
if (CanUseDoubleCompare(first) && CanUseDoubleCompare(second)) {
compareType_ = Compare_Double;
return;
}
}
}
} }
MBitNot * MBitNot *