Issue #1240 - Part 10 - Implement minimal Ion support for BigInt. https://bugzilla.mozilla.org/show_bug.cgi?id=1507484 Implement IC support for BigInt. https://bugzilla.mozilla.org/show_bug.cgi?id=1522431

This commit is contained in:
Brian Smith 2023-07-21 20:25:52 -05:00 • committed by roytam1
commit 2d5ee3c457
39 changed files with 448 additions and 43 deletions

View file

@ -1548,6 +1548,7 @@ class MConstant : public MNullaryInstruction
double d;
JSString* str;
JS::Symbol* sym;
BigInt* bi;
JSObject* obj;
uint64_t asBits;
};
@ -1672,6 +1673,10 @@ class MConstant : public MNullaryInstruction
MOZ_ASSERT(type() == MIRType::Symbol);
return payload_.sym;
}
BigInt* toBigInt() const {
MOZ_ASSERT(type() == MIRType::BigInt);
return payload_.bi;
}
JSObject& toObject() const {
MOZ_ASSERT(type() == MIRType::Object);
return *payload_.obj;
@ -4743,6 +4748,7 @@ class MUnbox final : public MUnaryInstruction, public BoxInputsPolicy::Data
type == MIRType::Double ||
type == MIRType::String ||
type == MIRType::Symbol ||
type == MIRType::BigInt ||
type == MIRType::Object);
TemporaryTypeSet* resultSet = ins->resultTypeSet();
@ -4781,6 +4787,9 @@ class MUnbox final : public MUnaryInstruction, public BoxInputsPolicy::Data
case MIRType::Symbol:
kind = Bailout_NonSymbolInput;
break;
case MIRType::BigInt:
kind = Bailout_NonBigIntInput;
break;
case MIRType::Object:
kind = Bailout_NonObjectInput;
break;
@ -5189,9 +5198,11 @@ class MToDouble
setMovable();
// An object might have "valueOf", which means it is effectful.
// ToNumber(symbol) throws.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol))
// ToNumber(symbol) and ToNumber(bigint) throw.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol) ||
def->mightBeType(MIRType::BigInt)) {
setGuard();
}
}
public:
@ -5226,11 +5237,15 @@ class MToDouble
MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
if (input()->type() == MIRType::Value)
if (input()->type() == MIRType::Value) {
return false;
if (input()->type() == MIRType::Symbol)
}
if (input()->type() == MIRType::Symbol) {
return false;
}
if (input()->type() == MIRType::BigInt) {
return false;
}
return true;
}
@ -5253,9 +5268,11 @@ class MToFloat32
setMovable();
// An object might have "valueOf", which means it is effectful.
// ToNumber(symbol) throws.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol))
// ToNumber(symbol) and ToNumber(BigInt) throw.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol) ||
def->mightBeType(MIRType::BigInt)) {
setGuard();
}
}
explicit MToFloat32(MDefinition* def, bool mustPreserveNaN)
@ -5537,9 +5554,11 @@ class MToInt32
setMovable();
// An object might have "valueOf", which means it is effectful.
// ToNumber(symbol) throws.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol))
// ToInt32(symbol) and ToInt32(BigInt) throw.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol) ||
def->mightBeType(MIRType::BigInt)) {
setGuard();
}
}
public:
@ -5594,9 +5613,11 @@ class MTruncateToInt32
setMovable();
// An object might have "valueOf", which means it is effectful.
// ToInt32(symbol) throws.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol))
// ToInt32(symbol) and ToInt32(BigInt) throw.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol) ||
def->mightBeType(MIRType::BigInt)) {
setGuard();
}
}
public:
@ -5639,9 +5660,12 @@ class MToString :
setResultType(MIRType::String);
setMovable();
// Objects might override toString and Symbols throw.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol))
// Objects might override toString; Symbol and BigInts throw. We bailout in
// those cases and run side-effects in baseline instead.
if (def->mightBeType(MIRType::Object) || def->mightBeType(MIRType::Symbol) ||
def->mightBeType(MIRType::BigInt)) {
setGuard();
}
}
public: