зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1438727: [Part 3] Implement ADD+SUB for Boolean + Double|Int32 r=jandem
--HG-- extra : rebase_source : 692d2222bc661d40f979528bf202c785802c6f09
This commit is contained in:
Родитель
632acc28d1
Коммит
735ced9223
|
@ -5108,6 +5108,8 @@ BinaryArithIRGenerator::tryAttachStub()
|
|||
return true;
|
||||
if (tryAttachDouble())
|
||||
return true;
|
||||
if (tryAttachBooleanWithInt32())
|
||||
return true;
|
||||
|
||||
trackAttached(IRGenerator::NotAttached);
|
||||
return false;
|
||||
|
@ -5178,3 +5180,39 @@ BinaryArithIRGenerator::tryAttachInt32()
|
|||
writer.returnFromIC();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BinaryArithIRGenerator::tryAttachBooleanWithInt32()
|
||||
{
|
||||
if (op_ != JSOP_ADD && op_ != JSOP_SUB)
|
||||
return false;
|
||||
|
||||
if (!(lhs_.isBoolean() && (rhs_.isBoolean() || rhs_.isInt32())) &&
|
||||
!(rhs_.isBoolean() && (lhs_.isBoolean() || lhs_.isInt32())))
|
||||
return false;
|
||||
|
||||
|
||||
ValOperandId lhsId(writer.setInputOperandId(0));
|
||||
ValOperandId rhsId(writer.setInputOperandId(1));
|
||||
|
||||
Int32OperandId lhsIntId = (lhs_.isBoolean() ? writer.guardIsBoolean(lhsId)
|
||||
: writer.guardIsInt32(lhsId));
|
||||
Int32OperandId rhsIntId = (rhs_.isBoolean() ? writer.guardIsBoolean(rhsId)
|
||||
: writer.guardIsInt32(rhsId));
|
||||
|
||||
switch (op_) {
|
||||
case JSOP_ADD:
|
||||
writer.int32AddResult(lhsIntId, rhsIntId);
|
||||
trackAttached("BinaryArith.BooleanInt32.Add");
|
||||
break;
|
||||
case JSOP_SUB:
|
||||
writer.int32SubResult(lhsIntId, rhsIntId);
|
||||
trackAttached("BinaryArith.BooleanInt32.Sub");
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Unhandled op in tryAttachInt32");
|
||||
}
|
||||
|
||||
writer.returnFromIC();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -182,6 +182,7 @@ extern const char* CacheKindNames[];
|
|||
_(GuardIsObject) \
|
||||
_(GuardIsObjectOrNull) \
|
||||
_(GuardIsNullOrUndefined) \
|
||||
_(GuardIsBoolean) \
|
||||
_(GuardIsString) \
|
||||
_(GuardIsSymbol) \
|
||||
_(GuardIsNumber) \
|
||||
|
@ -545,6 +546,12 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter
|
|||
writeOpWithOperandId(CacheOp::GuardIsObject, val);
|
||||
return ObjOperandId(val.id());
|
||||
}
|
||||
Int32OperandId guardIsBoolean(ValOperandId val) {
|
||||
Int32OperandId res(nextOperandId_++);
|
||||
writeOpWithOperandId(CacheOp::GuardIsBoolean, val);
|
||||
writeOperandId(res);
|
||||
return res;
|
||||
}
|
||||
StringOperandId guardIsString(ValOperandId val) {
|
||||
writeOpWithOperandId(CacheOp::GuardIsString, val);
|
||||
return StringOperandId(val.id());
|
||||
|
@ -1809,6 +1816,7 @@ class MOZ_RAII BinaryArithIRGenerator : public IRGenerator
|
|||
|
||||
bool tryAttachInt32();
|
||||
bool tryAttachDouble();
|
||||
bool tryAttachBooleanWithInt32();
|
||||
|
||||
public:
|
||||
BinaryArithIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc, ICState::Mode,
|
||||
|
|
|
@ -1384,6 +1384,28 @@ CacheIRCompiler::emitGuardIsObjectOrNull()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CacheIRCompiler::emitGuardIsBoolean()
|
||||
{
|
||||
ValOperandId inputId = reader.valOperandId();
|
||||
Register output = allocator.defineRegister(masm, reader.int32OperandId());
|
||||
|
||||
if (allocator.knownType(inputId) == JSVAL_TYPE_BOOLEAN) {
|
||||
Register input = allocator.useRegister(masm, Int32OperandId(inputId.id()));
|
||||
masm.move32(input, output);
|
||||
return true;
|
||||
}
|
||||
ValueOperand input = allocator.useValueRegister(masm, inputId);
|
||||
|
||||
FailurePath* failure;
|
||||
if (!addFailurePath(&failure))
|
||||
return false;
|
||||
|
||||
masm.branchTestBoolean(Assembler::NotEqual, input, failure->label());
|
||||
masm.unboxBoolean(input, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CacheIRCompiler::emitGuardIsString()
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace jit {
|
|||
_(GuardIsObject) \
|
||||
_(GuardIsNullOrUndefined) \
|
||||
_(GuardIsObjectOrNull) \
|
||||
_(GuardIsBoolean) \
|
||||
_(GuardIsString) \
|
||||
_(GuardIsSymbol) \
|
||||
_(GuardIsNumber) \
|
||||
|
|
Загрузка…
Ссылка в новой задаче