Commit e29cda4c

e29cda4cb6beMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · ~3 modified

Description

Seed hash-param value type from string/symbol-keyed []= writes

The usage-driven hash promotion skips parameters (they are typed from call sites), so a hash param filled internally by p[s] = v and read back via p.fetch(s) defaulted to str_poly through a monotonic cycle: the read yields poly, the poly flows back into the param's stored value type, and nothing narrows it. infer_param_hash_value narrows such a param to the concrete hash its own writes establish.

Only string/symbol-keyed []= writes count: an int-keyed p[i] = v is ambiguous with array element assignment (e.g. an int_array RAM param filled by ram[i] = b), so int keys must not be read as hash evidence -- doing so mistyped optcarrot's RAM param and broke it.

Resolves the last self-host inference cycle: local_class (name -> class_idx, str_int) was str_poly, so recv_class_idx_for_rebind returned poly, so the class-index ci was poly, so @cls_meth_idx_cache[ci*N+id] keyed on poly and boxed an int_int_hash literal into poly. With local_class -> str_int the whole chain is int. spinelc now compiles legacy/spinel_analyze.rb with ZERO unsupported constructs (remaining work: a few emitted-C type mismatches).

Gates: 845 test, 57 bench, optcarrot checksum 59662 -- all green.

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
e29cda4cb6be
Parent
70763b040501

src/analyze.cmodifiedView file

@@ -966,6 +966,7 @@
966966 build_ie_map(c); /* refresh instance_exec receiver-class map each pass */
967967 ch |= infer_write_types(c);
968968 ch |= infer_param_types(c);
969+ ch |= infer_param_hash_value(c);
969970 ch |= propagate_prep_params(c);
970971 ch |= infer_string_params(c);
971972 ch |= infer_default_param_types(c);
@@ -1011,6 +1012,7 @@
10111012 sp_narrow_memo_bump(); /* invalidate per-iteration narrow-helper memo */
10121013 ch |= infer_write_types(c);
10131014 ch |= infer_param_types(c);
1015+ ch |= infer_param_hash_value(c);
10141016 ch |= propagate_prep_params(c);
10151017 ch |= infer_string_params(c);
10161018 ch |= infer_default_param_types(c);