Commit 74d63c93
74d63c93e2aaMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Inline a yielding initialize at the Klass.new call site
Pool.new(2) { make_handle } with a yielding initialize previously dropped the
block (a yields=1 initialize is never emitted as a function, so the constructor
only allocated). The call site now inlines the initialize body with self bound
to the fresh object and the literal block feeding its yields -- the same
per-call-site specialization as ordinary yield-method inlining, wrapped in a
statement expression yielding the object.
analyze: yield_value_type resolves a Klass.new { block } call site to the
class's initialize, so @arr.push(yield) types the ivar's element from the
block value (block-param typing from yield args already handled Class.new).
Fixes i709.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 74d63c93e2aa
- Parent
- 578982b94c50
src/analyze.cmodifiedView file
} else { TyKind crt = infer_type(c, crecv); if (ty_is_object(crt)) rmi = comp_method_in_chain(c, ty_object_class(crt), cn, NULL); /* `Klass.new { block }`: the block feeds the class's initialize. */ else if (cn && !strcmp(cn, "new") && nt_type(nt, crecv) && !strcmp(nt_type(nt, crecv), "ConstantReadNode")) { int nci = comp_class_index(c, nt_str(nt, crecv, "name")); if (nci >= 0) rmi = comp_method_in_chain(c, nci, "initialize", NULL); } } if (rmi != mi) continue; int bb = nt_ref(nt, blk, "body");src/codegen.cmodifiedView file
Loading diff…