Commit 41c87970
41c879704177Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Keep index-filled array ivars typed instead of promoting to a hash
@a[i] = v with an int key promoted a TY_UNKNOWN ivar slot toward an
int-keyed hash, which then unified with the array-literal construction
write (@a = [x]*n) to poly. The existing guard that skips usage-driven
hash promotion when a typed construction write exists only applied to
plain reads; extend it to []= index-writes. A genuine hash (@h = {})
infers UNKNOWN from its empty literal and is unaffected, so only ivars
with a concrete array-typed construction are protected.
Together with the splat-literal fix this de-polys optcarrot's @palette -> @output_color -> render_pixel chain: best-of-15 628 -> 731 fps (legacy 735), checksum 59662 unchanged. Gates: 845 test, 57 bench green.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 41c879704177
- Parent
- ee4d5394f518
src/analyze_pass.cmodifiedView file
(but allow push-driven array promotion through). Without this guard, @free[0] read promotes @free to poly_poly_hash before @free = [] has been processed as an array. */ if (!is_push && !is_idx_write && *slot == TY_UNKNOWN && inm) { /* A typed (non-nil) construction write — `@a = [x]*n`, `@a = arr.map{}`, or an `@a = []` literal — means this ivar is an array filled by index, not a hash. Skip usage-driven hash promotion for both plain reads and `@a[k]=v` index-writes. A genuine hash (`@h = {}`) infers UNKNOWN from its empty literal and is unaffected. */ if (!is_push && *slot == TY_UNKNOWN && inm) { int has_typed_write = 0; for (int _wi = 0; _wi < nt->count && !has_typed_write; _wi++) { if (!nt_type(nt, _wi) || strcmp(nt_type(nt, _wi), "InstanceVariableWriteNode")) continue;