Bug 1522431 - Implement IC support for BigInt r=jandem,terpri

Differential Revision: https://phabricator.services.mozilla.com/D17483

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andy Wingo 2019-01-28 00:21:41 +00:00
parent 1db81fda08
commit 30503c1b25
16 changed files with 303 additions and 5 deletions

View File

@ -160,6 +160,10 @@ def get_macroassembler_definitions(filename):
if not style_section:
continue
# Ignore preprocessor directives.
if line.startswith('#'):
continue
# Remove comments from the processed line.
line = re.sub(r'//.*', '', line)
@ -219,10 +223,15 @@ def get_macroassembler_declaration(filename):
if not style_section:
continue
# Ignore preprocessor directives.
if line.startswith('#'):
continue
line = re.sub(r'//.*', '', line)
if len(line.strip()) == 0 or 'public:' in line or 'private:' in line:
lines = ''
continue
lines = lines + line
# Continue until we have a complete declaration

View File

@ -1479,6 +1479,12 @@ bool ICTypeMonitor_PrimitiveSet::Compiler::generateStubCode(
masm.branchTestSymbol(Assembler::Equal, R0, &success);
}
#ifdef ENABLE_BIGINT
if (flags_ & TypeToFlag(JSVAL_TYPE_BIGINT)) {
masm.branchTestBigInt(Assembler::Equal, R0, &success);
}
#endif
if (flags_ & TypeToFlag(JSVAL_TYPE_OBJECT)) {
masm.branchTestObject(Assembler::Equal, R0, &success);
}
@ -1819,6 +1825,12 @@ bool ICTypeUpdate_PrimitiveSet::Compiler::generateStubCode(
masm.branchTestSymbol(Assembler::Equal, R0, &success);
}
#ifdef ENABLE_BIGINT
if (flags_ & TypeToFlag(JSVAL_TYPE_BIGINT)) {
masm.branchTestBigInt(Assembler::Equal, R0, &success);
}
#endif
if (flags_ & TypeToFlag(JSVAL_TYPE_OBJECT)) {
masm.branchTestObject(Assembler::Equal, R0, &success);
}

View File

@ -1958,7 +1958,14 @@ bool GetPropIRGenerator::tryAttachPrimitive(ValOperandId valId, HandleId id) {
} else if (val_.isSymbol()) {
primitiveType = JSVAL_TYPE_SYMBOL;
proto = MaybeNativeObject(cx_->global()->maybeGetPrototype(JSProto_Symbol));
} else {
}
#ifdef ENABLE_BIGINT
else if (val_.isBigInt()) {
primitiveType = JSVAL_TYPE_BIGINT;
proto = MaybeNativeObject(cx_->global()->maybeGetPrototype(JSProto_BigInt));
}
#endif
else {
MOZ_ASSERT(val_.isNullOrUndefined() || val_.isMagic());
return false;
}

View File

