Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 577296de6a91c6458c2dabfd2ceb83dec93c82ed
      
https://github.com/WebKit/WebKit/commit/577296de6a91c6458c2dabfd2ceb83dec93c82ed
  Author: Vassili Bykov <[email protected]>
  Date:   2026-03-18 (Wed, 18 Mar 2026)

  Changed paths:
    M 
JSTests/stress/can-declare-global-var-invoked-before-any-binding-is-created-eval.js
    M 
JSTests/stress/can-declare-global-var-invoked-before-any-binding-is-created-global.js
    M JSTests/stress/eval-func-decl-in-global-of-eval.js
    M Source/JavaScriptCore/parser/VariableEnvironment.h
    M Source/JavaScriptCore/runtime/CachedTypes.cpp
    M Source/WTF/WTF.xcodeproj/project.pbxproj
    M Source/WTF/wtf/CMakeLists.txt
    A Source/WTF/wtf/InlineMap.h
    M Tools/TestWebKitAPI/CMakeLists.txt
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WTF/InlineMap.cpp

  Log Message:
  -----------
  [JSC] Improve the performance of maps in VariableEnvironments
https://bugs.webkit.org/show_bug.cgi?id=310108
rdar://172755753

Reviewed by Yusuke Suzuki.

This patch improves the performance of JavaScript parser.
Key changes:

    * Source/WTF/wtf/InlineMap.h: Added.
    * Tools/TestWebKitAPI/Tests/WTF/InlineMap.cpp: Added.

Introduces a new map implementation, largely compatible with the existing
UncheckedKeyHashMap. The map stores entries inline using a flat array with 
linear lookup
when the number of entries is at or below the InlineCapacity parameter value.
This is implemented as a new class rather than a change to the existing
UncheckedKeyHashMap / HashMap / HashTable class group to keep the change 
localized.
Changing the base HashTable to allow linear inline storage might be an 
interesting
exercise, but it would be touching many use cases and is better done as a 
separate
project.

    * Source/JavaScriptCore/parser/VariableEnvironment.h:
    * Source/JavaScriptCore/runtime/CachedTypes.cpp:

Class VariableEnvironment is changed to use the new map for its bindings.

Testing: The new class comes with unit tests. The parser is covered by existing 
tests.
The patch changes 3 of them:

    * 
JSTests/stress/can-declare-global-var-invoked-before-any-binding-is-created-eval.js:
    * 
JSTests/stress/can-declare-global-var-invoked-before-any-binding-is-created-global.js:
    * JSTests/stress/eval-func-decl-in-global-of-eval.js:

These tests were relying on the specific iteration order of the original hash 
map by
assuming which of the two problematic bindings was visited and detected first. 
The purpose
of the tests is to verify that a problematic binding prevents valid bindings in 
the same
eval unit from taking effect.

In this context, it actually makes sense to only have one problematic binding 
in the test.
This both avoids the non-determinism of which binding is detected first, and 
reduces the
chances of a false negative (having the valid bindings not take effect simply 
because the
invalid one was processed first). The patch removes the second problematic 
definition in
each test.

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



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

Reply via email to