Title: [288748] trunk/Source/_javascript_Core
Revision
288748
Author
[email protected]
Date
2022-01-28 11:01:21 -0800 (Fri, 28 Jan 2022)

Log Message

[JSC] YarrJIT optimization for character BM search
https://bugs.webkit.org/show_bug.cgi?id=235738

Reviewed by Saam Barati.

Add micro-optimization of BM search path. Since it is super hot path,
this small improvement offsers 1% in jquery-todomvc-regexp microbenchmark.

                                      ToT                     Patched

    jquery-todomvc-regexp      484.1399+-1.0527     ^    479.0932+-1.0999        ^ definitely 1.0105x faster

* yarr/YarrJIT.cpp:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (288747 => 288748)


--- trunk/Source/_javascript_Core/ChangeLog	2022-01-28 18:33:25 UTC (rev 288747)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-01-28 19:01:21 UTC (rev 288748)
@@ -1,3 +1,19 @@
+2022-01-28  Yusuke Suzuki  <[email protected]>
+
+        [JSC] YarrJIT optimization for character BM search
+        https://bugs.webkit.org/show_bug.cgi?id=235738
+
+        Reviewed by Saam Barati.
+
+        Add micro-optimization of BM search path. Since it is super hot path,
+        this small improvement offsers 1% in jquery-todomvc-regexp microbenchmark.
+
+                                              ToT                     Patched
+
+            jquery-todomvc-regexp      484.1399+-1.0527     ^    479.0932+-1.0999        ^ definitely 1.0105x faster
+
+        * yarr/YarrJIT.cpp:
+
 2022-01-27  Michael Saboff  <[email protected]>
 
         com.apple.WebKit.WebAuthn.xpc fails to build with system content path

Modified: trunk/Source/_javascript_Core/yarr/YarrJIT.cpp (288747 => 288748)


--- trunk/Source/_javascript_Core/yarr/YarrJIT.cpp	2022-01-28 18:33:25 UTC (rev 288747)
+++ trunk/Source/_javascript_Core/yarr/YarrJIT.cpp	2022-01-28 19:01:21 UTC (rev 288748)
@@ -2341,7 +2341,6 @@
                         auto [map, charactersFastPath] = op.m_bmInfo->createCandidateBitmap(beginIndex, endIndex);
                         unsigned mapCount = map.count();
                         // If candiate characters are <= 2, checking each is better than using vector.
-                        MacroAssembler::JumpList outOfLengthFailure;
                         MacroAssembler::JumpList matched;
                         dataLogLnIf(YarrJITInternal::verbose, "BM Bitmap is ", map);
                         // Patterns like /[]/ have zero candidates. Since it is rare, we do not do nothing for now.
@@ -2356,8 +2355,7 @@
                             matched.append(m_jit.branch32(MacroAssembler::Equal, m_regs.regT0, MacroAssembler::TrustedImm32(charactersFastPath.at(0))));
                             if (charactersFastPath.size() > 1)
                                 matched.append(m_jit.branch32(MacroAssembler::Equal, m_regs.regT0, MacroAssembler::TrustedImm32(charactersFastPath.at(1))));
-                            outOfLengthFailure.append(jumpIfNoAvailableInput(endIndex - beginIndex));
-                            m_jit.jump().linkTo(loopHead, &m_jit);
+                            jumpIfAvailableInput(endIndex - beginIndex).linkTo(loopHead, &m_jit);
                         } else {
                             const auto* pointer = getBoyerMooreBitmap(map);
                             dataLogLnIf(Options::verboseRegExpCompilation(), "Found bitmap lookahead count:(", mapCount, "),range:[", beginIndex, ", ", endIndex, ")");
@@ -2393,14 +2391,13 @@
                             m_jit.urshift32(m_regs.regT0, m_regs.regT2); // We can ignore upper bits and only lower 5bits are effective.
                             matched.append(m_jit.branchTest32(MacroAssembler::NonZero, m_regs.regT2, MacroAssembler::TrustedImm32(1)));
 #endif
-                            outOfLengthFailure.append(jumpIfNoAvailableInput(endIndex - beginIndex));
-                            m_jit.jump().linkTo(loopHead, &m_jit);
+                            jumpIfAvailableInput(endIndex - beginIndex).linkTo(loopHead, &m_jit);
                         }
+                        // Fallthrough if out-of-length failure happens.
 
                         // If the pattern size is not fixed, then store the start index for use if we match.
                         // This is used for adjusting match-start when we failed to find the start with BoyerMoore search.
                         if (!m_pattern.m_body->m_hasFixedSize) {
-                            outOfLengthFailure.link(&m_jit);
                             if (alternative->m_minimumSize) {
                                 m_jit.sub32(m_regs.index, MacroAssembler::Imm32(alternative->m_minimumSize), m_regs.regT0);
                                 setMatchStart(m_regs.regT0);
@@ -2408,7 +2405,7 @@
                                 setMatchStart(m_regs.index);
                             op.m_jumps.append(m_jit.jump());
                         } else
-                            op.m_jumps.append(outOfLengthFailure);
+                            op.m_jumps.append(m_jit.jump());
 
                         matched.link(&m_jit);
                         // If the pattern size is not fixed, then store the start index for use if we match.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to