Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7be57c077eda4ed04a6f77b547f01ffe214891d8
https://github.com/WebKit/WebKit/commit/7be57c077eda4ed04a6f77b547f01ffe214891d8
Author: Sosuke Suzuki <[email protected]>
Date: 2026-07-13 (Mon, 13 Jul 2026)
Changed paths:
A JSTests/microbenchmarks/set-constructor-cross-realm-array.js
A JSTests/stress/for-each-in-iterable-cross-realm-array-fast-path.js
M Source/JavaScriptCore/runtime/IteratorOperations.cpp
M Source/JavaScriptCore/runtime/IteratorOperations.h
Log Message:
-----------
[JSC] Support cross-realm Array fast path in `forEachInIterable`
https://bugs.webkit.org/show_bug.cgi?id=317731
Reviewed by Keith Miller.
The 2-argument getIterationMode (used only by forEachInIterable) gated FastArray
on the caller realm's isOriginalArrayStructure, so cross-realm arrays always
fell back to the generic iterator path. Switch to
JSArray::isIteratorProtocolFastAndNonObservable(), which checks the array's own
realm just like the existing JSMap/JSSet fast paths.
There is no observable behavior change: the predicate guarantees the array's own
realm's iterator protocol is pristine, so the inlined index loop is equivalent
to
what GetIterator + IteratorStep would do, and the materialized iterator for
IteratorClose now uses array->realm()->arrayIteratorStructure(), matching what
the spec's GetIterator would have produced.
Baseline Patched
set-constructor-cross-realm-array 18.0169+-0.1186 ^ 6.0958+-0.0508
^ definitely 2.9556x faster
Tests: JSTests/microbenchmarks/set-constructor-cross-realm-array.js
JSTests/stress/for-each-in-iterable-cross-realm-array-fast-path.js
* JSTests/microbenchmarks/set-constructor-cross-realm-array.js: Added.
(test):
* JSTests/stress/for-each-in-iterable-cross-realm-array-fast-path.js: Added.
(shouldBe):
(shouldBe.ArrayIteratorPrototype.return):
(ArrayIteratorPrototype.next):
* Source/JavaScriptCore/runtime/IteratorOperations.cpp:
(JSC::getIterationMode):
* Source/JavaScriptCore/runtime/IteratorOperations.h:
(JSC::forEachInFastArray):
(JSC::forEachInIterable):
* Source/JavaScriptCore/runtime/JSArray.h:
Canonical link: https://commits.webkit.org/317121@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications