Repository navigation
Whether a to_a result is mutated finds its local writes off an index - #8149
Conversation
an_to_a_result_mutated asks, for an Array a call answers, whether it is mutated in place: as the receiver of a mutator, or through a local it is written to. The receiver and the local's calls come off the variable-site index (matz#8014), but the writes themselves were found by walking every local-variable write of the program and comparing its value, for each call asked about, every round. On the 86k-line actionpack sample that walk was the costliest line of a second-pass fixpoint round (~14% of its samples). The site index now also chains the local writes by the node they write (comp_lwrite_of_value), built in the same pass and kept as fresh. The answer is a yes/no over the same writes, so nothing else changes; the activesupport sample's C is byte-identical. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe compiler now indexes local-variable writes by the node that supplies their value. Type analysis uses this index to find writes associated with a call when checking whether its result is mutated. ChangesLocal Write Index
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Suggested reviewers:
|
Compile time:
an_to_a_result_mutatedfound the local writes of an Array-answering call by walking every local-variable write in the program and comparing its value, once per call asked about and every fixpoint round.The rest of the question was already off the variable-site index (#8014): the receiver parent, and the calls on each local. This adds the missing piece to the same index: a chain of the local writes by the node they write (
comp_lwrite_of_value/comp_lwrite_next). It's built in the same pass as the rest of the index and rebuilt under the same conditions. A chain rather than a single slot keeps the answer exact if a desugar ever shares a value node between writes.Measured on an 86k-line actionpack program (a single-file ActionDispatch app with its gems inlined), on master plus #8138: this loop was the costliest line of a second-pass fixpoint round, about 14% of its samples (
analyze_infer.c:1866).The answer is a yes/no over the same writes, so behavior doesn't change. The emitted C for the 33k-line activesupport sample is byte-identical to master's.
🤖 Generated with Claude Code
Summary by CodeRabbit