@@ -5140,28 +5140,34 @@ void SpeculativeJIT::compileArithSub(Node* node)
51405140 int32_t imm2 = node->child2()->asInt32();
51415141 GPRTemporary result(this);
51425142
5143- if (!shouldCheckOverflow(node->arithMode())) {
5144- move(op1.gpr(), result.gpr());
5145- sub32(Imm32(imm2), result.gpr());
5146- } else {
5143+ GPRReg op1GPR = op1.gpr();
5144+ GPRReg resultGPR = result.gpr();
5145+
5146+ if (!shouldCheckOverflow(node->arithMode()))
5147+ sub32(op1GPR, Imm32(imm2), resultGPR);
5148+ else {
51475149 GPRTemporary scratch(this);
5148- speculationCheck(ExitKind::Overflow, JSValueRegs(), nullptr, branchSub32(Overflow, op1.gpr(), Imm32(imm2), result.gpr(), scratch.gpr()));
5150+ GPRReg scratchGPR = scratch.gpr();
5151+ speculationCheck(ExitKind::Overflow, JSValueRegs(), nullptr, branchSub32(Overflow, op1GPR, Imm32(imm2), resultGPR, scratchGPR));
51495152 }
51505153
5151- strictInt32Result(result.gpr() , node);
5154+ strictInt32Result(resultGPR , node);
51525155 return;
51535156 }
51545157
51555158 if (node->child1()->isInt32Constant()) {
51565159 int32_t imm1 = node->child1()->asInt32();
51575160 SpeculateInt32Operand op2(this, node->child2());
51585161 GPRTemporary result(this);
5162+
5163+ GPRReg op2GPR = op2.gpr();
5164+ GPRReg resultGPR = result.gpr();
51595165
5160- move(Imm32(imm1), result.gpr() );
5166+ move(Imm32(imm1), resultGPR );
51615167 if (!shouldCheckOverflow(node->arithMode()))
5162- sub32(op2.gpr(), result.gpr() );
5168+ sub32(op2GPR, resultGPR );
51635169 else
5164- speculationCheck(ExitKind::Overflow, JSValueRegs(), nullptr, branchSub32(Overflow, op2.gpr(), result.gpr() ));
5170+ speculationCheck(ExitKind::Overflow, JSValueRegs(), nullptr, branchSub32(Overflow, op2GPR, resultGPR ));
51655171
51665172 strictInt32Result(result.gpr(), node);
51675173 return;
@@ -5171,13 +5177,16 @@ void SpeculativeJIT::compileArithSub(Node* node)
51715177 SpeculateInt32Operand op2(this, node->child2());
51725178 GPRTemporary result(this);
51735179
5174- if (!shouldCheckOverflow(node->arithMode())) {
5175- move(op1.gpr(), result.gpr());
5176- sub32(op2.gpr(), result.gpr());
5177- } else
5178- speculationCheck(ExitKind::Overflow, JSValueRegs(), nullptr, branchSub32(Overflow, op1.gpr(), op2.gpr(), result.gpr()));
5180+ GPRReg op1GPR = op1.gpr();
5181+ GPRReg op2GPR = op2.gpr();
5182+ GPRReg resultGPR = result.gpr();
51795183
5180- strictInt32Result(result.gpr(), node);
5184+ if (!shouldCheckOverflow(node->arithMode()))
5185+ sub32(op1GPR, op2GPR, resultGPR);
5186+ else
5187+ speculationCheck(ExitKind::Overflow, JSValueRegs(), nullptr, branchSub32(Overflow, op1GPR, op2GPR, resultGPR));
5188+
5189+ strictInt32Result(resultGPR, node);
51815190 return;
51825191 }
51835192
@@ -5193,20 +5202,31 @@ void SpeculativeJIT::compileArithSub(Node* node)
51935202 SpeculateWhicheverInt52Operand op1(this, node->child1());
51945203 SpeculateWhicheverInt52Operand op2(this, node->child2(), op1);
51955204 GPRTemporary result(this, Reuse, op1);
5196- move(op1.gpr(), result.gpr());
5197- sub64(op2.gpr(), result.gpr());
5198- int52Result(result.gpr(), node, op1.format());
5205+
5206+ GPRReg op1GPR = op1.gpr();
5207+ GPRReg op2GPR = op2.gpr();
5208+ GPRReg resultGPR = result.gpr();
5209+
5210+ sub64(op1GPR, op2GPR, resultGPR);
5211+ int52Result(resultGPR, node, op1.format());
51995212 return;
52005213 }
52015214
52025215 SpeculateInt52Operand op1(this, node->child1());
52035216 SpeculateInt52Operand op2(this, node->child2());
52045217 GPRTemporary result(this);
5205- move(op1.gpr(), result.gpr());
5206- speculationCheck(
5207- Int52Overflow, JSValueRegs(), nullptr,
5208- branchSub64(Overflow, op2.gpr(), result.gpr()));
5209- int52Result(result.gpr(), node);
5218+
5219+ GPRReg op1GPR = op1.gpr();
5220+ GPRReg op2GPR = op2.gpr();
5221+ GPRReg resultGPR = result.gpr();
5222+
5223+ #if CPU(ARM64)
5224+ speculationCheck(Int52Overflow, JSValueRegs(), nullptr, branchSub64(Overflow, op1GPR, op2GPR, resultGPR));
5225+ #else
5226+ move(op1GPR, resultGPR);
5227+ speculationCheck(Int52Overflow, JSValueRegs(), nullptr, branchSub64(Overflow, op2GPR, resultGPR));
5228+ #endif
5229+ int52Result(resultGPR, node);
52105230 return;
52115231 }
52125232#endif // USE(JSVALUE64)
@@ -5216,11 +5236,12 @@ void SpeculativeJIT::compileArithSub(Node* node)
52165236 SpeculateDoubleOperand op2(this, node->child2());
52175237 FPRTemporary result(this, op1);
52185238
5219- FPRReg reg1 = op1.fpr();
5220- FPRReg reg2 = op2.fpr();
5221- subDouble(reg1, reg2, result.fpr() );
5239+ FPRReg op1FPR = op1.fpr();
5240+ FPRReg op2FPR = op2.fpr();
5241+ FPRReg resultFPR = result.fpr();
52225242
5223- doubleResult(result.fpr(), node);
5243+ subDouble(op1FPR, op2FPR, resultFPR);
5244+ doubleResult(resultFPR, node);
52245245 return;
52255246 }
52265247
0 commit comments