Changeset 37453 in webkit for trunk/JavaScriptCore/VM/CTI.cpp
- Timestamp:
- Oct 9, 2008, 4:59:26 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CTI.cpp
r37438 r37453 415 415 ALWAYS_INLINE void CTI::emitFastArithDeTagImmediate(X86Assembler::RegisterID reg) 416 416 { 417 // op_mod relies on this being a sub - setting zf if result is 0.418 417 m_jit.subl_i8r(JSImmediate::TagBitTypeInteger, reg); 418 } 419 420 ALWAYS_INLINE X86Assembler::JmpSrc CTI::emitFastArithDeTagImmediateJumpIfZero(X86Assembler::RegisterID reg) 421 { 422 m_jit.subl_i8r(JSImmediate::TagBitTypeInteger, reg); 423 return m_jit.emitUnlinkedJe(); 419 424 } 420 425 … … 809 814 } else { 810 815 ASSERT(opcodeID == op_mul); 811 emitFastArithDeTagImmediate(X86::eax);816 // convert eax & edx from JSImmediates to ints, and check if either are zero 812 817 emitFastArithImmToInt(X86::edx); 818 X86Assembler::JmpSrc op1Zero = emitFastArithDeTagImmediateJumpIfZero(X86::eax); 819 m_jit.testl_rr(X86::edx, X86::edx); 820 X86Assembler::JmpSrc op2NonZero = m_jit.emitUnlinkedJne(); 821 m_jit.link(op1Zero, m_jit.label()); 822 // if either input is zero, add the two together, and check if the result is < 0. 823 // If it is, we have a problem (N < 0), (N * 0) == -0, not representatble as a JSImmediate. 824 m_jit.movl_rr(X86::eax, X86::ecx); 825 m_jit.addl_rr(X86::edx, X86::ecx); 826 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJs(), i)); 827 // Skip the above check if neither input is zero 828 m_jit.link(op2NonZero, m_jit.label()); 813 829 m_jit.imull_rr(X86::edx, X86::eax); 814 830 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJo(), i)); … … 852 868 m_jit.link((++iter)->from, here); 853 869 } else 870 m_jit.link((++iter)->from, here); 871 872 // additional entry point to handle -0 cases. 873 if (opcodeID == op_mul) 854 874 m_jit.link((++iter)->from, here); 855 875 … … 1140 1160 unsigned src2 = instruction[i + 3].u.operand; 1141 1161 1142 if (JSValue* src1Value = getConstantImmediateNumericArg(src1)) { 1162 // For now, only plant a fast int case if the constant operand is greater than zero. 1163 JSValue* src1Value = getConstantImmediateNumericArg(src1); 1164 JSValue* src2Value = getConstantImmediateNumericArg(src2); 1165 int32_t value; 1166 if (src1Value && ((value = JSImmediate::intValue(src1Value)) > 0)) { 1143 1167 emitGetArg(src2, X86::eax); 1144 1168 emitJumpSlowCaseIfNotImmNum(X86::eax, i); 1145 emitFastArith ImmToInt(X86::eax);1146 m_jit.imull_i32r(X86::eax, getDeTaggedConstantImmediate(src1Value), X86::eax);1169 emitFastArithDeTagImmediate(X86::eax); 1170 m_jit.imull_i32r(X86::eax, value, X86::eax); 1147 1171 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJo(), i)); 1148 1172 emitFastArithReTagImmediate(X86::eax); 1149 1173 emitPutResult(dst); 1150 } else if ( JSValue* src2Value = getConstantImmediateNumericArg(src2)) {1174 } else if (src2Value && ((value = JSImmediate::intValue(src2Value)) > 0)) { 1151 1175 emitGetArg(src1, X86::eax); 1152 1176 emitJumpSlowCaseIfNotImmNum(X86::eax, i); 1153 emitFastArith ImmToInt(X86::eax);1154 m_jit.imull_i32r(X86::eax, getDeTaggedConstantImmediate(src2Value), X86::eax);1177 emitFastArithDeTagImmediate(X86::eax); 1178 m_jit.imull_i32r(X86::eax, value, X86::eax); 1155 1179 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJo(), i)); 1156 1180 emitFastArithReTagImmediate(X86::eax); … … 1628 1652 emitJumpSlowCaseIfNotImmNum(X86::ecx, i); 1629 1653 emitFastArithDeTagImmediate(X86::eax); 1630 emitFastArithDeTagImmediate(X86::ecx); 1631 m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJe(), i)); // This is checking if the last detag resulted in a value 0. 1654 m_slowCases.append(SlowCaseEntry(emitFastArithDeTagImmediateJumpIfZero(X86::ecx), i)); 1632 1655 m_jit.cdq(); 1633 1656 m_jit.idivl_r(X86::ecx); … … 2510 2533 int src1 = instruction[i + 2].u.operand; 2511 2534 int src2 = instruction[i + 3].u.operand; 2512 if (getConstantImmediateNumericArg(src1) || getConstantImmediateNumericArg(src2)) { 2535 JSValue* src1Value = getConstantImmediateNumericArg(src1); 2536 JSValue* src2Value = getConstantImmediateNumericArg(src2); 2537 int32_t value; 2538 if (src1Value && ((value = JSImmediate::intValue(src1Value)) > 0)) { 2513 2539 m_jit.link(iter->from, m_jit.label()); 2540 // There is an extra slow case for (op1 * -N) or (-N * op2), to check for 0 since this should produce a result of -0. 2541 emitGetPutArg(src1, 0, X86::ecx); 2542 emitGetPutArg(src2, 4, X86::ecx); 2543 emitCall(i, Machine::cti_op_mul); 2544 emitPutResult(dst); 2545 } else if (src2Value && ((value = JSImmediate::intValue(src2Value)) > 0)) { 2546 m_jit.link(iter->from, m_jit.label()); 2547 // There is an extra slow case for (op1 * -N) or (-N * op2), to check for 0 since this should produce a result of -0. 2514 2548 emitGetPutArg(src1, 0, X86::ecx); 2515 2549 emitGetPutArg(src2, 4, X86::ecx);
Note:
See TracChangeset
for help on using the changeset viewer.