Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1d355c27ea88a9e50184d16b7a76adb1ed6492bb
      
https://github.com/WebKit/WebKit/commit/1d355c27ea88a9e50184d16b7a76adb1ed6492bb
  Author: Yijia Huang <[email protected]>
  Date:   2026-07-28 (Tue, 28 Jul 2026)

  Changed paths:
    A JSTests/microbenchmarks/json-stringify-short-strings-upconvert.js
    M Source/JavaScriptCore/runtime/JSONObject.cpp
    M Source/WTF/wtf/MathExtras.h
    M Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp

  Log Message:
  -----------
  [JSC] Add an 8-byte SWAR fast path to JSON.stringify's stringCopyUpconvert 
for short strings
https://bugs.webkit.org/show_bug.cgi?id=320419
rdar://183378922

Reviewed by Yusuke Suzuki.

stringCopyUpconvert() is stringCopySameType()'s Latin1-to-char16_t upconvert
sibling and has the same gap: a scalar byte-at-a-time fallback and a 16-byte
SIMD fast path, but nothing in between, so strings shorter than 16 bytes
always took the scalar loop.

Add the same 8-byte SWAR tier. Widening 4 packed Latin1 bytes into 4
char16_t lanes needs an extra step beyond stringCopySameType's plain copy,
so this adds WTF::zeroExtendBytesToHalfwords(), a small bit-doubling
"spread" helper, and reuses it instead of an 8-instruction unrolled
extract-and-store loop.

                                                   ToT                     
Patched

json-stringify-short-strings-upconvert      174.2817+-5.1099     ^    
144.8684+-5.8863        ^ definitely 1.2030x faster

Tests: JSTests/microbenchmarks/json-stringify-short-strings-upconvert.js
       Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp

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



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

Reply via email to