Title: [229287] trunk/Source/_javascript_Core
Revision
229287
Author
[email protected]
Date
2018-03-05 10:31:40 -0800 (Mon, 05 Mar 2018)

Log Message

[JSC] Use WTF::ArithmeticOperations for CLoop overflow operations
https://bugs.webkit.org/show_bug.cgi?id=183324

Reviewed by JF Bastien.

We have WTF::ArithmeticOperations which has operations with overflow checking.
This is suitable for CLoop's overflow checking operations. This patch emits
WTF::ArithmeticOperations for CLoop's overflow checking operations. And it is
lowered to optimized code using CPU's overflow flag.

* offlineasm/cloop.rb:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (229286 => 229287)


--- trunk/Source/_javascript_Core/ChangeLog	2018-03-05 18:15:48 UTC (rev 229286)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-03-05 18:31:40 UTC (rev 229287)
@@ -1,3 +1,17 @@
+2018-03-05  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Use WTF::ArithmeticOperations for CLoop overflow operations
+        https://bugs.webkit.org/show_bug.cgi?id=183324
+
+        Reviewed by JF Bastien.
+
+        We have WTF::ArithmeticOperations which has operations with overflow checking.
+        This is suitable for CLoop's overflow checking operations. This patch emits
+        WTF::ArithmeticOperations for CLoop's overflow checking operations. And it is
+        lowered to optimized code using CPU's overflow flag.
+
+        * offlineasm/cloop.rb:
+
 2018-03-05  Don Olmstead  <[email protected]>
 
         [CMake] Split JSC header copying into public and private targets

Modified: trunk/Source/_javascript_Core/offlineasm/cloop.rb (229286 => 229287)


--- trunk/Source/_javascript_Core/offlineasm/cloop.rb	2018-03-05 18:15:48 UTC (rev 229286)
+++ trunk/Source/_javascript_Core/offlineasm/cloop.rb	2018-03-05 18:31:40 UTC (rev 229287)
@@ -480,71 +480,26 @@
     $asm.putc "}"
 end
 
-def cloopAddOverflowTest(operands, type)
+def cloopEmitOpAndBranchIfOverflow(operands, operator, type)
     case type
     when :int32
         tempType = "int32_t"
-        signBit = "SIGN_BIT32"
     else
         raise "Unimplemented type"
     end
 
-    $asm.putc "    #{tempType} a = #{operands[0].clValue(type)};"
-    $asm.putc "    #{tempType} b = #{operands[1].clValue(type)};"
-    $asm.putc "    // sign(b) sign(a) | Overflows if:"
-    $asm.putc "    // 0       0       | sign(b+a) = 1 (pos + pos != neg)"
-    $asm.putc "    // 0       1       | never"
-    $asm.putc "    // 1       0       | never"
-    $asm.putc "    // 1       1       | sign(b+a) = 0 (neg + neg != pos)"
-    "((#{signBit}(b) == #{signBit}(a)) && (#{signBit}(b+a) != #{signBit}(a)))"
-end
-
-def cloopSubOverflowTest(operands, type)
-    case type
-    when :int32
-        tempType = "int32_t"
-        signBit = "SIGN_BIT32"
-    else
-        raise "Unimplemented type"
-    end
-
-    $asm.putc "    #{tempType} a = #{operands[0].clValue(type)};"
-    $asm.putc "    #{tempType} b = #{operands[1].clValue(type)};"
-    $asm.putc "    // sign(b) sign(a) | Overflows if:"
-    $asm.putc "    // 0       0       | never"
-    $asm.putc "    // 0       1       | sign(b-a) = 1 (pos - neg != pos)"
-    $asm.putc "    // 1       0       | sign(b-a) = 0 (neg - pos != pos)"
-    $asm.putc "    // 1       1       | never"
-    "((#{signBit}(b) != #{signBit}(a)) && (#{signBit}(b-a) == #{signBit}(a)))"
-end
-
-def cloopMulOverflowTest(operands, type)
-    case type
-    when :int32
-        tempType = "uint32_t"
-    else
-        raise "Unimplemented type"
-    end
-    $asm.putc "    #{tempType} a = #{operands[0].clValue(type)};"
-    $asm.putc "    #{tempType} b = #{operands[1].clValue(type)};"
-    "((b | a) >> 15)"
-end
-
-def cloopEmitOpAndBranchIfOverflow(operands, operator, type)
     $asm.putc "{"
 
     # Emit the overflow test based on the operands and the type:
     case operator
-    when "+"; overflowTest = cloopAddOverflowTest(operands, type)
-    when "-"; overflowTest = cloopSubOverflowTest(operands, type)
-    when "*"; overflowTest = cloopMulOverflowTest(operands, type)
+    when "+"; operation = "add"
+    when "-"; operation = "sub"
+    when "*"; operation = "multiply"
     else
         raise "Unimplemented opeartor"
     end
 
-    $asm.putc "    bool didOverflow = #{overflowTest};"
-    $asm.putc "    #{operands[1].clValue(type)} = #{operands[1].clValue(type)} #{operator} #{operands[0].clValue(type)};"
-    $asm.putc "    if (didOverflow)"
+    $asm.putc "    if (!WTF::ArithmeticOperations<#{tempType}, #{tempType}, #{tempType}>::#{operation}(#{operands[1].clValue(type)}, #{operands[0].clValue(type)}, #{operands[1].clValue(type)}))"
     $asm.putc "        goto #{operands[2].cLabel};"
     $asm.putc "}"
 end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to