зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1542740: Convert BinaryArithIRGenerator to use AttachDecision r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D27309 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4e2871b298
Коммит
f983238229
|
@ -5796,9 +5796,9 @@ bool DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame,
|
||||||
stub->setSawDoubleResult();
|
stub->setSawDoubleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
TryAttachStubOld<BinaryArithIRGenerator>("BinaryArith", cx, frame, stub,
|
TryAttachStub<BinaryArithIRGenerator>("BinaryArith", cx, frame, stub,
|
||||||
BaselineCacheIRStubKind::Regular, op,
|
BaselineCacheIRStubKind::Regular, op,
|
||||||
lhs, rhs, ret);
|
lhs, rhs, ret);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6257,58 +6257,45 @@ void BinaryArithIRGenerator::trackAttached(const char* name) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachStub() {
|
AttachDecision BinaryArithIRGenerator::tryAttachStub() {
|
||||||
AutoAssertNoPendingException aanpe(cx_);
|
AutoAssertNoPendingException aanpe(cx_);
|
||||||
// Arithmetic operations with Int32 operands
|
// Arithmetic operations with Int32 operands
|
||||||
if (tryAttachInt32()) {
|
TRY_ATTACH(tryAttachInt32());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Bitwise operations with Int32 operands
|
// Bitwise operations with Int32 operands
|
||||||
if (tryAttachBitwise()) {
|
TRY_ATTACH(tryAttachBitwise());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Arithmetic operations with Double operands. This needs to come after
|
// Arithmetic operations with Double operands. This needs to come after
|
||||||
// tryAttachInt32, as the guards overlap, and we'd prefer to attach the
|
// tryAttachInt32, as the guards overlap, and we'd prefer to attach the
|
||||||
// more specialized Int32 IC if it is possible.
|
// more specialized Int32 IC if it is possible.
|
||||||
if (tryAttachDouble()) {
|
TRY_ATTACH(tryAttachDouble());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// String x String
|
// String x String
|
||||||
if (tryAttachStringConcat()) {
|
TRY_ATTACH(tryAttachStringConcat());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// String x Object
|
// String x Object
|
||||||
if (tryAttachStringObjectConcat()) {
|
TRY_ATTACH(tryAttachStringObjectConcat());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tryAttachStringNumberConcat()) {
|
TRY_ATTACH(tryAttachStringNumberConcat());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// String + Boolean
|
// String + Boolean
|
||||||
if (tryAttachStringBooleanConcat()) {
|
TRY_ATTACH(tryAttachStringBooleanConcat());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
trackAttached(IRGenerator::NotAttached);
|
trackAttached(IRGenerator::NotAttached);
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachBitwise() {
|
AttachDecision BinaryArithIRGenerator::tryAttachBitwise() {
|
||||||
// Only bit-wise and shifts.
|
// Only bit-wise and shifts.
|
||||||
if (op_ != JSOP_BITOR && op_ != JSOP_BITXOR && op_ != JSOP_BITAND &&
|
if (op_ != JSOP_BITOR && op_ != JSOP_BITXOR && op_ != JSOP_BITAND &&
|
||||||
op_ != JSOP_LSH && op_ != JSOP_RSH && op_ != JSOP_URSH) {
|
op_ != JSOP_LSH && op_ != JSOP_RSH && op_ != JSOP_URSH) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check guard conditions
|
// Check guard conditions
|
||||||
if (!(lhs_.isNumber() || lhs_.isBoolean()) ||
|
if (!(lhs_.isNumber() || lhs_.isBoolean()) ||
|
||||||
!(rhs_.isNumber() || rhs_.isBoolean())) {
|
!(rhs_.isNumber() || rhs_.isBoolean())) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All ops, with the exception of URSH produce Int32 values.
|
// All ops, with the exception of URSH produce Int32 values.
|
||||||
|
@ -6363,19 +6350,19 @@ bool BinaryArithIRGenerator::tryAttachBitwise() {
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.returnFromIC();
|
writer.returnFromIC();
|
||||||
return true;
|
return AttachDecision::Attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachDouble() {
|
AttachDecision BinaryArithIRGenerator::tryAttachDouble() {
|
||||||
// Check valid opcodes
|
// Check valid opcodes
|
||||||
if (op_ != JSOP_ADD && op_ != JSOP_SUB && op_ != JSOP_MUL &&
|
if (op_ != JSOP_ADD && op_ != JSOP_SUB && op_ != JSOP_MUL &&
|
||||||
op_ != JSOP_DIV && op_ != JSOP_MOD) {
|
op_ != JSOP_DIV && op_ != JSOP_MOD) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check guard conditions
|
// Check guard conditions
|
||||||
if (!lhs_.isNumber() || !rhs_.isNumber()) {
|
if (!lhs_.isNumber() || !rhs_.isNumber()) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValOperandId lhsId(writer.setInputOperandId(0));
|
ValOperandId lhsId(writer.setInputOperandId(0));
|
||||||
|
@ -6409,25 +6396,25 @@ bool BinaryArithIRGenerator::tryAttachDouble() {
|
||||||
MOZ_CRASH("Unhandled Op");
|
MOZ_CRASH("Unhandled Op");
|
||||||
}
|
}
|
||||||
writer.returnFromIC();
|
writer.returnFromIC();
|
||||||
return true;
|
return AttachDecision::Attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachInt32() {
|
AttachDecision BinaryArithIRGenerator::tryAttachInt32() {
|
||||||
// Check guard conditions
|
// Check guard conditions
|
||||||
if (!(lhs_.isInt32() || lhs_.isBoolean()) ||
|
if (!(lhs_.isInt32() || lhs_.isBoolean()) ||
|
||||||
!(rhs_.isInt32() || rhs_.isBoolean())) {
|
!(rhs_.isInt32() || rhs_.isBoolean())) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// These ICs will failure() if result can't be encoded in an Int32:
|
// These ICs will failure() if result can't be encoded in an Int32:
|
||||||
// If sample result is not Int32, we should avoid IC.
|
// If sample result is not Int32, we should avoid IC.
|
||||||
if (!res_.isInt32()) {
|
if (!res_.isInt32()) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op_ != JSOP_ADD && op_ != JSOP_SUB && op_ != JSOP_MUL &&
|
if (op_ != JSOP_ADD && op_ != JSOP_SUB && op_ != JSOP_MUL &&
|
||||||
op_ != JSOP_DIV && op_ != JSOP_MOD) {
|
op_ != JSOP_DIV && op_ != JSOP_MOD) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValOperandId lhsId(writer.setInputOperandId(0));
|
ValOperandId lhsId(writer.setInputOperandId(0));
|
||||||
|
@ -6470,18 +6457,18 @@ bool BinaryArithIRGenerator::tryAttachInt32() {
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.returnFromIC();
|
writer.returnFromIC();
|
||||||
return true;
|
return AttachDecision::Attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachStringNumberConcat() {
|
AttachDecision BinaryArithIRGenerator::tryAttachStringNumberConcat() {
|
||||||
// Only Addition
|
// Only Addition
|
||||||
if (op_ != JSOP_ADD) {
|
if (op_ != JSOP_ADD) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(lhs_.isString() && rhs_.isNumber()) &&
|
if (!(lhs_.isString() && rhs_.isNumber()) &&
|
||||||
!(lhs_.isNumber() && rhs_.isString())) {
|
!(lhs_.isNumber() && rhs_.isString())) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValOperandId lhsId(writer.setInputOperandId(0));
|
ValOperandId lhsId(writer.setInputOperandId(0));
|
||||||
|
@ -6509,18 +6496,18 @@ bool BinaryArithIRGenerator::tryAttachStringNumberConcat() {
|
||||||
|
|
||||||
writer.returnFromIC();
|
writer.returnFromIC();
|
||||||
trackAttached("BinaryArith.StringNumberConcat");
|
trackAttached("BinaryArith.StringNumberConcat");
|
||||||
return true;
|
return AttachDecision::Attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachStringBooleanConcat() {
|
AttachDecision BinaryArithIRGenerator::tryAttachStringBooleanConcat() {
|
||||||
// Only Addition
|
// Only Addition
|
||||||
if (op_ != JSOP_ADD) {
|
if (op_ != JSOP_ADD) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!lhs_.isString() || !rhs_.isBoolean()) &&
|
if ((!lhs_.isString() || !rhs_.isBoolean()) &&
|
||||||
(!lhs_.isBoolean() || !rhs_.isString())) {
|
(!lhs_.isBoolean() || !rhs_.isString())) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValOperandId lhsId(writer.setInputOperandId(0));
|
ValOperandId lhsId(writer.setInputOperandId(0));
|
||||||
|
@ -6542,18 +6529,18 @@ bool BinaryArithIRGenerator::tryAttachStringBooleanConcat() {
|
||||||
|
|
||||||
writer.returnFromIC();
|
writer.returnFromIC();
|
||||||
trackAttached("BinaryArith.StringBooleanConcat");
|
trackAttached("BinaryArith.StringBooleanConcat");
|
||||||
return true;
|
return AttachDecision::Attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachStringConcat() {
|
AttachDecision BinaryArithIRGenerator::tryAttachStringConcat() {
|
||||||
// Only Addition
|
// Only Addition
|
||||||
if (op_ != JSOP_ADD) {
|
if (op_ != JSOP_ADD) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check guards
|
// Check guards
|
||||||
if (!lhs_.isString() || !rhs_.isString()) {
|
if (!lhs_.isString() || !rhs_.isString()) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValOperandId lhsId(writer.setInputOperandId(0));
|
ValOperandId lhsId(writer.setInputOperandId(0));
|
||||||
|
@ -6566,19 +6553,19 @@ bool BinaryArithIRGenerator::tryAttachStringConcat() {
|
||||||
|
|
||||||
writer.returnFromIC();
|
writer.returnFromIC();
|
||||||
trackAttached("BinaryArith.StringConcat");
|
trackAttached("BinaryArith.StringConcat");
|
||||||
return true;
|
return AttachDecision::Attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryArithIRGenerator::tryAttachStringObjectConcat() {
|
AttachDecision BinaryArithIRGenerator::tryAttachStringObjectConcat() {
|
||||||
// Only Addition
|
// Only Addition
|
||||||
if (op_ != JSOP_ADD) {
|
if (op_ != JSOP_ADD) {
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Guards
|
// Check Guards
|
||||||
if (!(lhs_.isObject() && rhs_.isString()) &&
|
if (!(lhs_.isObject() && rhs_.isString()) &&
|
||||||
!(lhs_.isString() && rhs_.isObject()))
|
!(lhs_.isString() && rhs_.isObject()))
|
||||||
return false;
|
return AttachDecision::NoAction;
|
||||||
|
|
||||||
ValOperandId lhsId(writer.setInputOperandId(0));
|
ValOperandId lhsId(writer.setInputOperandId(0));
|
||||||
ValOperandId rhsId(writer.setInputOperandId(1));
|
ValOperandId rhsId(writer.setInputOperandId(1));
|
||||||
|
@ -6598,7 +6585,7 @@ bool BinaryArithIRGenerator::tryAttachStringObjectConcat() {
|
||||||
|
|
||||||
writer.returnFromIC();
|
writer.returnFromIC();
|
||||||
trackAttached("BinaryArith.StringObjectConcat");
|
trackAttached("BinaryArith.StringObjectConcat");
|
||||||
return true;
|
return AttachDecision::Attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewObjectIRGenerator::NewObjectIRGenerator(JSContext* cx, HandleScript script,
|
NewObjectIRGenerator::NewObjectIRGenerator(JSContext* cx, HandleScript script,
|
||||||
|
|
|
@ -2481,20 +2481,20 @@ class MOZ_RAII BinaryArithIRGenerator : public IRGenerator {
|
||||||
|
|
||||||
void trackAttached(const char* name);
|
void trackAttached(const char* name);
|
||||||
|
|
||||||
bool tryAttachInt32();
|
AttachDecision tryAttachInt32();
|
||||||
bool tryAttachDouble();
|
AttachDecision tryAttachDouble();
|
||||||
bool tryAttachBitwise();
|
AttachDecision tryAttachBitwise();
|
||||||
bool tryAttachStringConcat();
|
AttachDecision tryAttachStringConcat();
|
||||||
bool tryAttachStringObjectConcat();
|
AttachDecision tryAttachStringObjectConcat();
|
||||||
bool tryAttachStringNumberConcat();
|
AttachDecision tryAttachStringNumberConcat();
|
||||||
bool tryAttachStringBooleanConcat();
|
AttachDecision tryAttachStringBooleanConcat();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BinaryArithIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc,
|
BinaryArithIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc,
|
||||||
ICState::Mode, JSOp op, HandleValue lhs,
|
ICState::Mode, JSOp op, HandleValue lhs,
|
||||||
HandleValue rhs, HandleValue res);
|
HandleValue rhs, HandleValue res);
|
||||||
|
|
||||||
bool tryAttachStub();
|
AttachDecision tryAttachStub();
|
||||||
};
|
};
|
||||||
|
|
||||||
class MOZ_RAII NewObjectIRGenerator : public IRGenerator {
|
class MOZ_RAII NewObjectIRGenerator : public IRGenerator {
|
||||||
|
|
|
@ -616,8 +616,8 @@ bool IonBinaryArithIC::update(JSContext* cx, HandleScript outerScript,
|
||||||
MOZ_CRASH("Unhandled binary arith op");
|
MOZ_CRASH("Unhandled binary arith op");
|
||||||
}
|
}
|
||||||
|
|
||||||
TryAttachIonStubOld<BinaryArithIRGenerator, IonBinaryArithIC>(
|
TryAttachIonStub<BinaryArithIRGenerator, IonBinaryArithIC>(cx, ic, ionScript,
|
||||||
cx, ic, ionScript, op, lhs, rhs, ret);
|
op, lhs, rhs, ret);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче