зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1642680: Share LRandom lowering code. r=jandem
The previous code was using a fixed result register, because bug 774364 was using an OOL-path for `Math.random`, which was later removed in bug 322529. Differential Revision: https://phabricator.services.mozilla.com/D77836
This commit is contained in:
Родитель
2301168947
Коммит
346a4b69db
|
@ -14031,13 +14031,8 @@ void CodeGenerator::visitRandom(LRandom* ins) {
|
|||
FloatRegister output = ToFloatRegister(ins->output());
|
||||
Register rngReg = ToRegister(ins->temp0());
|
||||
|
||||
#ifdef JS_PUNBOX64
|
||||
Register64 temp1(ToRegister(ins->temp1()));
|
||||
Register64 temp2(ToRegister(ins->temp2()));
|
||||
#else
|
||||
Register64 temp1(ToRegister(ins->temp1()), ToRegister(ins->temp2()));
|
||||
Register64 temp2(ToRegister(ins->temp3()), ToRegister(ins->temp4()));
|
||||
#endif
|
||||
Register64 temp1 = ToRegister64(ins->temp1());
|
||||
Register64 temp2 = ToRegister64(ins->temp2());
|
||||
|
||||
const XorShift128PlusRNG* rng = gen->realm->addressOfRandomNumberGenerator();
|
||||
masm.movePtr(ImmPtr(rng), rngReg);
|
||||
|
|
|
@ -1595,6 +1595,11 @@ void LIRGenerator::visitMathFunction(MMathFunction* ins) {
|
|||
defineReturn(lir, ins);
|
||||
}
|
||||
|
||||
void LIRGenerator::visitRandom(MRandom* ins) {
|
||||
auto* lir = new (alloc()) LRandom(temp(), tempInt64(), tempInt64());
|
||||
define(lir, ins);
|
||||
}
|
||||
|
||||
// Try to mark an add or sub instruction as able to recover its input when
|
||||
// bailing out.
|
||||
template <typename S, typename T>
|
||||
|
|
|
@ -934,11 +934,6 @@ void LIRGenerator::visitSubstr(MSubstr* ins) {
|
|||
assignSafepoint(lir, ins);
|
||||
}
|
||||
|
||||
void LIRGenerator::visitRandom(MRandom* ins) {
|
||||
LRandom* lir = new (alloc()) LRandom(temp(), temp(), temp(), temp(), temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
|
||||
void LIRGenerator::visitWasmTruncateToInt64(MWasmTruncateToInt64* ins) {
|
||||
MDefinition* opd = ins->input();
|
||||
MOZ_ASSERT(opd->type() == MIRType::Double || opd->type() == MIRType::Float32);
|
||||
|
|
|
@ -505,11 +505,6 @@ void LIRGenerator::visitSubstr(MSubstr* ins) {
|
|||
assignSafepoint(lir, ins);
|
||||
}
|
||||
|
||||
void LIRGenerator::visitRandom(MRandom* ins) {
|
||||
LRandom* lir = new (alloc()) LRandom(temp(), temp(), temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
|
||||
void LIRGenerator::visitWasmTruncateToInt64(MWasmTruncateToInt64* ins) {
|
||||
MOZ_CRASH("NYI");
|
||||
}
|
||||
|
|
|
@ -218,11 +218,6 @@ void LIRGeneratorMIPS::lowerUModI64(MMod* mod) {
|
|||
defineReturn(lir, mod);
|
||||
}
|
||||
|
||||
void LIRGenerator::visitRandom(MRandom* ins) {
|
||||
LRandom* lir = new (alloc()) LRandom(temp(), temp(), temp(), temp(), temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
|
||||
void LIRGenerator::visitWasmTruncateToInt64(MWasmTruncateToInt64* ins) {
|
||||
MDefinition* opd = ins->input();
|
||||
MOZ_ASSERT(opd->type() == MIRType::Double || opd->type() == MIRType::Float32);
|
||||
|
|
|
@ -146,11 +146,6 @@ void LIRGeneratorMIPS64::lowerTruncateFToInt32(MTruncateToInt32* ins) {
|
|||
define(new (alloc()) LTruncateFToInt32(useRegister(opd), tempFloat32()), ins);
|
||||
}
|
||||
|
||||
void LIRGenerator::visitRandom(MRandom* ins) {
|
||||
LRandom* lir = new (alloc()) LRandom(temp(), temp(), temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
|
||||
void LIRGenerator::visitWasmTruncateToInt64(MWasmTruncateToInt64* ins) {
|
||||
MDefinition* opd = ins->input();
|
||||
MOZ_ASSERT(opd->type() == MIRType::Double || opd->type() == MIRType::Float32);
|
||||
|
|
|
@ -7389,38 +7389,19 @@ class LArrowNewTarget : public LInstructionHelper<BOX_PIECES, 1, 0> {
|
|||
};
|
||||
|
||||
// Math.random().
|
||||
#ifdef JS_PUNBOX64
|
||||
# define LRANDOM_NUM_TEMPS 3
|
||||
#else
|
||||
# define LRANDOM_NUM_TEMPS 5
|
||||
#endif
|
||||
|
||||
class LRandom : public LInstructionHelper<1, 0, LRANDOM_NUM_TEMPS> {
|
||||
class LRandom : public LInstructionHelper<1, 0, 1 + 2 * INT64_PIECES> {
|
||||
public:
|
||||
LIR_HEADER(Random)
|
||||
LRandom(const LDefinition& temp0, const LDefinition& temp1,
|
||||
const LDefinition& temp2
|
||||
#ifndef JS_PUNBOX64
|
||||
,
|
||||
const LDefinition& temp3, const LDefinition& temp4
|
||||
#endif
|
||||
)
|
||||
LRandom(const LDefinition& temp0, const LInt64Definition& temp1,
|
||||
const LInt64Definition& temp2)
|
||||
: LInstructionHelper(classOpcode) {
|
||||
setTemp(0, temp0);
|
||||
setTemp(1, temp1);
|
||||
setTemp(2, temp2);
|
||||
#ifndef JS_PUNBOX64
|
||||
setTemp(3, temp3);
|
||||
setTemp(4, temp4);
|
||||
#endif
|
||||
setInt64Temp(1, temp1);
|
||||
setInt64Temp(1 + INT64_PIECES, temp2);
|
||||
}
|
||||
const LDefinition* temp0() { return getTemp(0); }
|
||||
const LDefinition* temp1() { return getTemp(1); }
|
||||
const LDefinition* temp2() { return getTemp(2); }
|
||||
#ifndef JS_PUNBOX64
|
||||
const LDefinition* temp3() { return getTemp(3); }
|
||||
const LDefinition* temp4() { return getTemp(4); }
|
||||
#endif
|
||||
LInt64Definition temp1() { return getInt64Temp(1); }
|
||||
LInt64Definition temp2() { return getInt64Temp(1 + INT64_PIECES); }
|
||||
|
||||
MRandom* mir() const { return mir_->toRandom(); }
|
||||
};
|
||||
|
|
|
@ -341,11 +341,6 @@ void LIRGenerator::visitSubstr(MSubstr* ins) {
|
|||
assignSafepoint(lir, ins);
|
||||
}
|
||||
|
||||
void LIRGenerator::visitRandom(MRandom* ins) {
|
||||
LRandom* lir = new (alloc()) LRandom(temp(), temp(), temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
|
||||
void LIRGeneratorX64::lowerDivI64(MDiv* div) {
|
||||
if (div->isUnsigned()) {
|
||||
lowerUDivI64(div);
|
||||
|
|
|
@ -635,11 +635,6 @@ void LIRGenerator::visitSubstr(MSubstr* ins) {
|
|||
assignSafepoint(lir, ins);
|
||||
}
|
||||
|
||||
void LIRGenerator::visitRandom(MRandom* ins) {
|
||||
LRandom* lir = new (alloc()) LRandom(temp(), temp(), temp(), temp(), temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
|
||||
void LIRGenerator::visitWasmTruncateToInt64(MWasmTruncateToInt64* ins) {
|
||||
MDefinition* opd = ins->input();
|
||||
MOZ_ASSERT(opd->type() == MIRType::Double || opd->type() == MIRType::Float32);
|
||||
|
|
Загрузка…
Ссылка в новой задаче