Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 04f3239284c0217ad05bff4a8c98b2a90b1658c1
      
https://github.com/WebKit/WebKit/commit/04f3239284c0217ad05bff4a8c98b2a90b1658c1
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-19 (Sun, 19 Apr 2026)

  Changed paths:
    M Source/WebCore/bindings/scripts/CodeGenerator.pm
    M Source/WebCore/bindings/scripts/Hasher.pm
    M Source/WebCore/bindings/scripts/generate-bindings.pl
    M Source/WebCore/bindings/scripts/preprocess-idls.pl

  Log Message:
  -----------
  Optimize IDL bindings generation scripts for faster build times
https://bugs.webkit.org/show_bug.cgi?id=312673

Reviewed by Darin Adler.

Hasher.pm was using 'use bigint', which routes all arithmetic through
Math::BigInt arbitrary-precision integers. On 64-bit Perl, native integer
arithmetic is ~430x faster per hash. This patch also uses substr() instead of
split() for character access, eliminates per-call local subroutine
redefinitions, and makes the @secret array a file-scoped constant.

ProcessInterfaceSupplementalDependencies and
ProcessDictionarySupplementalDependencies were re-parsing the same supplemental
IDL files (~30ms each) for every target that depends on them, even within the
same process. This patch adds an in-memory cache using Storable::dclone so each
supplemental IDL file is parsed at most once per process.

Additionally, prefer JSON::XS (C-based) over JSON::PP (pure Perl) when available
for ~72x faster IDL attributes parsing, and memoize
GenerateConditionalStringFromAttributeValue to avoid redundant recomputation.

Performance results (Apple M4 Max, 16 cores):

Actual parallel bindings generation (1,823 IDL files, generate-bindings-all.pl):
  Before: 14.6s wall, 54.9s user CPU
  After:  13.2s wall, 48.7s user CPU
  Speedup: 10% wall (1.4s saved), 11% user CPU (6.2s saved)

* Source/WebCore/bindings/scripts/Hasher.pm:
(maskTop8BitsAndAvoidZero): No functional change.
(_unsigned_lt): Added. Unsigned 64-bit comparison under 'use integer' by XORing
the sign bit to flip signed ordering to unsigned ordering.
(wymum): Use native arithmetic with 'use integer' instead of 
uint64_add/uint64_multi
wrappers. Mask right-shifts by & 0xFFFFFFFF for correct unsigned extraction 
under
arithmetic shift. Use _unsigned_lt for carry detection.
(wymix): No functional change.
(_wyr8): New. Reads 4 characters via substr and converts to 64-bit, replacing 
the
per-call local *wyr8 closure and separate convert32BitTo64Bit function.
(_wyr4): New. Reads 2 characters via substr, replacing local *wyr4 closure and
separate convert16BitTo32Bit function.
(_wyr2): New. Reads 1 character via substr, replacing local *wyr2 closure.
(GenerateHashValue): Merged wyhash() logic here. Operates directly on the string
instead of splitting into a character array. Uses file-scoped @secret array.
(uint64_add): Deleted.
(uint64_multi): Deleted.
(convert32BitTo64Bit): Deleted, inlined into _wyr8.
(convert16BitTo32Bit): Deleted, inlined into _wyr4.
(wyhash): Deleted, merged into GenerateHashValue.
* Source/WebCore/bindings/scripts/CodeGenerator.pm:
(GenerateConditionalStringFromAttributeValue): Memoize results to avoid 
redundant
split/map/join/sort for repeated conditional attribute values.
(ProcessInterfaceSupplementalDependencies): Cache parsed supplemental IDL 
documents
in-memory using Storable::dclone to avoid re-parsing the same mixin/partial IDL
files for every target that depends on them within the same process.
(ProcessDictionarySupplementalDependencies): Same caching.
* Source/WebCore/bindings/scripts/generate-bindings.pl:
Use JSON::XS when available, falling back to JSON::PP.
* Source/WebCore/bindings/scripts/preprocess-idls.pl:
Use JSON::XS when available, falling back to JSON::PP.

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



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

Reply via email to