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
edusperoni
added a commit
to NativeScript/ios
that referenced
this pull request
Nov 22, 2026
Adds the declined masking-interceptor store fast path (NativeScript/v8-buildscripts#15): when a masking named interceptor declines a store to a name the receiver already has as an own fast data field, the store IC overwrites the field instead of calling Runtime_StorePropertyPastInterceptor. --store-ic-declined-interceptor-fast-path, on by default. Public headers are unchanged from -11.
edusperoni
added a commit
to NativeScript/android
that referenced
this pull request
Nov 22, 2026
### Description Bottom of a stacked series that ports the iOS wrapper lifetime modes (NativeScript/ios#558, #559's config, #561, #563; #576's leak probe is redesigned in #2130) to Android. Not ported: #559's `rooted` mode (it reads retain counts, which Java does not have) and #578 (a native-setter fast path in the canary write handler; on Android a write to a Java field still goes through V8 after the handler declines). No PR in the series has performance numbers yet. This PR changes only the V8 pin, so the new binary can be validated, and reverted, on its own. `V8_RELEASE` moves from `v8-14.9.207.39-7` to `-12`. Same V8 version and the same Android patches (`v8_resurrecting_finalizers.patch`, the JS dispatch table reservation, the Android build patch), plus two fixes for named interceptors and a fast path for stores a masking interceptor declines: - **`-10`, NativeScript/v8-buildscripts#11** (`v8_nonmasking_own_lookup.patch`, crbug 585053531): an own-property lookup on an object with a `kNonMasking` interceptor could end on a prototype's interceptor (`Object.hasOwn` true for a prototype-only name, `delete` reaching the prototype). - **`-11`, NativeScript/v8-buildscripts#13** (`v8_create_data_property_interceptor.patch`, `v8_interceptor_define_descriptor.patch`): `JSObject::CreateDataProperty` (define-semantics class fields once warm, `v8::Object::CreateDataProperty`) bypassed named interceptors, and a definer received a plain data property with every attribute inverted. - **`-12`, NativeScript/v8-buildscripts#15** (`v8_declined_interceptor_store_fast_path.patch`): when a masking named interceptor declines a store and the receiver already has that name as an own data field, the store IC overwrites the field directly instead of going through `Runtime_StorePropertyPastInterceptor`. Behind `--store-ic-declined-interceptor-fast-path`, on by default. On a phone, an expando overwrite on a canary goes from 178 to 105 ns; adding a property, writes that end at a prototype accessor, and everything else are unchanged. The canary mode later in this stack puts a masking named interceptor (setter, deleter, definer) on wrapper templates, and needs both. Nothing on Android uses a named interceptor on an instance template today, so this PR alone changes no behaviour. `-8` and `-9` add only Apple TV and Mac Catalyst variants. ### Testing Full suite on an arm64 API 35 emulator with the `-11` arm64 libraries: 1773 specs, 0 failures. With the `-12` patch (the #15 CI arm64 library), at the top of this stack on `main` at a59e6ba: 1895 / 1895 / 1909 specs, 0 failures, in `canary`/`all`, `canary`/`extended` and `resurrecting`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Chores** * Updated the V8 release from 14.9.207.39-11 to 14.9.207.39-12. * V8 installations now verify that each requested ABI matches the selected release and record the release for each installed ABI. Libraries and release stamps that do not match the selected release are removed during installation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.