Title: [292324] branches/safari-613-branch/Source/_javascript_Core/yarr/YarrJIT.cpp
Revision
292324
Author
alanc...@apple.com
Date
2022-04-04 14:54:52 -0700 (Mon, 04 Apr 2022)

Log Message

Cherry-pick r288748. rdar://91259284

    [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: branches/safari-613-branch/Source/_javascript_Core/yarr/YarrJIT.cpp (292323 => 292324)


--- branches/safari-613-branch/Source/_javascript_Core/yarr/YarrJIT.cpp	2022-04-04 21:54:49 UTC (rev 292323)
+++ branches/safari-613-branch/Source/_javascript_Core/yarr/YarrJIT.cpp	2022-04-04 21:54:52 UTC (rev 292324)
@@ -2344,7 +2344,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.
@@ -2359,8 +2358,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, ")");
@@ -2396,14 +2394,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);
@@ -2411,7 +2408,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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to