Title: [97039] trunk/Source/_javascript_Core
Revision
97039
Author
[email protected]
Date
2011-10-09 21:05:27 -0700 (Sun, 09 Oct 2011)

Log Message

Improve Null or Undefined test in 32_64 DFG
https://bugs.webkit.org/show_bug.cgi?id=69734

Patch by Yuqiang Xian <[email protected]> on 2011-10-09
Reviewed by Darin Adler.

Currently Null or Undefined value test in 32_64 DFG will check
Null and Undefined tag separately and introduce one more branch.
It can be improved in the way how the baseline JIT is doing - by
relying on the fact that "UndefinedTag + 1 == NullTag and NullTag & 1".

* dfg/DFGJITCodeGenerator32_64.cpp:
(JSC::DFG::JITCodeGenerator::nonSpeculativeNonPeepholeCompareNull):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compileObjectOrOtherLogicalNot):
(JSC::DFG::SpeculativeJIT::emitObjectOrOtherBranch):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (97038 => 97039)


--- trunk/Source/_javascript_Core/ChangeLog	2011-10-10 03:25:36 UTC (rev 97038)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-10-10 04:05:27 UTC (rev 97039)
@@ -1,5 +1,23 @@
 2011-10-09  Yuqiang Xian  <[email protected]>
 
+        Improve Null or Undefined test in 32_64 DFG
+        https://bugs.webkit.org/show_bug.cgi?id=69734
+
+        Reviewed by Darin Adler.
+
+        Currently Null or Undefined value test in 32_64 DFG will check
+        Null and Undefined tag separately and introduce one more branch.
+        It can be improved in the way how the baseline JIT is doing - by
+        relying on the fact that "UndefinedTag + 1 == NullTag and NullTag & 1".
+
+        * dfg/DFGJITCodeGenerator32_64.cpp:
+        (JSC::DFG::JITCodeGenerator::nonSpeculativeNonPeepholeCompareNull):
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compileObjectOrOtherLogicalNot):
+        (JSC::DFG::SpeculativeJIT::emitObjectOrOtherBranch):
+
+2011-10-09  Yuqiang Xian  <[email protected]>
+
         JSVALUE32_64 DFG JIT - Bug fix for ConvertThis
         https://bugs.webkit.org/show_bug.cgi?id=69721
 

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCodeGenerator32_64.cpp (97038 => 97039)


--- trunk/Source/_javascript_Core/dfg/DFGJITCodeGenerator32_64.cpp	2011-10-10 03:25:36 UTC (rev 97038)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCodeGenerator32_64.cpp	2011-10-10 04:05:27 UTC (rev 97039)
@@ -1171,18 +1171,15 @@
     m_jit.test8(invert ? JITCompiler::Zero : JITCompiler::NonZero, JITCompiler::Address(resultPayloadGPR, Structure::typeInfoFlagsOffset()), JITCompiler::TrustedImm32(MasqueradesAsUndefined), resultPayloadGPR);
     
     if (!isKnownCell(operand)) {
-        JITCompiler::JumpList done;
-        done.append(m_jit.jump());
+        JITCompiler::Jump done = m_jit.jump();
         
         notCell.link(&m_jit);
         // null or undefined?
-        JITCompiler::Jump checkUndefined = m_jit.branch32(invert ? JITCompiler::Equal: JITCompiler::NotEqual, argTagGPR, JITCompiler::TrustedImm32(JSValue::NullTag));
-        m_jit.move(JITCompiler::TrustedImm32(1), resultPayloadGPR);
-        done.append(m_jit.jump());
+        COMPILE_ASSERT((JSValue::UndefinedTag | 1) == JSValue::NullTag, UndefinedTag_OR_1_EQUALS_NullTag);
+        m_jit.move(argTagGPR, resultPayloadGPR);
+        m_jit.or32(TrustedImm32(1), resultPayloadGPR);
+        m_jit.compare32(invert ? JITCompiler::NotEqual : JITCompiler::Equal, resultPayloadGPR, TrustedImm32(JSValue::NullTag), resultPayloadGPR);
 
-        checkUndefined.link(&m_jit);
-        m_jit.compare32(invert ? JITCompiler::NotEqual: JITCompiler::Equal, argTagGPR, JITCompiler::TrustedImm32(JSValue::UndefinedTag), resultPayloadGPR);
-
         done.link(&m_jit);
     }
     

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (97038 => 97039)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2011-10-10 03:25:36 UTC (rev 97038)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2011-10-10 04:05:27 UTC (rev 97039)
@@ -457,11 +457,10 @@
     
     notCell.link(&m_jit);
  
-    MacroAssembler::Jump isNull = m_jit.branch32(MacroAssembler::Equal, valueTagGPR, TrustedImm32(JSValue::NullTag));
-    speculationCheck(m_jit.branch32(MacroAssembler::NotEqual, valueTagGPR, TrustedImm32(JSValue::UndefinedTag)));
-
-    isNull.link(&m_jit);
-
+    COMPILE_ASSERT((JSValue::UndefinedTag | 1) == JSValue::NullTag, UndefinedTag_OR_1_EQUALS_NullTag);
+    m_jit.move(valueTagGPR, resultPayloadGPR);
+    m_jit.or32(TrustedImm32(1), resultPayloadGPR);
+    speculationCheck(m_jit.branch32(MacroAssembler::NotEqual, resultPayloadGPR, TrustedImm32(JSValue::NullTag)));
     m_jit.move(TrustedImm32(1), resultPayloadGPR);
     
     done.link(&m_jit);
@@ -547,8 +546,10 @@
 void SpeculativeJIT::emitObjectOrOtherBranch(NodeIndex nodeIndex, BlockIndex taken, BlockIndex notTaken, void *vptr)
 {
     JSValueOperand value(this, nodeIndex);
+    GPRTemporary scratch(this, value);
     GPRReg valueTagGPR = value.tagGPR();
     GPRReg valuePayloadGPR = value.payloadGPR();
+    GPRReg scratchGPR = scratch.gpr();
     
     MacroAssembler::Jump notCell = m_jit.branch32(MacroAssembler::NotEqual, valueTagGPR, TrustedImm32(JSValue::CellTag));
     speculationCheck(m_jit.branchPtr(MacroAssembler::NotEqual, MacroAssembler::Address(valuePayloadGPR), MacroAssembler::TrustedImmPtr(vptr)));
@@ -556,11 +557,11 @@
     
     notCell.link(&m_jit);
     
-    MacroAssembler::Jump isNull = m_jit.branch32(MacroAssembler::Equal, valueTagGPR, TrustedImm32(JSValue::NullTag));
-    speculationCheck(m_jit.branch32(MacroAssembler::NotEqual, valueTagGPR, TrustedImm32(JSValue::UndefinedTag)));
+    COMPILE_ASSERT((JSValue::UndefinedTag | 1) == JSValue::NullTag, UndefinedTag_OR_1_EQUALS_NullTag);
+    m_jit.move(valueTagGPR, scratchGPR);
+    m_jit.or32(TrustedImm32(1), scratchGPR);
+    speculationCheck(m_jit.branch32(MacroAssembler::NotEqual, scratchGPR, TrustedImm32(JSValue::NullTag)));
 
-    isNull.link(&m_jit);
-
     if (notTaken != (m_block + 1))
         addBranch(m_jit.jump(), notTaken);
     
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to