Changeset 39738 in webkit for trunk/JavaScriptCore/jit/JITArithmetic.cpp
- Timestamp:
- Jan 9, 2009, 12:11:00 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/jit/JITArithmetic.cpp
r39670 r39738 61 61 #endif 62 62 lshift32(X86::ecx, X86::eax); 63 #if USE(ALTERNATE_JSIMMEDIATE) 64 emitFastArithIntToImmNoCheck(X86::eax); 65 #else 63 #if !USE(ALTERNATE_JSIMMEDIATE) 66 64 addSlowCase(joAdd32(X86::eax, X86::eax)); 67 65 signExtend32ToPtr(X86::eax, X86::eax); 68 emitFastArithReTagImmediate(X86::eax); 69 #endif 66 #endif 67 emitFastArithReTagImmediate(X86::eax, X86::eax); 70 68 emitPutVirtualRegister(result); 71 69 } … … 98 96 emitJumpSlowCaseIfNotImmNum(X86::eax); 99 97 // Mask with 0x1f as per ecma-262 11.7.2 step 7. 98 #if USE(ALTERNATE_JSIMMEDIATE) 99 rshift32(Imm32(JSImmediate::getTruncatedUInt32(getConstantOperand(op2)) & 0x1f), X86::eax); 100 #else 100 101 rshiftPtr(Imm32(JSImmediate::getTruncatedUInt32(getConstantOperand(op2)) & 0x1f), X86::eax); 102 #endif 101 103 } else { 102 104 emitGetVirtualRegisters(op1, X86::eax, op2, X86::ecx); … … 109 111 and32(Imm32(0x1f), X86::ecx); 110 112 #endif 113 #if USE(ALTERNATE_JSIMMEDIATE) 114 rshift32(X86::ecx, X86::eax); 115 #else 111 116 rshiftPtr(X86::ecx, X86::eax); 112 } 113 orPtr(Imm32(JSImmediate::TagBitTypeInteger), X86::eax); 117 #endif 118 } 119 #if USE(ALTERNATE_JSIMMEDIATE) 120 emitFastArithIntToImmNoCheck(X86::eax, X86::eax); 121 #else 122 orPtr(Imm32(JSImmediate::TagTypeInteger), X86::eax); 123 #endif 114 124 emitPutVirtualRegister(result); 115 125 } … … 131 141 void JIT::compileFastArith_op_bitand(unsigned result, unsigned op1, unsigned op2) 132 142 { 133 if (isOperandConstant 31BitImmediateInt(op1)) {143 if (isOperandConstantImmediateInt(op1)) { 134 144 emitGetVirtualRegister(op2, X86::eax); 135 145 emitJumpSlowCaseIfNotImmNum(X86::eax); 146 #if USE(ALTERNATE_JSIMMEDIATE) 147 int32_t imm = JSImmediate::intValue(getConstantOperand(op1)); 148 andPtr(Imm32(imm), X86::eax); 149 if (imm >= 0) 150 emitFastArithIntToImmNoCheck(X86::eax, X86::eax); 151 #else 136 152 andPtr(Imm32(static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op1)))), X86::eax); 137 } else if (isOperandConstant31BitImmediateInt(op2)) { 153 #endif 154 } else if (isOperandConstantImmediateInt(op2)) { 138 155 emitGetVirtualRegister(op1, X86::eax); 139 156 emitJumpSlowCaseIfNotImmNum(X86::eax); 157 #if USE(ALTERNATE_JSIMMEDIATE) 158 int32_t imm = JSImmediate::intValue(getConstantOperand(op2)); 159 andPtr(Imm32(imm), X86::eax); 160 if (imm >= 0) 161 emitFastArithIntToImmNoCheck(X86::eax, X86::eax); 162 #else 140 163 andPtr(Imm32(static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op2)))), X86::eax); 164 #endif 141 165 } else { 142 166 emitGetVirtualRegisters(op1, X86::eax, op2, X86::edx); … … 149 173 { 150 174 linkSlowCase(iter); 151 if (isOperandConstant 31BitImmediateInt(op1)) {175 if (isOperandConstantImmediateInt(op1)) { 152 176 emitPutJITStubArgFromVirtualRegister(op1, 1, X86::ecx); 153 177 emitPutJITStubArg(X86::eax, 2); 154 } else if (isOperandConstant 31BitImmediateInt(op2)) {178 } else if (isOperandConstantImmediateInt(op2)) { 155 179 emitPutJITStubArg(X86::eax, 1); 156 180 emitPutJITStubArgFromVirtualRegister(op2, 2, X86::ecx); … … 169 193 emitJumpSlowCaseIfNotImmNum(X86::ecx); 170 194 #if USE(ALTERNATE_JSIMMEDIATE) 171 addSlowCase(jePtr(X86::ecx, ImmPtr(JSImmediate::zeroImmediate()))); 172 emitFastArithImmToInt(X86::eax); 173 emitFastArithImmToInt(X86::ecx); 195 addSlowCase(jePtr(X86::ecx, ImmPtr(JSValuePtr::encode(JSImmediate::zeroImmediate())))); 174 196 mod32(X86::ecx, X86::eax, X86::edx); 175 emitFastArithIntToImmNoCheck(X86::edx);176 197 #else 177 198 emitFastArithDeTagImmediate(X86::eax); … … 179 200 mod32(X86::ecx, X86::eax, X86::edx); 180 201 signExtend32ToPtr(X86::edx, X86::edx); 181 emitFastArithReTagImmediate(X86::edx); 182 #endif 183 move(X86::edx, X86::eax); 202 #endif 203 emitFastArithReTagImmediate(X86::edx, X86::eax); 184 204 emitPutVirtualRegister(result); 185 205 } … … 194 214 Jump notImm2 = getSlowCase(iter); 195 215 linkSlowCase(iter); 196 emitFastArithReTagImmediate(X86::eax );197 emitFastArithReTagImmediate(X86::ecx );216 emitFastArithReTagImmediate(X86::eax, X86::eax); 217 emitFastArithReTagImmediate(X86::ecx, X86::ecx); 198 218 notImm1.link(this); 199 219 notImm2.link(this); … … 217 237 // FIXME: investigate performing a 31-bit add here (can we preserve upper bit & detect overflow from low word to high?) 218 238 // (or, detect carry? - if const is positive, will only carry when overflowing from negative to positive?) 219 emitFastArithImmToInt(X86::eax);220 239 addSlowCase(joAdd32(Imm32(getConstantOperandImmediateInt(op1)), X86::eax)); 221 emitFastArithIntToImmNoCheck(X86::eax );240 emitFastArithIntToImmNoCheck(X86::eax, X86::eax); 222 241 #else 223 242 addSlowCase(joAdd32(Imm32(getConstantOperandImmediateInt(op1) << JSImmediate::IntegerPayloadShift), X86::eax)); … … 231 250 emitFastArithImmToInt(X86::eax); 232 251 addSlowCase(joAdd32(Imm32(getConstantOperandImmediateInt(op2)), X86::eax)); 233 emitFastArithIntToImmNoCheck(X86::eax );252 emitFastArithIntToImmNoCheck(X86::eax, X86::eax); 234 253 #else 235 254 addSlowCase(joAdd32(Imm32(getConstantOperandImmediateInt(op2) << JSImmediate::IntegerPayloadShift), X86::eax)); … … 306 325 emitJumpSlowCaseIfNotImmNum(X86::eax); 307 326 #if USE(ALTERNATE_JSIMMEDIATE) 308 emitFastArithImmToInt(X86::eax);309 327 addSlowCase(joMul32(Imm32(value), X86::eax, X86::eax)); 310 emitFastArithIntToImmNoCheck(X86::eax);311 328 #else 312 329 emitFastArithDeTagImmediate(X86::eax); 313 330 addSlowCase(joMul32(Imm32(value), X86::eax, X86::eax)); 314 331 signExtend32ToPtr(X86::eax, X86::eax); 315 emitFastArithReTagImmediate(X86::eax); 316 #endif 332 #endif 333 emitFastArithReTagImmediate(X86::eax, X86::eax); 317 334 emitPutVirtualRegister(result); 318 335 } else if (isOperandConstantImmediateInt(op2) && ((value = getConstantOperandImmediateInt(op2)) > 0)) { … … 320 337 emitJumpSlowCaseIfNotImmNum(X86::eax); 321 338 #if USE(ALTERNATE_JSIMMEDIATE) 322 emitFastArithImmToInt(X86::eax);323 339 addSlowCase(joMul32(Imm32(value), X86::eax, X86::eax)); 324 emitFastArithIntToImmNoCheck(X86::eax);325 340 #else 326 341 emitFastArithDeTagImmediate(X86::eax); 327 342 addSlowCase(joMul32(Imm32(value), X86::eax, X86::eax)); 328 343 signExtend32ToPtr(X86::eax, X86::eax); 329 emitFastArithReTagImmediate(X86::eax); 330 #endif 344 #endif 345 emitFastArithReTagImmediate(X86::eax, X86::eax); 331 346 emitPutVirtualRegister(result); 332 347 } else … … 358 373 emitJumpSlowCaseIfNotImmNum(X86::eax); 359 374 #if USE(ALTERNATE_JSIMMEDIATE) 360 emitFastArithImmToInt(X86::edx);361 375 addSlowCase(joAdd32(Imm32(1), X86::edx)); 362 emitFastArithIntToImmNoCheck(X86::edx );376 emitFastArithIntToImmNoCheck(X86::edx, X86::edx); 363 377 #else 364 378 addSlowCase(joAdd32(Imm32(1 << JSImmediate::IntegerPayloadShift), X86::edx)); … … 384 398 emitJumpSlowCaseIfNotImmNum(X86::eax); 385 399 #if USE(ALTERNATE_JSIMMEDIATE) 386 emitFastArithImmToInt(X86::edx);387 400 addSlowCase(joSub32(Imm32(1), X86::edx)); 388 emitFastArithIntToImmNoCheck(X86::edx );401 emitFastArithIntToImmNoCheck(X86::edx, X86::edx); 389 402 #else 390 403 addSlowCase(joSub32(Imm32(1 << JSImmediate::IntegerPayloadShift), X86::edx)); … … 409 422 emitJumpSlowCaseIfNotImmNum(X86::eax); 410 423 #if USE(ALTERNATE_JSIMMEDIATE) 411 emitFastArithImmToInt(X86::eax);412 424 // FIXME: Could add ptr & specify int64; no need to re-sign-extend? 413 425 addSlowCase(joAdd32(Imm32(1), X86::eax)); 414 emitFastArithIntToImmNoCheck(X86::eax );426 emitFastArithIntToImmNoCheck(X86::eax, X86::eax); 415 427 #else 416 428 addSlowCase(joAdd32(Imm32(1 << JSImmediate::IntegerPayloadShift), X86::eax)); … … 435 447 emitJumpSlowCaseIfNotImmNum(X86::eax); 436 448 #if USE(ALTERNATE_JSIMMEDIATE) 437 emitFastArithImmToInt(X86::eax);438 449 addSlowCase(joSub32(Imm32(1), X86::eax)); 439 emitFastArithIntToImmNoCheck(X86::eax );450 emitFastArithIntToImmNoCheck(X86::eax, X86::eax); 440 451 #else 441 452 addSlowCase(joSub32(Imm32(1 << JSImmediate::IntegerPayloadShift), X86::eax)); … … 556 567 __ link(__ je(), resultLookedLikeImmButActuallyIsnt); // Actually was -0 557 568 // Yes it really really really is representable as a JSImmediate. 558 emitFastArithIntToImmNoCheck(tempReg1); 559 if (tempReg1 != X86::eax) 560 __ movl_rr(tempReg1, X86::eax); 569 emitFastArithIntToImmNoCheck(tempReg1, X86::eax); 561 570 emitPutVirtualRegister(dst); 562 571 } … … 576 585 577 586 // Check op2 is a number 578 __ testl_i32r(JSImmediate::Tag BitTypeInteger, X86::edx);587 __ testl_i32r(JSImmediate::TagTypeInteger, X86::edx); 579 588 JmpSrc op2imm = __ jne(); 580 589 if (!types.second().definitelyIsNumber()) { … … 586 595 // (1) In this case src2 is a reusable number cell. 587 596 // Slow case if src1 is not a number type. 588 __ testl_i32r(JSImmediate::Tag BitTypeInteger, X86::eax);597 __ testl_i32r(JSImmediate::TagTypeInteger, X86::eax); 589 598 JmpSrc op1imm = __ jne(); 590 599 if (!types.first().definitelyIsNumber()) { … … 623 632 624 633 // Check op1 is a number 625 __ testl_i32r(JSImmediate::Tag BitTypeInteger, X86::eax);634 __ testl_i32r(JSImmediate::TagTypeInteger, X86::eax); 626 635 JmpSrc op1imm = __ jne(); 627 636 if (!types.first().definitelyIsNumber()) { … … 633 642 // (1) In this case src1 is a reusable number cell. 634 643 // Slow case if src2 is not a number type. 635 __ testl_i32r(JSImmediate::Tag BitTypeInteger, X86::edx);644 __ testl_i32r(JSImmediate::TagTypeInteger, X86::edx); 636 645 JmpSrc op2imm = __ jne(); 637 646 if (!types.second().definitelyIsNumber()) { … … 680 689 addSlowCase(__ jo()); 681 690 signExtend32ToPtr(X86::eax, X86::eax); 682 emitFastArithReTagImmediate(X86::eax );691 emitFastArithReTagImmediate(X86::eax, X86::eax); 683 692 } else { 684 693 ASSERT(opcodeID == op_mul); … … 699 708 addSlowCase(__ jo()); 700 709 signExtend32ToPtr(X86::eax, X86::eax); 701 emitFastArithReTagImmediate(X86::eax );710 emitFastArithReTagImmediate(X86::eax, X86::eax); 702 711 } 703 712 emitPutVirtualRegister(dst);
Note:
See TracChangeset
for help on using the changeset viewer.