Commit 22dbee2d
22dbee2d65deMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
Merge pull request #421 from ledsun/codex/class-body-inference-convergence
perf(analyze): stop class body call inference after convergence
Details
- Commit
- 22dbee2d65de
- Parent
- bd18403c6e4b
- Merge parent
- 822d8ff0270e
spinel_analyze.rbmodifiedView file
@@ -14280,6 +14280,12 @@
1428014280
# Update called method param types from argument types at call sites.1428114281
# Run multiple passes for propagation.1428214282
pass = 014283+
# Stop this local propagation loop once the class-body call type tables14284+
# stop changing; later passes would rescan the same bodies without14285+
# teaching any callee a new argument type. Keep the previous pass's14286+
# signature instead of recomputing it at the top of every pass, because14287+
# the prior `cur_sig` is exactly the next pass's `prev_sig`.14288+
prev_sig = class_body_call_type_signature1428314289
while pass < 51428414290
ci = 01428514291
while ci < @cls_names.length@@ -14392,6 +14398,11 @@
1439214398
@current_method_name = saved_meth_cb1439314399
ci = ci + 11439414400
end14401+
cur_sig = class_body_call_type_signature14402+
if cur_sig == prev_sig14403+
break14404+
end14405+
prev_sig = cur_sig1439514406
pass = pass + 11439614407
end1439714408
end@@ -14555,6 +14566,15 @@
1455514566
@meth_return_types.join("|") + "/" + @cls_ivar_types.join("|") + "/" + @meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/")1455614567
end1455714568
14569+
# `inference_signature` covers the wider analyze-phase fixpoint, including14570+
# return and ivar types that `infer_class_body_call_types` does not refine14571+
# directly. This narrower fingerprint tracks only the param-type tables that14572+
# can affect the next class-body call pass, so an unrelated wider signature14573+
# change does not force this local loop to spend all five passes.14574+
def class_body_call_type_signature14575+
@meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/") + "/" + @cls_cmeth_ptypes.join("/")14576+
end14577+
1455814578
1455914579
# End-to-end whole-program analysis. Splits cleanly out of `compile`1456014580
# so the same work can be invoked once and its results serialized