@ -1568,6 +1568,11 @@ bool CacheIRCompiler::emitGuardType() {
case JSVAL_TYPE_SYMBOL:
masm.branchTestSymbol(Assembler::NotEqual, input, failure->label());
break;
#ifdef ENABLE_BIGINT
case JSVAL_TYPE_BIGINT:
masm.branchTestBigInt(Assembler::NotEqual, input, failure->label());
break;
#endif
case JSVAL_TYPE_INT32:
masm.branchTestInt32(Assembler::NotEqual, input, failure->label());
break;

View File

@ -64,6 +64,11 @@ static void EmitTypeCheck(MacroAssembler& masm, Assembler::Condition cond,
case JSVAL_TYPE_SYMBOL:
masm.branchTestSymbol(cond, src, label);
break;
#ifdef ENABLE_BIGINT
case JSVAL_TYPE_BIGINT:
masm.branchTestBigInt(cond, src, label);
break;
#endif
case JSVAL_TYPE_NULL:
masm.branchTestNull(cond, src, label);
break;
@ -96,10 +101,17 @@ void MacroAssembler::guardTypeSet(const Source& address, const TypeSet* types,
MOZ_ASSERT(!types->unknown());
Label matched;
TypeSet::Type tests[8] = {TypeSet::Int32Type(), TypeSet::UndefinedType(),
TypeSet::BooleanType(), TypeSet::StringType(),
TypeSet::SymbolType(), TypeSet::NullType(),
TypeSet::MagicArgType(), TypeSet::AnyObjectType()};
TypeSet::Type tests[] = {TypeSet::Int32Type(),
TypeSet::UndefinedType(),
TypeSet::BooleanType(),
TypeSet::StringType(),
TypeSet::SymbolType(),
#ifdef ENABLE_BIGINT
TypeSet::BigIntType(),
#endif
TypeSet::NullType(),
TypeSet::MagicArgType(),
TypeSet::AnyObjectType()};
// The double type also implies Int32.
// So replace the int32 test with the double one.

View File

@ -1421,6 +1421,10 @@ class MacroAssembler : public MacroAssemblerSpecific {
Label* label) PER_SHARED_ARCH;
inline void branchTestSymbol(Condition cond, Register tag,
Label* label) PER_SHARED_ARCH;
#ifdef ENABLE_BIGINT
inline void branchTestBigInt(Condition cond, Register tag,
Label* label) PER_SHARED_ARCH;
#endif
inline void branchTestNull(Condition cond, Register tag,
Label* label) PER_SHARED_ARCH;
inline void branchTestObject(Condition cond, Register tag,
@ -1484,6 +1488,14 @@ class MacroAssembler : public MacroAssemblerSpecific {
Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
#ifdef ENABLE_BIGINT
inline void branchTestBigInt(Condition cond, const BaseIndex& address,
Label* label) PER_SHARED_ARCH;
inline void branchTestBigInt(Condition cond, const ValueOperand& value,
Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
#endif
inline void branchTestNull(Condition cond, const Address& address,
Label* label) PER_SHARED_ARCH;
inline void branchTestNull(Condition cond, const BaseIndex& address,
@ -1577,6 +1589,11 @@ class MacroAssembler : public MacroAssemblerSpecific {
template <typename T>
inline void branchTestSymbolImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
#ifdef ENABLE_BIGINT
template <typename T>
inline void branchTestBigIntImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
#endif
template <typename T>
inline void branchTestNullImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);

View File

@ -1694,6 +1694,30 @@ void MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t,
ma_b(label, c);
}
#ifdef ENABLE_BIGINT
void MacroAssembler::branchTestBigInt(Condition cond, Register tag,
Label* label) {
branchTestBigIntImpl(cond, tag, label);
}
void MacroAssembler::branchTestBigInt(Condition cond, const BaseIndex& address,
Label* label) {
branchTestBigIntImpl(cond, address, label);
}
void MacroAssembler::branchTestBigInt(Condition cond, const ValueOperand& value,
Label* label) {
branchTestBigIntImpl(cond, value, label);
}
template <typename T>
void MacroAssembler::branchTestBigIntImpl(Condition cond, const T& t,
Label* label) {
Condition c = testBigInt(cond, t);
ma_b(label, c);
}
#endif
void MacroAssembler::branchTestNull(Condition cond, Register tag,
Label* label) {
branchTestNullImpl(cond, tag, label);

View File

@ -2419,6 +2419,13 @@ Assembler::Condition MacroAssemblerARMCompat::testSymbol(
return testSymbol(cond, value.typeReg());
}
#ifdef ENABLE_BIGINT
Assembler::Condition MacroAssemblerARMCompat::testBigInt(
Assembler::Condition cond, const ValueOperand& value) {
return testBigInt(cond, value.typeReg());
}
#endif
Assembler::Condition MacroAssemblerARMCompat::testObject(
Assembler::Condition cond, const ValueOperand& value) {
return testObject(cond, value.typeReg());
@ -2482,6 +2489,15 @@ Assembler::Condition MacroAssemblerARMCompat::testSymbol(
return cond;
}
#ifdef ENABLE_BIGINT
Assembler::Condition MacroAssemblerARMCompat::testBigInt(
Assembler::Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_cmp(tag, ImmTag(JSVAL_TAG_BIGINT));
return cond;
}
#endif
Assembler::Condition MacroAssemblerARMCompat::testObject(
Assembler::Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
@ -2578,6 +2594,16 @@ Assembler::Condition MacroAssemblerARMCompat::testSymbol(
return testSymbol(cond, tag);
}
#ifdef ENABLE_BIGINT
Assembler::Condition MacroAssemblerARMCompat::testBigInt(
Condition cond, const Address& address) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ScratchRegisterScope scratch(asMasm());
Register tag = extractTag(address, scratch);
return testBigInt(cond, tag);
}
#endif
Assembler::Condition MacroAssemblerARMCompat::testObject(
Condition cond, const Address& address) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
@ -2654,6 +2680,17 @@ Assembler::Condition MacroAssemblerARMCompat::testSymbol(Condition cond,
return cond;
}
#ifdef ENABLE_BIGINT
Assembler::Condition MacroAssemblerARMCompat::testBigInt(Condition cond,
const BaseIndex& src) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ScratchRegisterScope scratch(asMasm());
Register tag = extractTag(src, scratch);
ma_cmp(tag, ImmTag(JSVAL_TAG_BIGINT));
return cond;
}
#endif
Assembler::Condition MacroAssemblerARMCompat::testInt32(Condition cond,
const BaseIndex& src) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);

View File

@ -766,6 +766,9 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM {
Condition testUndefined(Condition cond, const ValueOperand& value);
Condition testString(Condition cond, const ValueOperand& value);
Condition testSymbol(Condition cond, const ValueOperand& value);
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const ValueOperand& value);
#endif
Condition testObject(Condition cond, const ValueOperand& value);
Condition testNumber(Condition cond, const ValueOperand& value);
Condition testMagic(Condition cond, const ValueOperand& value);
@ -779,6 +782,9 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM {
Condition testUndefined(Condition cond, Register tag);
Condition testString(Condition cond, Register tag);
Condition testSymbol(Condition cond, Register tag);
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, Register tag);
#endif
Condition testObject(Condition cond, Register tag);
Condition testDouble(Condition cond, Register tag);
Condition testNumber(Condition cond, Register tag);
@ -794,6 +800,9 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM {
Condition testUndefined(Condition cond, const Address& address);
Condition testString(Condition cond, const Address& address);
Condition testSymbol(Condition cond, const Address& address);
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const Address& address);
#endif
Condition testObject(Condition cond, const Address& address);
Condition testNumber(Condition cond, const Address& address);
@ -802,6 +811,9 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM {
Condition testBoolean(Condition cond, const BaseIndex& src);
Condition testString(Condition cond, const BaseIndex& src);
Condition testSymbol(Condition cond, const BaseIndex& src);
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const BaseIndex& src);
#endif
Condition testInt32(Condition cond, const BaseIndex& src);
Condition testObject(Condition cond, const BaseIndex& src);
Condition testDouble(Condition cond, const BaseIndex& src);

View File

@ -1402,6 +1402,30 @@ void MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t,
B(label, c);
}
#ifdef ENABLE_BIGINT
void MacroAssembler::branchTestBigInt(Condition cond, Register tag,
Label* label) {
branchTestBigIntImpl(cond, tag, label);
}
void MacroAssembler::branchTestBigInt(Condition cond, const BaseIndex& address,
Label* label) {
branchTestBigIntImpl(cond, address, label);
}
void MacroAssembler::branchTestBigInt(Condition cond, const ValueOperand& value,
Label* label) {
branchTestBigIntImpl(cond, value, label);
}
template <typename T>
void MacroAssembler::branchTestBigIntImpl(Condition cond, const T& t,
Label* label) {
Condition c = testBigInt(cond, t);
B(label, c);
}
#endif
void MacroAssembler::branchTestNull(Condition cond, Register tag,
Label* label) {
branchTestNullImpl(cond, tag, label);

View File

@ -1479,6 +1479,13 @@ class MacroAssemblerCompat : public vixl::MacroAssembler {
cmpTag(tag, ImmTag(JSVAL_TAG_SYMBOL));
return cond;
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmpTag(tag, ImmTag(JSVAL_TAG_BIGINT));
return cond;
}
#endif
Condition testObject(Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmpTag(tag, ImmTag(JSVAL_TAG_OBJECT));
@ -1569,6 +1576,15 @@ class MacroAssemblerCompat : public vixl::MacroAssembler {
splitSignExtTag(value, scratch);
return testSymbol(cond, scratch);
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const ValueOperand& value) {
vixl::UseScratchRegisterScope temps(this);
const Register scratch = temps.AcquireX().asUnsized();
MOZ_ASSERT(value.valueReg() != scratch);
splitSignExtTag(value, scratch);
return testBigInt(cond, scratch);
}
#endif
Condition testObject(Condition cond, const ValueOperand& value) {
vixl::UseScratchRegisterScope temps(this);
const Register scratch = temps.AcquireX().asUnsized();
@ -1665,6 +1681,15 @@ class MacroAssemblerCompat : public vixl::MacroAssembler {
splitSignExtTag(address, scratch);
return testSymbol(cond, scratch);
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const Address& address) {
vixl::UseScratchRegisterScope temps(this);
const Register scratch = temps.AcquireX().asUnsized();
MOZ_ASSERT(address.base != scratch);
splitSignExtTag(address, scratch);
return testBigInt(cond, scratch);
}
#endif
Condition testObject(Condition cond, const Address& address) {
vixl::UseScratchRegisterScope temps(this);
const Register scratch = temps.AcquireX().asUnsized();
@ -1721,6 +1746,16 @@ class MacroAssemblerCompat : public vixl::MacroAssembler {
splitSignExtTag(src, scratch);
return testSymbol(cond, scratch);
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const BaseIndex& src) {
vixl::UseScratchRegisterScope temps(this);
const Register scratch = temps.AcquireX().asUnsized();
MOZ_ASSERT(src.base != scratch);
MOZ_ASSERT(src.index != scratch);
splitSignExtTag(src, scratch);
return testBigInt(cond, scratch);
}
#endif
Condition testInt32(Condition cond, const BaseIndex& src) {
vixl::UseScratchRegisterScope temps(this);
const Register scratch = temps.AcquireX().asUnsized();

View File

@ -814,6 +814,13 @@ void MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value,
branchTestSymbol(cond, value.typeReg(), label);
}
#ifdef ENABLE_BIGINT
void MacroAssembler::branchTestBigInt(Condition cond, const ValueOperand& value,
Label* label) {
branchTestBigInt(cond, value.typeReg(), label);
}
#endif
void MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value,
Label* label) {
branchTestNull(cond, value.typeReg(), label);

View File

@ -546,6 +546,15 @@ void MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value,
branchTestSymbol(cond, scratch2, label);
}
#ifdef ENABLE_BIGINT
void MacroAssembler::branchTestBigInt(Condition cond, const ValueOperand& value,
Label* label) {
SecondScratchRegisterScope scratch2(*this);
splitTag(value, scratch2);
branchTestBigInt(cond, scratch2, label);
}
#endif
void MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value,
Label* label) {
SecondScratchRegisterScope scratch2(*this);

View File

@ -255,6 +255,13 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared {
cmp32(tag, ImmTag(JSVAL_TAG_SYMBOL));
return cond;
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(tag, ImmTag(JSVAL_TAG_BIGINT));
return cond;
}
#endif
Condition testObject(Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(tag, ImmTag(JSVAL_TAG_OBJECT));
@ -330,6 +337,13 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared {
splitTag(src, scratch);
return testSymbol(cond, scratch);
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const ValueOperand& src) {
ScratchRegisterScope scratch(asMasm());
splitTag(src, scratch);
return testBigInt(cond, scratch);
}
#endif
Condition testObject(Condition cond, const ValueOperand& src) {
ScratchRegisterScope scratch(asMasm());
splitTag(src, scratch);
@ -383,6 +397,13 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared {
splitTag(src, scratch);
return testSymbol(cond, scratch);
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const Address& src) {
ScratchRegisterScope scratch(asMasm());
splitTag(src, scratch);
return testBigInt(cond, scratch);
}
#endif
Condition testObject(Condition cond, const Address& src) {
ScratchRegisterScope scratch(asMasm());
splitTag(src, scratch);
@ -429,6 +450,13 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared {
splitTag(src, scratch);
return testSymbol(cond, scratch);
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const BaseIndex& src) {
ScratchRegisterScope scratch(asMasm());
splitTag(src, scratch);
return testBigInt(cond, scratch);
}
#endif
Condition testInt32(Condition cond, const BaseIndex& src) {
ScratchRegisterScope scratch(asMasm());
splitTag(src, scratch);
@ -800,6 +828,15 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared {
unboxNonDouble(src, dest, JSVAL_TYPE_SYMBOL);
}
#ifdef ENABLE_BIGINT
void unboxBigInt(const ValueOperand& src, Register dest) {
unboxNonDouble(src, dest, JSVAL_TYPE_BIGINT);
}
void unboxBigInt(const Operand& src, Register dest) {
unboxNonDouble(src, dest, JSVAL_TYPE_BIGINT);
}
#endif
void unboxObject(const ValueOperand& src, Register dest) {
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT);
}

View File

@ -801,6 +801,30 @@ void MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t,
j(cond, label);
}
#ifdef ENABLE_BIGINT
void MacroAssembler::branchTestBigInt(Condition cond, Register tag,
Label* label) {
branchTestBigIntImpl(cond, tag, label);
}
void MacroAssembler::branchTestBigInt(Condition cond, const BaseIndex& address,
Label* label) {
branchTestBigIntImpl(cond, address, label);
}
void MacroAssembler::branchTestBigInt(Condition cond, const ValueOperand& value,
Label* label) {
branchTestBigIntImpl(cond, value, label);
}
template <typename T>
void MacroAssembler::branchTestBigIntImpl(Condition cond, const T& t,
Label* label) {
cond = testBigInt(cond, t);
j(cond, label);
}
#endif
void MacroAssembler::branchTestNull(Condition cond, Register tag,
Label* label) {
branchTestNullImpl(cond, tag, label);

View File

@ -309,6 +309,13 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared {
cmp32(tag, ImmTag(JSVAL_TAG_SYMBOL));
return cond;
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(tag, ImmTag(JSVAL_TAG_BIGINT));
return cond;
}
#endif
Condition testObject(Condition cond, Register tag) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(tag, ImmTag(JSVAL_TAG_OBJECT));
@ -424,6 +431,11 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared {
Condition testSymbol(Condition cond, const ValueOperand& value) {
return testSymbol(cond, value.typeReg());
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const ValueOperand& value) {
return testBigInt(cond, value.typeReg());
}
#endif
Condition testObject(Condition cond, const ValueOperand& value) {
return testObject(cond, value.typeReg());
}
@ -473,6 +485,13 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared {
cmp32(tagOf(address), ImmTag(JSVAL_TAG_SYMBOL));
return cond;
}
#ifdef ENABLE_BIGINT
Condition testBigInt(Condition cond, const BaseIndex& address) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(tagOf(address), ImmTag(JSVAL_TAG_BIGINT));
return cond;
}
#endif
Condition testInt32(Condition cond, const BaseIndex& address) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(tagOf(address), ImmTag(JSVAL_TAG_INT32));
@ -747,6 +766,14 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared {
void unboxSymbol(const Address& src, Register dest) {
unboxNonDouble(src, dest, JSVAL_TYPE_SYMBOL);
}
#ifdef ENABLE_BIGINT
void unboxBigInt(const ValueOperand& src, Register dest) {
unboxNonDouble(src, dest, JSVAL_TYPE_BIGINT);
}
void unboxBigInt(const Address& src, Register dest) {
unboxNonDouble(src, dest, JSVAL_TYPE_BIGINT);
}
#endif
void unboxObject(const ValueOperand& src, Register dest) {
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT);
}