feat(jit): specialize Set/ArrayPush on delayed-move collection rebinds - #1
Merged
Conversation
Record same-local rebinds (stloc Null then Set/ArrayPush) directly in native traces, removing the call boundary that previously forced interpreter fallback. Key changes: - ValueInfo now carries a source_local provenance tag set exclusively at Ldloc; arithmetic, constants, and call outputs clear it, ensuring the recorder and static loop-header plan agree on which local a value came from. - Recorder selects ArraySet / MapSet / ArrayPush specialization only when the container operand still carries the source local and that symbolic local is Null (dirty + known_type Null). Additional args that also share the moved local are rejected to prevent alias correctness issues. - New native bridge helpers pd_vm_native_collection_set and pd_vm_native_array_push use ptr::replace to take true ownership of the container slot, perform COW/rebind/shared-impl logic, and write the result back to the same owned-temp slot, compatible with native loop-back. - Reusable owned helpers builtin_set_owned / builtin_array_push_owned keep interpreter and JIT paths on the same semantics. - Lowering allocates MutationArgBox temp slots for index/key/value and calls collection_set / array_push native helpers with status checking. - Benchmark harness extended to gate per-sample native execution growth and freeze trace_attempts / recorded_traces / native traces during measurement. Tests (all passing): - trace_jit_specializes_same_local_array_set_through_loop_back - trace_jit_specializes_same_local_map_set_through_loop_back (dual mutation with null-delete) - trace_jit_specializes_same_local_array_push_through_loop_back - trace_jit_array_set_preserves_cow_alias - trace_jit_does_not_consume_non_moved_array_set_container Collection rebind benchmark (release, 50K iters, width=256, 15 samples): array: interpreter 5928 µs → JIT 1181 µs (0.20×, ~5× speedup) map: interpreter 22822 µs → JIT 2325 µs (0.10×, ~10× speedup) WAF benchmark sub-par because its Set calls do not use the rebind pattern; JIT trace statistics confirm the expected LoopBack shape for the micro-bench workloads.
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.
Record same-local rebinds (stloc Null then Set/ArrayPush) directly in native traces, removing the call boundary that previously forced interpreter fallback.
Key changes:
Tests (all passing):
Collection rebind benchmark (release, 50K iters, width=256, 15 samples):
array: interpreter 5928 µs → JIT 1181 µs (0.20×, ~5× speedup)
map: interpreter 22822 µs → JIT 2325 µs (0.10×, ~10× speedup)
WAF benchmark sub-par because its Set calls do not use the rebind pattern; JIT trace statistics confirm the expected LoopBack shape for the micro-bench workloads.