summaryrefslogtreecommitdiff
path: root/js/src/jit/CodeGenerator.cpp
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-09-17 12:39:03 -0500
committerBrian Smith <brian@dbsoft.org>2023-09-17 12:39:03 -0500
commit99184b1764286b99927adba7702620e29fb601f4 (patch)
tree44c7649249dc0a78905e22892b940ddf165b77e3 /js/src/jit/CodeGenerator.cpp
parent8f26f1a87321c47622bdeac2f610d31c33970b7e (diff)
downloaduxp-99184b1764286b99927adba7702620e29fb601f4.tar.gz
Issue #2308 & #1240 Follow-up - Replace JSOP_POS in ++/-- with JSOP_TONUMERIC.
https://bugzilla.mozilla.org/show_bug.cgi?id=1519135
Diffstat (limited to 'js/src/jit/CodeGenerator.cpp')
-rw-r--r--js/src/jit/CodeGenerator.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp
index 5c2d9ac4e7..f2c3076f99 100644
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -3416,6 +3416,48 @@ CodeGenerator::visitLoadUnboxedExpando(LLoadUnboxedExpando* lir)
}
void
+CodeGenerator::visitToNumeric(LToNumeric* lir)
+{
+ ValueOperand operand = ToValue(lir, LToNumeric::Input);
+ ValueOperand output = ToOutValue(lir);
+ bool maybeInt32 = lir->mir()->mightBeType(MIRType::Int32);
+ bool maybeDouble = lir->mir()->mightBeType(MIRType::Double);
+ bool maybeNumber = maybeInt32 || maybeDouble;
+ bool maybeBigInt = lir->mir()->mightBeType(MIRType::BigInt);
+ int checks = int(maybeNumber) + int(maybeBigInt);
+
+ OutOfLineCode* ool = oolCallVM(ToNumericInfo, lir, ArgList(operand), StoreValueTo(output));
+
+ if (checks == 0) {
+ masm.jump(ool->entry());
+ } else {
+ Label done;
+ using Condition = Assembler::Condition;
+ constexpr Condition Equal = Assembler::Equal;
+ constexpr Condition NotEqual = Assembler::NotEqual;
+
+ if (maybeNumber) {
+ checks--;
+ Condition cond = checks ? Equal : NotEqual;
+ Label* target = checks ? &done : ool->entry();
+ masm.branchTestNumber(cond, operand, target);
+ }
+ if (maybeBigInt) {
+ checks--;
+ Condition cond = checks ? Equal : NotEqual;
+ Label* target = checks ? &done : ool->entry();
+ masm.branchTestBigInt(cond, operand, target);
+ }
+
+ MOZ_ASSERT(checks == 0);
+ masm.bind(&done);
+ masm.moveValue(operand, output);
+ }
+
+ masm.bind(ool->rejoin());
+}
+
+void
CodeGenerator::visitTypeBarrierV(LTypeBarrierV* lir)
{
ValueOperand operand = ToValue(lir, LTypeBarrierV::Input);