Title: [285406] trunk
Revision
285406
Author
[email protected]
Date
2021-11-08 09:05:33 -0800 (Mon, 08 Nov 2021)

Log Message

We need to PreferNumber when calling toPrimitive for negate
https://bugs.webkit.org/show_bug.cgi?id=232679

Reviewed by Alexey Shvayka.

JSTests:

* stress/negate-prefer-number-to-primitive.js

Source/_javascript_Core:

We were forgetting to do this in a few implementations of the negate
bytecode. So depending on which variant you took, you could get different
results.

* jit/JITOperations.cpp:
(JSC::JSC_DEFINE_JIT_OPERATION):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (285405 => 285406)


--- trunk/JSTests/ChangeLog	2021-11-08 16:58:13 UTC (rev 285405)
+++ trunk/JSTests/ChangeLog	2021-11-08 17:05:33 UTC (rev 285406)
@@ -1,3 +1,12 @@
+2021-11-08  Saam Barati  <[email protected]>
+
+        We need to PreferNumber when calling toPrimitive for negate
+        https://bugs.webkit.org/show_bug.cgi?id=232679
+
+        Reviewed by Alexey Shvayka.
+
+        * stress/negate-prefer-number-to-primitive.js
+
 2021-11-05  Russell Epstein  <[email protected]>
 
         Cherry-pick r284635. rdar://problem/85039977

Added: trunk/JSTests/stress/negate-prefer-number-to-primitive.js (0 => 285406)


--- trunk/JSTests/stress/negate-prefer-number-to-primitive.js	                        (rev 0)
+++ trunk/JSTests/stress/negate-prefer-number-to-primitive.js	2021-11-08 17:05:33 UTC (rev 285406)
@@ -0,0 +1,22 @@
+//@ runDefault("--validateOptions=true", "--useConcurrentJIT=false", "--useConcurrentGC=false", "--thresholdForJITSoon=10", "--thresholdForJITAfterWarmUp=10", "--thresholdForOptimizeAfterWarmUp=100", "--thresholdForOptimizeAfterLongWarmUp=100", "--thresholdForOptimizeSoon=100", "--thresholdForFTLOptimizeAfterWarmUp=1000", "--thresholdForFTLOptimizeSoon=1000", "--validateBCE=true", "--useFTLJIT=1")
+
+function assert(b) {
+    if (!b)
+        throw new Error;
+}
+
+function main() {
+    let result;
+    for (let i = 0; i < 7; ++i) {
+        function f() {
+            "a".charCodeAt(undefined);
+            const v44 = new Date(123);
+            result = -v44;
+            for (let j = -4096; j < 100; j++) { } 
+        }   
+        noInline(f);
+        f();
+        assert(result === -123);
+    }
+}
+main();

Modified: trunk/Source/_javascript_Core/ChangeLog (285405 => 285406)


--- trunk/Source/_javascript_Core/ChangeLog	2021-11-08 16:58:13 UTC (rev 285405)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-11-08 17:05:33 UTC (rev 285406)
@@ -1,3 +1,17 @@
+2021-11-08  Saam Barati  <[email protected]>
+
+        We need to PreferNumber when calling toPrimitive for negate
+        https://bugs.webkit.org/show_bug.cgi?id=232679
+
+        Reviewed by Alexey Shvayka.
+
+        We were forgetting to do this in a few implementations of the negate
+        bytecode. So depending on which variant you took, you could get different
+        results.
+
+        * jit/JITOperations.cpp:
+        (JSC::JSC_DEFINE_JIT_OPERATION):
+
 2021-11-05  Russell Epstein  <[email protected]>
 
         Cherry-pick r284635. rdar://problem/85039977

Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (285405 => 285406)


--- trunk/Source/_javascript_Core/jit/JITOperations.cpp	2021-11-08 16:58:13 UTC (rev 285405)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp	2021-11-08 17:05:33 UTC (rev 285406)
@@ -3411,7 +3411,7 @@
     JSValue operand = JSValue::decode(encodedOperand);
     arithProfile->observeArg(operand);
 
-    JSValue primValue = operand.toPrimitive(globalObject);
+    JSValue primValue = operand.toPrimitive(globalObject, PreferNumber);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
 #if USE(BIGINT32)
@@ -3455,7 +3455,7 @@
     callFrame->codeBlock()->dumpMathICStats();
 #endif
     
-    JSValue primValue = operand.toPrimitive(globalObject);
+    JSValue primValue = operand.toPrimitive(globalObject, PreferNumber);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
 #if USE(BIGINT32)
@@ -3498,7 +3498,7 @@
     callFrame->codeBlock()->dumpMathICStats();
 #endif
 
-    JSValue primValue = operand.toPrimitive(globalObject);
+    JSValue primValue = operand.toPrimitive(globalObject, PreferNumber);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
 #if USE(BIGINT32)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to