Title: [95168] trunk/Source/_javascript_Core
Revision
95168
Author
[email protected]
Date
2011-09-14 22:17:20 -0700 (Wed, 14 Sep 2011)

Log Message

[n]stricteq code is bogus in JSValue32_64 JIT
https://bugs.webkit.org/show_bug.cgi?id=68141

Reviewed by Sam Weinig.

The code tries to check for both ints or cells, but this check also
catches cases where values that are undefined, null, etc (probably
was incorrectly assuming cell was the 2nd highest tag?).

Also, there is no need not to handle int on the fast path.
stricteq is just a case of comparing the payloads, if we:
    * handle cases of differing tags on a slow path
    * handle doubles a slow path
    * handle both-are-string on a slow path

* jit/JITOpcodes32_64.cpp:
(JSC::JIT::compileOpStrictEq):
(JSC::JIT::emitSlow_op_stricteq):
(JSC::JIT::emitSlow_op_nstricteq):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (95167 => 95168)


--- trunk/Source/_javascript_Core/ChangeLog	2011-09-15 05:15:16 UTC (rev 95167)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-09-15 05:17:20 UTC (rev 95168)
@@ -1,3 +1,25 @@
+2011-09-14  Gavin Barraclough  <[email protected]>
+
+        [n]stricteq code is bogus in JSValue32_64 JIT
+        https://bugs.webkit.org/show_bug.cgi?id=68141
+
+        Reviewed by Sam Weinig.
+
+        The code tries to check for both ints or cells, but this check also
+        catches cases where values that are undefined, null, etc (probably
+        was incorrectly assuming cell was the 2nd highest tag?).
+
+        Also, there is no need not to handle int on the fast path.
+        stricteq is just a case of comparing the payloads, if we:
+            * handle cases of differing tags on a slow path
+            * handle doubles a slow path
+            * handle both-are-string on a slow path
+
+        * jit/JITOpcodes32_64.cpp:
+        (JSC::JIT::compileOpStrictEq):
+        (JSC::JIT::emitSlow_op_stricteq):
+        (JSC::JIT::emitSlow_op_nstricteq):
+
 2011-09-14  Mark Hahnenberg  <[email protected]>
 
         Make JSCell::toBoolean non-virtual

Modified: trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp (95167 => 95168)


--- trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2011-09-15 05:15:16 UTC (rev 95167)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2011-09-15 05:17:20 UTC (rev 95168)
@@ -995,20 +995,24 @@
     unsigned src1 = currentInstruction[2].u.operand;
     unsigned src2 = currentInstruction[3].u.operand;
 
-    emitLoadTag(src1, regT0);
-    emitLoadTag(src2, regT1);
+    emitLoad2(src1, regT1, regT0, src2, regT3, regT2);
 
-    // Jump to a slow case if either operand is double, or if both operands are
-    // cells and/or Int32s.
-    move(regT0, regT2);
-    and32(regT1, regT2);
-    addSlowCase(branch32(Below, regT2, TrustedImm32(JSValue::LowestTag)));
-    addSlowCase(branch32(AboveOrEqual, regT2, TrustedImm32(JSValue::CellTag)));
+    // Bail if the tags differ, or are double.
+    addSlowCase(branch32(NotEqual, regT1, regT3));
+    addSlowCase(branch32(Below, regT1, TrustedImm32(JSValue::LowestTag)));
 
+    // Jump to a slow case if both are strings.
+    Jump notCell = branch32(NotEqual, regT1, TrustedImm32(JSValue::CellTag));
+    Jump firstNotString = branchPtr(NotEqual, Address(regT0), TrustedImmPtr(m_globalData->jsStringVPtr));
+    addSlowCase(branchPtr(Equal, Address(regT2), TrustedImmPtr(m_globalData->jsStringVPtr)));
+    notCell.link(this);
+    firstNotString.link(this);
+
+    // Simply compare the payloads.
     if (type == OpStrictEq)
-        compare32(Equal, regT0, regT1, regT0);
+        compare32(Equal, regT0, regT2, regT0);
     else
-        compare32(NotEqual, regT0, regT1, regT0);
+        compare32(NotEqual, regT0, regT2, regT0);
 
     emitStoreBool(dst, regT0);
 }
@@ -1026,6 +1030,7 @@
 
     linkSlowCase(iter);
     linkSlowCase(iter);
+    linkSlowCase(iter);
 
     JITStubCall stubCall(this, cti_op_stricteq);
     stubCall.addArgument(src1);
@@ -1046,6 +1051,7 @@
 
     linkSlowCase(iter);
     linkSlowCase(iter);
+    linkSlowCase(iter);
 
     JITStubCall stubCall(this, cti_op_nstricteq);
     stubCall.addArgument(src1);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to