tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit dce8338b0f3c7ef9989ccd86e516c871a0d96cd0
parent 4567c368cfb9606b49265fff33e8e5f149f67ec7
Author: André Bargull <andre.bargull@gmail.com>
Date:   Fri, 24 Oct 2025 14:58:52 +0000

Bug 1996082 - Part 1: Always allocate registers for Int64 ALU operations on {mips,loong,riscv}64. r=spidermonkey-reviewers,jandem

These architectures don't support ALU operations on `Address`, so it's more
efficient to directly allocate a register.

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

Diffstat:
Mjs/src/jit/loong64/CodeGenerator-loong64.cpp | 24++++++------------------
Mjs/src/jit/loong64/CodeGenerator-loong64.h | 6------
Mjs/src/jit/loong64/Lowering-loong64.cpp | 11++++++-----
Mjs/src/jit/mips-shared/CodeGenerator-mips-shared.cpp | 17++++++-----------
Mjs/src/jit/mips-shared/CodeGenerator-mips-shared.h | 2--
Mjs/src/jit/mips-shared/Lowering-mips-shared.cpp | 11++++++-----
Mjs/src/jit/riscv64/CodeGenerator-riscv64.cpp | 24++++++------------------
Mjs/src/jit/riscv64/CodeGenerator-riscv64.h | 6------
Mjs/src/jit/riscv64/Lowering-riscv64.cpp | 11++++++-----
9 files changed, 36 insertions(+), 76 deletions(-)

