Bug 830676 - YarrJIT is broken on Win64 after landing bug 820124. r=sstangl, a=lsblakk
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 25 Jan 2013 12:09:54 +0900
changeset 123937 6ed750ce8e6acdd19184efd4b88562373fc239eb
parent 123936 1939e049e60d784c272d8c8eaf76176f5d23d474
child 123938 9c559854783bc888a20258a2434f8d271962eec3
push id3335
push usersean.stangl@gmail.com
push dateSat, 09 Feb 2013 01:19:58 +0000
treeherdermozilla-aurora@9c559854783b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl, lsblakk
bugs830676, 820124
milestone20.0a2
Bug 830676 - YarrJIT is broken on Win64 after landing bug 820124. r=sstangl, a=lsblakk
js/src/assembler/assembler/MacroAssemblerX86_64.h
js/src/yarr/MatchResult.h
js/src/yarr/YarrJIT.cpp
--- a/js/src/assembler/assembler/MacroAssemblerX86_64.h
+++ b/js/src/assembler/assembler/MacroAssemblerX86_64.h
@@ -363,16 +363,22 @@ public:
     }
 
     DataLabel32 storePtrWithAddressOffsetPatch(RegisterID src, Address address)
     {
         m_assembler.movq_rm_disp32(src, address.offset, address.base);
         return DataLabel32(this);
     }
 
+    void move32(RegisterID src, RegisterID dest)
+    {
+        // upper 32bit will be 0
+        m_assembler.movl_rr(src, dest);
+    }
+
     void movePtrToDouble(RegisterID src, FPRegisterID dest)
     {
         m_assembler.movq_rr(src, dest);
     }
 
     void moveDoubleToPtr(FPRegisterID src, RegisterID dest)
     {
         m_assembler.movq_rr(src, dest);
--- a/js/src/yarr/MatchResult.h
+++ b/js/src/yarr/MatchResult.h
@@ -26,48 +26,51 @@
 #ifndef MatchResult_h
 #define MatchResult_h
 
 #include "wtfbridge.h"
 
 typedef uint64_t EncodedMatchResult;
 
 struct MatchResult {
-    MatchResult(size_t start, size_t end)
+    MatchResult(int start, int end)
         : start(start)
         , end(end)
     {
     }
 
+#if !WTF_CPU_X86_64 || WTF_PLATFORM_WIN
     explicit MatchResult(EncodedMatchResult encoded)
     {
         union u {
             uint64_t encoded;
             struct s {
-                size_t start;
-                size_t end;
+                int start;
+                int end;
             } split;
         } value;
         value.encoded = encoded;
         start = value.split.start;
         end = value.split.end;
     }
+#endif
 
     static MatchResult failed()
     {
         return MatchResult(WTF::notFound, 0);
     }
 
     operator bool()
     {
-        return start != WTF::notFound;
+        return start != int(WTF::notFound);
     }
 
     bool empty()
     {
         return start == end;
     }
 
-    size_t start;
-    size_t end;
+    // strings are limited to a length of 2^28. So this is safe
+    int start;
+    int end;
 };
 
 #endif
--- a/js/src/yarr/YarrJIT.cpp
+++ b/js/src/yarr/YarrJIT.cpp
@@ -106,17 +106,21 @@ class YarrGenerator : private MacroAssem
     static const RegisterID length = X86Registers::edx;
     static const RegisterID output = X86Registers::ecx;
 # endif
 
     static const RegisterID regT0 = X86Registers::eax;
     static const RegisterID regT1 = X86Registers::ebx;
 
     static const RegisterID returnRegister = X86Registers::eax;
+
+# if !WTF_PLATFORM_WIN
+    // no way to use int128_t as return value on Win64 ABI
     static const RegisterID returnRegister2 = X86Registers::edx;
+# endif
 #endif
 
     void optimizeAlternative(PatternAlternative* alternative)
     {
         if (!alternative->m_terms.size())
             return;
 
         for (unsigned i = 0; i < alternative->m_terms.size() - 1; ++i) {
@@ -1406,17 +1410,24 @@ class YarrGenerator : private MacroAssem
                     if (priorAlternative->m_minimumSize)
                         sub32(Imm32(priorAlternative->m_minimumSize), returnRegister);
                     if (compileMode == IncludeSubpatterns)
                         store32(returnRegister, output);
                 } else
                     getMatchStart(returnRegister);
                 if (compileMode == IncludeSubpatterns)
                     store32(index, Address(output, 4));
+#if WTF_CPU_X86_64
+                // upper 32bit to 0
+                move32(returnRegister, returnRegister);
+                lshiftPtr(Imm32(32), index);
+                orPtr(index, returnRegister);
+#else
                 move(index, returnRegister2);
+#endif
 
                 generateReturn();
 
                 // This is the divide between the tail of the prior alternative, above, and
                 // the head of the subsequent alternative, below.
 
                 if (op.m_op == OpBodyAlternativeNext) {
                     // This is the reentry point for the Next alternative. We expect any code
@@ -1725,18 +1736,22 @@ class YarrGenerator : private MacroAssem
                 m_checked += lastOp.m_checkAdjust;
                 break;
             }
 
             case OpMatchFailed:
 #if !WTF_CPU_SPARC
                 removeCallFrame();
 #endif
+#if WTF_CPU_X86_64
+                move(TrustedImm32(WTF::notFound), returnRegister);
+#else
                 move(TrustedImmPtr((void*)WTF::notFound), returnRegister);
                 move(TrustedImm32(0), returnRegister2);
+#endif
                 generateReturn();
                 break;
             }
 
             ++opIndex;
         } while (opIndex < m_ops.size());
     }
 
@@ -1967,18 +1982,22 @@ class YarrGenerator : private MacroAssem
 
                 // We jump to here if we iterate to the point that there is insufficient input to
                 // run any matches, and need to return a failure state from JIT code.
                 matchFailed.link(this);
 
 #if !WTF_CPU_SPARC
                 removeCallFrame();
 #endif
+#if WTF_CPU_X86_64
+                move(TrustedImm32(WTF::notFound), returnRegister);
+#else
                 move(TrustedImmPtr((void*)WTF::notFound), returnRegister);
                 move(TrustedImm32(0), returnRegister2);
+#endif
                 generateReturn();
                 break;
             }
             case OpBodyAlternativeEnd: {
                 // We should never backtrack back into a body disjunction.
                 ASSERT(m_backtrackingState.isEmpty());
 
                 PatternAlternative* priorAlternative = m_ops[op.m_previousOp].m_alternative;
@@ -2615,18 +2634,22 @@ public:
     {
     }
 
     void compile(JSGlobalData* globalData, YarrCodeBlock& jitObject)
     {
         generateEnter();
 
         Jump hasInput = checkInput();
+#if WTF_CPU_X86_64
+        move(TrustedImm32(WTF::notFound), returnRegister);
+#else
         move(TrustedImmPtr((void*)WTF::notFound), returnRegister);
         move(TrustedImm32(0), returnRegister2);
+#endif
         generateReturn();
         hasInput.link(this);
 
         if (compileMode == IncludeSubpatterns) {
             for (unsigned i = 0; i < m_pattern.m_numSubpatterns + 1; ++i)
                 store32(TrustedImm32(-1), Address(output, (i << 1) * sizeof(int)));
         }