Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 67969621f7032db54f3cec3c893ff1b5bf212fcf
      
https://github.com/WebKit/WebKit/commit/67969621f7032db54f3cec3c893ff1b5bf212fcf
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-05-17 (Sun, 17 May 2026)

  Changed paths:
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

  Log Message:
  -----------
  [JSC] Inline `String#startsWith` / `String#endsWith` with constant search 
string in DFG/FTL
https://bugs.webkit.org/show_bug.cgi?id=314517

Reviewed by Yusuke Suzuki.

This patch inlines StringStartsWith / StringEndsWith when the search
string is a constant, embedding its bytes as immediate operands instead
of calling into the runtime.

The comparison uses a few wide loads with overlap when the search
length isn't a power of two: load64 for >= 8 bytes, load32 for 4-7,
load16 for 2-3, load8 for 1. A 16-byte search needs at most two
load64 + cmp.

Only constant 8-bit search strings of 1-16 bytes are supported; ropes,
16-bit base strings, and variable or position-argument forms still go
through the runtime helper.

                                                  TipOfTree                  
Patched

string-startswith-constant                     17.9727+-0.4341     ^      
5.7938+-0.3102        ^ definitely 3.1021x faster
string-endswith-constant                       17.3566+-1.8544     ^      
6.1307+-0.2170        ^ definitely 2.8311x faster
string-startswith-constant-long                16.1837+-1.2149     ^      
5.8331+-0.4844        ^ definitely 2.7744x faster

* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileStringStartsOrEndsWithConstant):
(JSC::FTL::DFG::LowerDFGToB3::compileStringStartsOrEndsWith):

Canonical link: https://commits.webkit.org/313394@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to