diff --git a/js/src/jit/loong64/CodeGenerator-loong64.cpp b/js/src/jit/loong64/CodeGenerator-loong64.cpp @@ -54,18 +54,6 @@ Operand CodeGeneratorLOONG64::ToOperand(const LDefinition* def) { return ToOperand(def->output()); } -#ifdef JS_PUNBOX64 -Operand CodeGeneratorLOONG64::ToOperandOrRegister64( - const LInt64Allocation& input) { - return ToOperand(input.value()); -} -#else -Register64 CodeGeneratorLOONG64::ToOperandOrRegister64( - const LInt64Allocation& input) { - return ToRegister64(input); -} -#endif - void CodeGeneratorLOONG64::branchToBlock(Assembler::FloatFormat fmt, FloatRegister lhs, FloatRegister rhs, MBasicBlock* mir, @@ -707,7 +695,7 @@ void CodeGenerator::visitAddI64(LAddI64* lir) { return; } - masm.add64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.add64(ToRegister64(rhs), ToRegister64(lhs)); } void CodeGenerator::visitSubI(LSubI* ins) { @@ -763,7 +751,7 @@ void CodeGenerator::visitSubI64(LSubI64* lir) { return; } - masm.sub64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.sub64(ToRegister64(rhs), ToRegister64(lhs)); } void CodeGenerator::visitMulI(LMulI* ins) { @@ -990,7 +978,7 @@ void CodeGenerator::visitMulI64(LMulI64* lir) { } } else { Register temp = ToTempRegisterOrInvalid(lir->temp0()); - masm.mul64(ToOperandOrRegister64(rhs), ToRegister64(lhs), temp); + masm.mul64(ToRegister64(rhs), ToRegister64(lhs), temp); } } @@ -1268,21 +1256,21 @@ void CodeGenerator::visitBitOpI64(LBitOpI64* lir) { if (IsConstant(rhs)) { masm.or64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.or64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.or64(ToRegister64(rhs), ToRegister64(lhs)); } break; case JSOp::BitXor: if (IsConstant(rhs)) { masm.xor64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.xor64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.xor64(ToRegister64(rhs), ToRegister64(lhs)); } break; case JSOp::BitAnd: if (IsConstant(rhs)) { masm.and64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.and64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.and64(ToRegister64(rhs), ToRegister64(lhs)); } break; default: diff --git a/js/src/jit/loong64/CodeGenerator-loong64.h b/js/src/jit/loong64/CodeGenerator-loong64.h @@ -32,12 +32,6 @@ class CodeGeneratorLOONG64 : public CodeGeneratorShared { Operand ToOperand(const LAllocation* a); Operand ToOperand(const LDefinition* def); -#ifdef JS_PUNBOX64 - Operand ToOperandOrRegister64(const LInt64Allocation& input); -#else - Register64 ToOperandOrRegister64(const LInt64Allocation& input); -#endif - MoveOperand toMoveOperand(LAllocation a) const; template <typename T1, typename T2> diff --git a/js/src/jit/loong64/Lowering-loong64.cpp b/js/src/jit/loong64/Lowering-loong64.cpp @@ -87,9 +87,10 @@ void LIRGeneratorLOONG64::lowerForALUInt64( LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0>* ins, MDefinition* mir, MDefinition* lhs, MDefinition* rhs) { ins->setInt64Operand(0, useInt64RegisterAtStart(lhs)); - ins->setInt64Operand(INT64_PIECES, willHaveDifferentLIRNodes(lhs, rhs) - ? useInt64OrConstant(rhs) - : useInt64OrConstantAtStart(rhs)); + ins->setInt64Operand(INT64_PIECES, + willHaveDifferentLIRNodes(lhs, rhs) + ? useInt64RegisterOrConstant(rhs) + : useInt64RegisterOrConstantAtStart(rhs)); defineInt64ReuseInput(ins, mir, 0); } @@ -101,8 +102,8 @@ void LIRGeneratorLOONG64::lowerForMulInt64(LMulI64* ins, MMul* mir, ins->setLhs(useInt64RegisterAtStart(lhs)); ins->setRhs((willHaveDifferentLIRNodes(lhs, rhs) || cannotAliasRhs) - ? useInt64OrConstant(rhs) - : useInt64OrConstantAtStart(rhs)); + ? useInt64RegisterOrConstant(rhs) + : useInt64RegisterOrConstantAtStart(rhs)); if (needsTemp) { ins->setTemp0(temp()); diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp @@ -59,11 +59,6 @@ Operand CodeGeneratorMIPSShared::ToOperand(const LDefinition* def) { return ToOperand(def->output()); } -Operand CodeGeneratorMIPSShared::ToOperandOrRegister64( - const LInt64Allocation& input) { - return ToOperand(input.value()); -} - void CodeGeneratorMIPSShared::branchToBlock(Assembler::FloatFormat fmt, FloatRegister lhs, FloatRegister rhs, MBasicBlock* mir, @@ -204,7 +199,7 @@ void CodeGenerator::visitAddI64(LAddI64* lir) { return; } - masm.add64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.add64(ToRegister64(rhs), ToRegister64(lhs)); } void CodeGenerator::visitSubI(LSubI* ins) { @@ -259,7 +254,7 @@ void CodeGenerator::visitSubI64(LSubI64* lir) { return; } - masm.sub64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.sub64(ToRegister64(rhs), ToRegister64(lhs)); } void CodeGenerator::visitMulI(LMulI* ins) { @@ -479,7 +474,7 @@ void CodeGenerator::visitMulI64(LMulI64* lir) { } } else { Register temp = ToTempRegisterOrInvalid(lir->temp0()); - masm.mul64(ToOperandOrRegister64(rhs), ToRegister64(lhs), temp); + masm.mul64(ToRegister64(rhs), ToRegister64(lhs), temp); } } @@ -778,21 +773,21 @@ void CodeGenerator::visitBitOpI64(LBitOpI64* lir) { if (IsConstant(rhs)) { masm.or64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.or64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.or64(ToRegister64(rhs), ToRegister64(lhs)); } break; case JSOp::BitXor: if (IsConstant(rhs)) { masm.xor64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.xor64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.xor64(ToRegister64(rhs), ToRegister64(lhs)); } break; case JSOp::BitAnd: if (IsConstant(rhs)) { masm.and64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.and64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.and64(ToRegister64(rhs), ToRegister64(lhs)); } break; default: diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.h b/js/src/jit/mips-shared/CodeGenerator-mips-shared.h @@ -32,8 +32,6 @@ class CodeGeneratorMIPSShared : public CodeGeneratorShared { Operand ToOperand(const LAllocation* a); Operand ToOperand(const LDefinition* def); - Operand ToOperandOrRegister64(const LInt64Allocation& input); - MoveOperand toMoveOperand(LAllocation a) const; template <typename T1, typename T2> diff --git a/js/src/jit/mips-shared/Lowering-mips-shared.cpp b/js/src/jit/mips-shared/Lowering-mips-shared.cpp @@ -61,9 +61,10 @@ void LIRGeneratorMIPSShared::lowerForALUInt64( LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0>* ins, MDefinition* mir, MDefinition* lhs, MDefinition* rhs) { ins->setInt64Operand(0, useInt64RegisterAtStart(lhs)); - ins->setInt64Operand(INT64_PIECES, willHaveDifferentLIRNodes(lhs, rhs) - ? useInt64OrConstant(rhs) - : useInt64OrConstantAtStart(rhs)); + ins->setInt64Operand(INT64_PIECES, + willHaveDifferentLIRNodes(lhs, rhs) + ? useInt64RegisterOrConstant(rhs) + : useInt64RegisterOrConstantAtStart(rhs)); defineInt64ReuseInput(ins, mir, 0); } @@ -76,8 +77,8 @@ void LIRGeneratorMIPSShared::lowerForMulInt64(LMulI64* ins, MMul* mir, ins->setLhs(useInt64RegisterAtStart(lhs)); ins->setRhs((willHaveDifferentLIRNodes(lhs, rhs) || cannotAliasRhs) - ? useInt64OrConstant(rhs) - : useInt64OrConstantAtStart(rhs)); + ? useInt64RegisterOrConstant(rhs) + : useInt64RegisterOrConstantAtStart(rhs)); if (needsTemp) { ins->setTemp0(temp()); diff --git a/js/src/jit/riscv64/CodeGenerator-riscv64.cpp b/js/src/jit/riscv64/CodeGenerator-riscv64.cpp @@ -54,18 +54,6 @@ Operand CodeGeneratorRiscv64::ToOperand(const LDefinition* def) { return ToOperand(def->output()); } -#ifdef JS_PUNBOX64 -Operand CodeGeneratorRiscv64::ToOperandOrRegister64( - const LInt64Allocation& input) { - return ToOperand(input.value()); -} -#else -Register64 CodeGeneratorRiscv64::ToOperandOrRegister64( - const LInt64Allocation& input) { - return ToRegister64(input); -} -#endif - void CodeGeneratorRiscv64::branchToBlock(FloatFormat fmt, FloatRegister lhs, FloatRegister rhs, MBasicBlock* mir, Assembler::DoubleCondition cond) { @@ -736,7 +724,7 @@ void CodeGenerator::visitAddI64(LAddI64* lir) { return; } - masm.add64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.add64(ToRegister64(rhs), ToRegister64(lhs)); } void CodeGenerator::visitSubI(LSubI* ins) { @@ -792,7 +780,7 @@ void CodeGenerator::visitSubI64(LSubI64* lir) { return; } - masm.sub64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.sub64(ToRegister64(rhs), ToRegister64(lhs)); } void CodeGenerator::visitMulI(LMulI* ins) { @@ -1046,7 +1034,7 @@ void CodeGenerator::visitMulI64(LMulI64* lir) { } } else { Register temp = ToTempRegisterOrInvalid(lir->temp0()); - masm.mul64(ToOperandOrRegister64(rhs), ToRegister64(lhs), temp); + masm.mul64(ToRegister64(rhs), ToRegister64(lhs), temp); } } @@ -1353,21 +1341,21 @@ void CodeGenerator::visitBitOpI64(LBitOpI64* lir) { if (IsConstant(rhs)) { masm.or64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.or64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.or64(ToRegister64(rhs), ToRegister64(lhs)); } break; case JSOp::BitXor: if (IsConstant(rhs)) { masm.xor64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.xor64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.xor64(ToRegister64(rhs), ToRegister64(lhs)); } break; case JSOp::BitAnd: if (IsConstant(rhs)) { masm.and64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); } else { - masm.and64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); + masm.and64(ToRegister64(rhs), ToRegister64(lhs)); } break; default: diff --git a/js/src/jit/riscv64/CodeGenerator-riscv64.h b/js/src/jit/riscv64/CodeGenerator-riscv64.h @@ -33,12 +33,6 @@ class CodeGeneratorRiscv64 : public CodeGeneratorShared { Operand ToOperand(const LAllocation* a); Operand ToOperand(const LDefinition* def); -#ifdef JS_PUNBOX64 - Operand ToOperandOrRegister64(const LInt64Allocation& input); -#else - Register64 ToOperandOrRegister64(const LInt64Allocation& input); -#endif - MoveOperand toMoveOperand(LAllocation a) const; template <typename T1, typename T2> diff --git a/js/src/jit/riscv64/Lowering-riscv64.cpp b/js/src/jit/riscv64/Lowering-riscv64.cpp @@ -88,9 +88,10 @@ void LIRGeneratorRiscv64::lowerForALUInt64( LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0>* ins, MDefinition* mir, MDefinition* lhs, MDefinition* rhs) { ins->setInt64Operand(0, useInt64RegisterAtStart(lhs)); - ins->setInt64Operand(INT64_PIECES, willHaveDifferentLIRNodes(lhs, rhs) - ? useInt64OrConstant(rhs) - : useInt64OrConstantAtStart(rhs)); + ins->setInt64Operand(INT64_PIECES, + willHaveDifferentLIRNodes(lhs, rhs) + ? useInt64RegisterOrConstant(rhs) + : useInt64RegisterOrConstantAtStart(rhs)); defineInt64ReuseInput(ins, mir, 0); } @@ -102,8 +103,8 @@ void LIRGeneratorRiscv64::lowerForMulInt64(LMulI64* ins, MMul* mir, ins->setLhs(useInt64RegisterAtStart(lhs)); ins->setRhs((willHaveDifferentLIRNodes(lhs, rhs) || cannotAliasRhs) - ? useInt64OrConstant(rhs) - : useInt64OrConstantAtStart(rhs)); + ? useInt64RegisterOrConstant(rhs) + : useInt64RegisterOrConstantAtStart(rhs)); if (needsTemp) { ins->setTemp0(temp());