Support pre-SSE2 CPUs in JaegerMonkey (bug 696291, r=bhackett).

--HG--
extra : rebase_source : f1f6a1e60b05974533ff39292a0a278fc69fbb0f
This commit is contained in:
David Anderson 2012-01-13 13:33:56 -08:00
Родитель d0b8307cdc
Коммит 3de3a194ba
7 изменённых файлов: 134 добавлений и 76 удалений

Просмотреть файл

@ -1678,13 +1678,7 @@ void
JSContext::updateJITEnabled()
{
#ifdef JS_METHODJIT
methodJitEnabled = (runOptions & JSOPTION_METHODJIT) &&
!IsJITBrokenHere()
# if defined JS_CPU_X86 || defined JS_CPU_X64
&& JSC::MacroAssemblerX86Common::getSSEState() >=
JSC::MacroAssemblerX86Common::HasSSE2
# endif
;
methodJitEnabled = (runOptions & JSOPTION_METHODJIT) && !IsJITBrokenHere();
#endif
}

Просмотреть файл

@ -59,6 +59,9 @@
#include "js/MemoryMetrics.h"
#include "methodjit/MethodJIT.h"
#include "methodjit/Retcon.h"
#ifdef JS_METHODJIT
# include "assembler/assembler/MacroAssembler.h"
#endif
#include "jsatominlines.h"
#include "jsgcinlines.h"
@ -1961,9 +1964,14 @@ TypeCompartment::init(JSContext *cx)
{
PodZero(this);
if (cx && cx->getRunOptions() & JSOPTION_TYPE_INFERENCE)
if (cx && cx->getRunOptions() & JSOPTION_TYPE_INFERENCE) {
#ifdef JS_METHODJIT
JSC::MacroAssembler masm;
if (masm.supportsFloatingPoint())
#endif
inferenceEnabled = true;
}
}
TypeObject *
TypeCompartment::newTypeObject(JSContext *cx, JSScript *script,

Просмотреть файл

@ -638,6 +638,7 @@ private:
bool jsop_tableswitch(jsbytecode *pc);
/* Fast arithmetic. */
bool jsop_binary_slow(JSOp op, VoidStub stub, JSValueType type, FrameEntry *lhs, FrameEntry *rhs);
bool jsop_binary(JSOp op, VoidStub stub, JSValueType type, types::TypeSet *typeSet);
void jsop_binary_full(FrameEntry *lhs, FrameEntry *rhs, JSOp op, VoidStub stub,
JSValueType type, bool cannotOverflow, bool ignoreOverflow);

Просмотреть файл

@ -175,6 +175,21 @@ mjit::Compiler::maybeJumpIfNotDouble(Assembler &masm, MaybeJump &mj, FrameEntry
}
}
bool
mjit::Compiler::jsop_binary_slow(JSOp op, VoidStub stub, JSValueType type,
FrameEntry *lhs, FrameEntry *rhs)
{
bool isStringResult = (op == JSOP_ADD) &&
(lhs->isType(JSVAL_TYPE_STRING) || rhs->isType(JSVAL_TYPE_STRING));
JS_ASSERT_IF(isStringResult && type != JSVAL_TYPE_UNKNOWN, type == JSVAL_TYPE_STRING);
prepareStubCall(Uses(2));
INLINE_STUBCALL(stub, REJOIN_BINARY);
frame.popn(2);
frame.pushSynced(isStringResult ? JSVAL_TYPE_STRING : type);
return true;
}
bool
mjit::Compiler::jsop_binary(JSOp op, VoidStub stub, JSValueType type, types::TypeSet *typeSet)
{
@ -205,16 +220,7 @@ mjit::Compiler::jsop_binary(JSOp op, VoidStub stub, JSValueType type, types::Typ
(lhs->isTypeKnown() && (lhs->getKnownType() > JSVAL_UPPER_INCL_TYPE_OF_NUMBER_SET)) ||
(rhs->isTypeKnown() && (rhs->getKnownType() > JSVAL_UPPER_INCL_TYPE_OF_NUMBER_SET)))
{
bool isStringResult = (op == JSOP_ADD) &&
(lhs->isType(JSVAL_TYPE_STRING) ||
rhs->isType(JSVAL_TYPE_STRING));
JS_ASSERT_IF(isStringResult && type != JSVAL_TYPE_UNKNOWN, type == JSVAL_TYPE_STRING);
prepareStubCall(Uses(2));
INLINE_STUBCALL(stub, REJOIN_BINARY);
frame.popn(2);
frame.pushSynced(isStringResult ? JSVAL_TYPE_STRING : type);
return true;
return jsop_binary_slow(op, stub, type, lhs, rhs);
}
/*
@ -238,6 +244,9 @@ mjit::Compiler::jsop_binary(JSOp op, VoidStub stub, JSValueType type, types::Typ
bool canDoIntMath = op != JSOP_DIV && type != JSVAL_TYPE_DOUBLE &&
!(rhs->isType(JSVAL_TYPE_DOUBLE) || lhs->isType(JSVAL_TYPE_DOUBLE));
if (!masm.supportsFloatingPoint() && (!canDoIntMath || frame.haveSameBacking(lhs, rhs)))
return jsop_binary_slow(op, stub, type, lhs, rhs);
if (canDoIntMath)
jsop_binary_full(lhs, rhs, op, stub, type, cannotOverflow, ignoreOverflow);
else
@ -572,7 +581,7 @@ mjit::Compiler::jsop_binary_full(FrameEntry *lhs, FrameEntry *rhs, JSOp op,
/* Perform the double addition. */
MaybeJump doublePathDone;
if (!rhs->isTypeKnown() || lhsUnknownDone.isSet()) {
if (masm.supportsFloatingPoint() && (!rhs->isTypeKnown() || !lhs->isTypeKnown())) {
/* If the LHS type was not known, link its path here. */
if (lhsUnknownDone.isSet())
lhsUnknownDone.get().linkTo(stubcc.masm.label(), &stubcc.masm);
@ -790,7 +799,9 @@ mjit::Compiler::jsop_neg()
FrameEntry *fe = frame.peek(-1);
JSValueType type = knownPushedType(0);
if (fe->isTypeKnown() && fe->getKnownType() > JSVAL_UPPER_INCL_TYPE_OF_NUMBER_SET) {
if ((fe->isTypeKnown() && fe->getKnownType() > JSVAL_UPPER_INCL_TYPE_OF_NUMBER_SET) ||
!masm.supportsFloatingPoint())
{
prepareStubCall(Uses(1));
INLINE_STUBCALL(stubs::Neg, REJOIN_FALLTHROUGH);
frame.pop();
@ -802,7 +813,8 @@ mjit::Compiler::jsop_neg()
/* Handle negation of a known double, or of a known integer which has previously overflowed. */
if (fe->isType(JSVAL_TYPE_DOUBLE) ||
(fe->isType(JSVAL_TYPE_INT32) && type == JSVAL_TYPE_DOUBLE)) {
(fe->isType(JSVAL_TYPE_INT32) && type == JSVAL_TYPE_DOUBLE))
{
FPRegisterID fpreg;
if (fe->isType(JSVAL_TYPE_DOUBLE)) {
fpreg = frame.tempFPRegForData(fe);
@ -1309,6 +1321,11 @@ mjit::Compiler::emitLeftDoublePath(FrameEntry *lhs, FrameEntry *rhs, FrameState:
Jump lhsNotInt32 = masm.testInt32(Assembler::NotEqual, regs.lhsType.reg());
stubcc.linkExitDirect(lhsNotInt32, stubcc.masm.label());
if (!masm.supportsFloatingPoint()) {
lhsNotDouble = stubcc.masm.jump();
return;
}
/* OOL path for LHS as a double - first test LHS is double. */
lhsNotDouble = stubcc.masm.testDouble(Assembler::NotEqual, regs.lhsType.reg());
@ -1354,6 +1371,11 @@ mjit::Compiler::emitRightDoublePath(FrameEntry *lhs, FrameEntry *rhs, FrameState
Jump notInt32 = masm.testInt32(Assembler::NotEqual, regs.rhsType.reg());
stubcc.linkExitDirect(notInt32, stubcc.masm.label());
if (!masm.supportsFloatingPoint()) {
rhsNotNumber2 = stubcc.masm.jump();
return;
}
/* Now test if RHS is a double. */
rhsNotNumber2 = stubcc.masm.testDouble(Assembler::NotEqual, regs.rhsType.reg());
@ -1571,7 +1593,7 @@ mjit::Compiler::jsop_relational_full(JSOp op, BoolStub stub, jsbytecode *target,
/* Both double paths will join here. */
bool hasDoublePath = false;
if (!rhs->isTypeKnown() || lhsUnknownDone.isSet())
if (masm.supportsFloatingPoint() && (!rhs->isTypeKnown() || !lhs->isTypeKnown()))
hasDoublePath = true;
/* Integer path - figure out the immutable side. */
@ -1612,6 +1634,7 @@ mjit::Compiler::jsop_relational_full(JSOp op, BoolStub stub, jsbytecode *target,
frame.sync(stubcc.masm, Uses(frame.frameSlots()));
doubleTest = stubcc.masm.branchDouble(dblCond, regs.lhsFP, regs.rhsFP);
doubleFall = stubcc.masm.jump();
}
/* Link all incoming slow paths to here. */
if (lhsNotDouble.isSet()) {
@ -1630,7 +1653,6 @@ mjit::Compiler::jsop_relational_full(JSOp op, BoolStub stub, jsbytecode *target,
frame.sync(stubcc.masm, Uses(frame.frameSlots()));
stubcc.leave();
OOL_STUBCALL(stub, REJOIN_BRANCH);
}
/* Forget the world, preserving data. */
frame.pinReg(cmpReg);
@ -1701,6 +1723,7 @@ mjit::Compiler::jsop_relational_full(JSOp op, BoolStub stub, jsbytecode *target,
stubcc.masm.move(Imm32(1), regs.result);
skip.linkTo(stubcc.masm.label(), &stubcc.masm);
doubleDone = stubcc.masm.jump();
}
/* Link all incoming slow paths to here. */
if (lhsNotDouble.isSet()) {
@ -1715,7 +1738,6 @@ mjit::Compiler::jsop_relational_full(JSOp op, BoolStub stub, jsbytecode *target,
frame.sync(stubcc.masm, Uses(2));
stubcc.leave();
OOL_STUBCALL(stub, REJOIN_FALLTHROUGH);
}
/* Get an integer comparison condition. */
Assembler::Condition i32Cond = GetCompareCondition(cmpOp, fused);

Просмотреть файл

@ -101,6 +101,7 @@ mjit::Compiler::ensureInteger(FrameEntry *fe, Uses uses)
frame.freeReg(fptemp);
frame.learnType(fe, JSVAL_TYPE_INT32, data);
} else if (!fe->isType(JSVAL_TYPE_INT32)) {
if (masm.supportsFloatingPoint()) {
FPRegisterID fptemp = frame.allocFPReg();
RegisterID typeReg = frame.tempRegForType(fe);
frame.pinReg(typeReg);
@ -123,6 +124,19 @@ mjit::Compiler::ensureInteger(FrameEntry *fe, Uses uses)
frame.freeReg(fptemp);
frame.learnType(fe, JSVAL_TYPE_INT32, dataReg);
} else {
RegisterID typeReg = frame.tempRegForType(fe);
frame.pinReg(typeReg);
RegisterID dataReg = frame.copyDataIntoReg(fe);
frame.unpinReg(typeReg);
Jump intGuard = masm.testInt32(Assembler::NotEqual, typeReg);
Label syncPath = stubcc.syncExitAndJump(uses);
stubcc.linkExitDirect(intGuard, syncPath);
frame.learnType(fe, JSVAL_TYPE_INT32, dataReg);
}
}
}
@ -562,6 +576,8 @@ mjit::Compiler::jsop_relational(JSOp op, BoolStub stub,
} else if (lhs->isType(JSVAL_TYPE_STRING) || rhs->isType(JSVAL_TYPE_STRING)) {
return emitStubCmpOp(stub, target, fused);
} else if (lhs->isType(JSVAL_TYPE_DOUBLE) || rhs->isType(JSVAL_TYPE_DOUBLE)) {
if (!masm.supportsFloatingPoint())
return emitStubCmpOp(stub, target, fused);
return jsop_relational_double(op, stub, target, fused);
} else if (cx->typeInferenceEnabled() &&
lhs->isType(JSVAL_TYPE_INT32) && rhs->isType(JSVAL_TYPE_INT32)) {

Просмотреть файл

@ -1530,11 +1530,13 @@ FrameState::merge(Assembler &masm, Changes changes) const
* do not require stub paths to always generate a double when needed.
* :FIXME: we check this on OOL stub calls, but not inline stub calls.
*/
if (cx->typeInferenceEnabled()) {
for (unsigned i = 0; i < changes.nchanges; i++) {
FrameEntry *fe = a->sp - 1 - i;
if (fe->isTracked() && fe->isType(JSVAL_TYPE_DOUBLE))
masm.ensureInMemoryDouble(addressOf(fe));
}
}
uint32_t mask = Registers::AvailAnyRegs & ~freeRegs.freeMask;
Registers search(mask);

Просмотреть файл

@ -2537,6 +2537,14 @@ GetElementIC::attachTypedArray(VMFrame &f, JSObject *obj, const Value &v, jsid i
: Int32Key::FromRegister(idRemat.dataReg());
JSObject *tarray = js::TypedArray::getTypedArray(obj);
if (!masm.supportsFloatingPoint() &&
(TypedArray::getType(tarray) == js::TypedArray::TYPE_FLOAT32 ||
TypedArray::getType(tarray) == js::TypedArray::TYPE_FLOAT64 ||
TypedArray::getType(tarray) == js::TypedArray::TYPE_UINT32))
{
return disable(cx, "fpu not supported");
}
MaybeRegisterID tempReg;
masm.loadFromTypedArray(TypedArray::getType(tarray), objReg, key, typeReg, objReg, tempReg);
@ -2829,6 +2837,13 @@ SetElementIC::attachTypedArray(VMFrame &f, JSObject *obj, int32_t key)
masm.loadPtr(Address(objReg, TypedArray::dataOffset()), objReg);
JSObject *tarray = js::TypedArray::getTypedArray(obj);
if (!masm.supportsFloatingPoint() &&
(TypedArray::getType(tarray) == js::TypedArray::TYPE_FLOAT32 ||
TypedArray::getType(tarray) == js::TypedArray::TYPE_FLOAT64))
{
return disable(cx, "fpu not supported");
}
int shift = js::TypedArray::slotWidth(obj);
if (hasConstantKey) {
Address addr(objReg, keyValue * shift);