Repository navigation
feat(patches): fast path for stores a masking interceptor declines - #15
Merged
Merged
Conversation
A masking named interceptor whose setter declines (Intercepted::kNo) makes V8 finish every store in Runtime_StorePropertyPastInterceptor, which redoes the lookup and runs a generic SetProperty even when the store just overwrites an existing own field. The runtimes' write-observing setters mirror each write and decline, so they pay this on every property write. v8_declined_interceptor_store_fast_path.patch records in the store IC handler, when the IC is computed, whether the receiver map has an own, writable, fast-mode data field for the name and its descriptor index. After a declined setter, the handler overwrites that field in place when the receiver kept the same, non-deprecated map; constness, representation and field type are read live, so const fields and values that need generalization go to the runtime. Every bailout continues in the runtime, never through an IC miss, so the setter runs once. Globals, access-checked and dictionary-mode receivers and protector names are excluded when the IC is computed. --no-store-ic-declined-interceptor-fast-path turns it off. Not yet submitted upstream. Applied on every platform. Tested locally on macOS arm64 (release, dcheck_always_on, verify_heap) on 14.9.207.39 with the existing patches: new cctests DeclinedInterceptorStore* (fast path hit mono/poly/megamorphic, in-object and out-of-object, keyed, Maglev/Turbofan code; representations; constness; 21 setter side effects; exclusions) check that the setter runs once per store and that the final state matches Reflect.set. test-api-interceptors, test-api and test-accessors have the same failures as without the patch under default flags, --no-lazy-feedback-allocation, --maglev, --turbofan, --always-sparkplug, --jitless, --no-use-ic and with the fast path off. Same binary, fast path on vs off, existing-field overwrite in a hot loop: setter that declines at once 153.6 -> 8.8 ns/store; setter that mirrors the write into another object then declines 299.5 -> 148.6 ns/store.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Adds CSA_DCHECKs where the handler loads the cached descriptor (map not in dictionary mode, no access check, index below the own descriptor count) and leaves the fast path out of define-own IC handlers at code generation time; ComputeHandler already gives those a slow handler. New cctest DeclinedInterceptorStoreGCInSetter runs a minor GC, a major GC or a forced compaction of the receiver's and its property array's pages from inside the declining setter, for Smi, double and tagged fields, and checks the fast path still writes the right object. Path assertions tolerate cleared feedback under GC stress flags. Locally (macOS arm64, release + dcheck_always_on + verify_heap) all of test-api-interceptors passes under default flags, --no-lazy-feedback-allocation, --maglev, --turbofan, --always-sparkplug, --jitless, --stress-ic, --verify-heap, --stress-compaction, --gc-interval=500 and =10, --stress-incremental-marking, --stress-scavenge=100 and =10, and with the fast path off; only the pre-existing Regress256330 failure under --no-use-ic remains. test-api and test-accessors fail exactly as without the patch (default, fast path off, --stress-compaction). The README row notes that turning the flag off restores behaviour but not identical code.
edusperoni
marked this pull request as ready for review
November 21, 2026 20:07
This was referenced Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
patches/v8_declined_interceptor_store_fast_path.patchand applies it inscripts/matrix/fetch.shon every platform, afterv8_interceptor_define_descriptor.patch(the iOS-only Catalyst patch still applies after it). README row added.When a masking named interceptor's setter declines a store (
Intercepted::kNo), V8 14.9 always finishes the store inRuntime_StorePropertyPastInterceptor. That redoes the lookup and runs a genericObject::SetProperty, even when the store just overwrites an existing own field. The runtimes' write-observing setters mirror each write and then decline, so they pay this on every property write.How
StoreIC::ComputeHandler, INTERCEPTOR case): a side-effect-free own lookup that skips the interceptor checks whether the receiver map has an own, writable, fast-mode data field (kField) for the name. If it does, the interceptor store handler gets a bit plus the field's descriptor index, in new smi bits afterNonMaskingInterceptorBits.OverwriteExistingFastDataProperty(). That function reads constness, representation and field type live, so const fields and values that need generalization go to the runtime.Runtime::kStorePropertyPastInterceptor, never an IC miss, so the setter is never called twice. When the setter throws, the builtin's exception exit unwinds before the new code runs (checked inCallApiFunctionAndReturnon every architecture).--no-store-ic-declined-interceptor-fast-pathturns it off. With the flag off, the compute-time bit is never set and every store takes today's path.V8.StorePropertyPastInterceptor(a stats counter, used by the tests) and the RCS handler counterStoreIC_StoreInterceptorOwnFieldDH.Testing (local, macOS arm64, release +
dcheck_always_on+verify_heap, 14.9.207.39 with the existing patches)New cctests
test-api-interceptors/DeclinedInterceptorStore*:kOnlyInterceptStringswith a symbol key, class fields, access-checked object, interceptor on the prototype, dictionary mode, adding a missing property, protector names, global proxy.How the tests check it:
Reflect.set.Matrix:
--no-lazy-feedback-allocation,--maglev,--turbofan,--always-sparkplug,--jitless,--no-use-ic,--stress-ic(interceptor suite only), fast path off, and fast path off with--jitless.test-api-interceptors,test-apiandtest-accessorsfail on exactly the same tests as the unpatched binary in each variant. Those failures are expected-fail or variant-incompatible.CI here only builds
v8_monolith, so the cctests ran only locally.Benchmark
Same binary, fast path on vs off, hot loop overwriting an existing field. Medians of 4 interleaved runs × 7 reps × 2M stores, in ns/store:
kYes), referenceFollow-up commit
DeclinedInterceptorStoreGCInSetter: the setter runs a minor GC, a major GC or a forced compaction of the receiver's pages before it declines, for Smi, double and tagged fields.test-api-interceptorspasses under--verify-heap,--stress-compaction,--gc-interval=500and=10,--stress-incremental-marking, and--stress-scavenge=100and=10, in addition to the earlier variants. The only remaining failure isRegress256330under--no-use-ic, which fails the same way without the patch.