-
-
Notifications
You must be signed in to change notification settings - Fork 158
perf(object): keep populated-delete ICs stable per key #9137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
proggeramlug
merged 2 commits into
PerryTS:main
from
proggeramlug:fix/9064-stable-delete-ic
Aug 30, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ### perf(runtime,codegen): keep populated-delete ICs stable per key | ||
|
|
||
| Owned ordinary objects now keep one ShapeId across tombstone delete/re-add | ||
| epochs. Read and write IC hits validate the cached value slot against | ||
| `TAG_HOLE`, while a guarded re-add lane appends the key to preserve enumeration | ||
| order and re-primes both megamorphic caches. Squeeze still publishes a fresh | ||
| immutable shape, and flag-off in-place compaction retires growth-era prefix | ||
| tokens before shifting keys. | ||
|
|
||
| On Linux, a min-of-seven interleaved run of `bench_popdel.ts` against the exact | ||
| main tip improves from 329 ms to 57 ms (Node: 21 ms, Perry: 2.71x Node), while | ||
| the six #9029 differentials remain byte-identical in both tombstone modes. | ||
| Fixes #9064. |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| //! Stable-tombstone slot validation shared by the static and dynamic write ICs. | ||
| //! | ||
| //! A stable-tombstone receiver deliberately keeps its ShapeId while deletes | ||
| //! leave `TAG_HOLE` in individual slots. Both write ICs therefore need the | ||
| //! same cold validation diamond before their ordinary direct-store block. | ||
|
|
||
| use crate::types::{DOUBLE, I16, I64}; | ||
|
|
||
| use super::FnCtx; | ||
|
|
||
| /// Runtime `OBJ_FLAG_STABLE_TOMBSTONES`. The bit is already present in each | ||
| /// generated write guard's `_reserved` load; on a hit it gates the one deleted | ||
| /// slot check required while the receiver keeps a stable ShapeId (#9064). | ||
| const STABLE_TOMBSTONES_OBJ_FLAG: u16 = 0x400; | ||
|
|
||
| pub(super) struct StableTombstoneSlotCheck { | ||
| validate_idx: usize, | ||
| live_idx: usize, | ||
| validate_label: String, | ||
| live_label: String, | ||
| } | ||
|
|
||
| impl StableTombstoneSlotCheck { | ||
| /// Create the cold validation block followed by the ordinary live-slot | ||
| /// continuation, preserving the caller's basic-block creation order. | ||
| pub(super) fn new(ctx: &mut FnCtx<'_>, validate_name: &str, live_name: &str) -> Self { | ||
| let validate_idx = ctx.new_block(validate_name); | ||
| let live_idx = ctx.new_block(live_name); | ||
| Self { | ||
| validate_idx, | ||
| live_idx, | ||
| validate_label: ctx.block_label(validate_idx), | ||
| live_label: ctx.block_label(live_idx), | ||
| } | ||
| } | ||
|
|
||
| /// Branch ordinary receivers straight to the direct store. Stable- | ||
| /// tombstone receivers first prove that the cached slot is still live. | ||
| pub(super) fn emit( | ||
| &self, | ||
| ctx: &mut FnCtx<'_>, | ||
| reserved: &str, | ||
| slot_ptr: &str, | ||
| deleted_label: &str, | ||
| ) { | ||
| let stable_tombstones = | ||
| ctx.block() | ||
| .and(I16, reserved, &STABLE_TOMBSTONES_OBJ_FLAG.to_string()); | ||
| let needs_slot_validation = ctx.block().icmp_ne(I16, &stable_tombstones, "0"); | ||
| ctx.block().cond_br( | ||
| &needs_slot_validation, | ||
| &self.validate_label, | ||
| &self.live_label, | ||
| ); | ||
|
|
||
| ctx.current_block = self.validate_idx; | ||
| let old_value = ctx.block().load(DOUBLE, slot_ptr); | ||
| let old_bits = ctx.block().bitcast_double_to_i64(&old_value); | ||
| let deleted = ctx | ||
| .block() | ||
| .icmp_eq(I64, &old_bits, crate::nanbox::TAG_HOLE_I64); | ||
| ctx.block() | ||
| .cond_br(&deleted, deleted_label, &self.live_label); | ||
| } | ||
|
|
||
| pub(super) fn enter_live(&self, ctx: &mut FnCtx<'_>) { | ||
| ctx.current_block = self.live_idx; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Route deleted primary hits through
pic.miss.hit_deletedbranches directly topic.miss.call. This bypasses the guard-fail and fallback-call feedback records inpic.miss. The deleted polymorphic-way path records those events before it calls the runtime helper. Branch tomiss_labelhere.🤖 Prompt for AI Agents