Changeset 229287 in webkit for trunk/Source/JavaScriptCore/offlineasm/cloop.rb
- Timestamp:
- Mar 5, 2018, 10:31:40 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/offlineasm/cloop.rb
r228402 r229287 481 481 end 482 482 483 def cloop AddOverflowTest(operands, type)483 def cloopEmitOpAndBranchIfOverflow(operands, operator, type) 484 484 case type 485 485 when :int32 486 486 tempType = "int32_t" 487 signBit = "SIGN_BIT32"488 487 else 489 488 raise "Unimplemented type" 490 489 end 491 490 492 $asm.putc " #{tempType} a = #{operands[0].clValue(type)};"493 $asm.putc " #{tempType} b = #{operands[1].clValue(type)};"494 $asm.putc " // sign(b) sign(a) | Overflows if:"495 $asm.putc " // 0 0 | sign(b+a) = 1 (pos + pos != neg)"496 $asm.putc " // 0 1 | never"497 $asm.putc " // 1 0 | never"498 $asm.putc " // 1 1 | sign(b+a) = 0 (neg + neg != pos)"499 "((#{signBit}(b) == #{signBit}(a)) && (#{signBit}(b+a) != #{signBit}(a)))"500 end501 502 def cloopSubOverflowTest(operands, type)503 case type504 when :int32505 tempType = "int32_t"506 signBit = "SIGN_BIT32"507 else508 raise "Unimplemented type"509 end510 511 $asm.putc " #{tempType} a = #{operands[0].clValue(type)};"512 $asm.putc " #{tempType} b = #{operands[1].clValue(type)};"513 $asm.putc " // sign(b) sign(a) | Overflows if:"514 $asm.putc " // 0 0 | never"515 $asm.putc " // 0 1 | sign(b-a) = 1 (pos - neg != pos)"516 $asm.putc " // 1 0 | sign(b-a) = 0 (neg - pos != pos)"517 $asm.putc " // 1 1 | never"518 "((#{signBit}(b) != #{signBit}(a)) && (#{signBit}(b-a) == #{signBit}(a)))"519 end520 521 def cloopMulOverflowTest(operands, type)522 case type523 when :int32524 tempType = "uint32_t"525 else526 raise "Unimplemented type"527 end528 $asm.putc " #{tempType} a = #{operands[0].clValue(type)};"529 $asm.putc " #{tempType} b = #{operands[1].clValue(type)};"530 "((b | a) >> 15)"531 end532 533 def cloopEmitOpAndBranchIfOverflow(operands, operator, type)534 491 $asm.putc "{" 535 492 536 493 # Emit the overflow test based on the operands and the type: 537 494 case operator 538 when "+"; o verflowTest = cloopAddOverflowTest(operands, type)539 when "-"; o verflowTest = cloopSubOverflowTest(operands, type)540 when "*"; o verflowTest = cloopMulOverflowTest(operands, type)495 when "+"; operation = "add" 496 when "-"; operation = "sub" 497 when "*"; operation = "multiply" 541 498 else 542 499 raise "Unimplemented opeartor" 543 500 end 544 501 545 $asm.putc " bool didOverflow = #{overflowTest};" 546 $asm.putc " #{operands[1].clValue(type)} = #{operands[1].clValue(type)} #{operator} #{operands[0].clValue(type)};" 547 $asm.putc " if (didOverflow)" 502 $asm.putc " if (!WTF::ArithmeticOperations<#{tempType}, #{tempType}, #{tempType}>::#{operation}(#{operands[1].clValue(type)}, #{operands[0].clValue(type)}, #{operands[1].clValue(type)}))" 548 503 $asm.putc " goto #{operands[2].cLabel};" 549 504 $asm.putc "}"
Note:
See TracChangeset
for help on using the changeset viewer.