[webkit-changes] [WebKit/WebKit] 2a040c: [JSC] Implement fromHex and setFromHex in SIMD

Yusuke Suzuki noreply at github.com
Wed Jul 17 08:35:38 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2a040cbef4c2e759a20508e0e32170a86f72d9ab
      https://github.com/WebKit/WebKit/commit/2a040cbef4c2e759a20508e0e32170a86f72d9ab
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2024-07-17 (Wed, 17 Jul 2024)

  Changed paths:
    A JSTests/microbenchmarks/from-hex.js
    M JSTests/stress/uint8array-fromHex.js
    M JSTests/stress/uint8array-setFromHex.js
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.cpp
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototype.cpp

  Log Message:
  -----------
  [JSC] Implement fromHex and setFromHex in SIMD
https://bugs.webkit.org/show_bug.cgi?id=276705
rdar://131903377

Reviewed by Keith Miller and Justin Michaud.

This patch implements fromHex / setFromHex in SIMD. The new implementation is roughly 17x faster.
We use http://0x80.pl/notesen/2022-01-17-validating-hex-parse.html 's algorithm 3 approach to decode hex in SIMD with validation.
For 16bit string, we load high and low bytes separately, checking high bytes are all zero, and decoding low bytes as the same to
8bit string with validation.

                               ToT                     Patched

    from-hex             46.8263+-0.1123     ^      2.7441+-0.0149        ^ definitely 17.0641x faster

* JSTests/microbenchmarks/from-hex.js: Added.
(test):
* JSTests/stress/uint8array-fromHex.js:
(shouldBeArray.Uint8Array.fromHex):
(shouldBeArray):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.cpp:
(JSC::decodeHexImpl):
(JSC::decodeHex):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h:
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):

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



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


More information about the webkit-changes mailing list