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 = 0
14283+ # Stop this local propagation loop once the class-body call type tables
14284+ # stop changing; later passes would rescan the same bodies without
14285+ # teaching any callee a new argument type. Keep the previous pass's
14286+ # signature instead of recomputing it at the top of every pass, because
14287+ # the prior `cur_sig` is exactly the next pass's `prev_sig`.
14288+ prev_sig = class_body_call_type_signature
1428314289 while pass < 5
1428414290 ci = 0
1428514291 while ci < @cls_names.length
@@ -14392,6 +14398,11 @@
1439214398 @current_method_name = saved_meth_cb
1439314399 ci = ci + 1
1439414400 end
14401+ cur_sig = class_body_call_type_signature
14402+ if cur_sig == prev_sig
14403+ break
14404+ end
14405+ prev_sig = cur_sig
1439514406 pass = pass + 1
1439614407 end
1439714408 end
@@ -14555,6 +14566,15 @@
1455514566 @meth_return_types.join("|") + "/" + @cls_ivar_types.join("|") + "/" + @meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/")
1455614567 end
1455714568
14569+ # `inference_signature` covers the wider analyze-phase fixpoint, including
14570+ # return and ivar types that `infer_class_body_call_types` does not refine
14571+ # directly. This narrower fingerprint tracks only the param-type tables that
14572+ # can affect the next class-body call pass, so an unrelated wider signature
14573+ # change does not force this local loop to spend all five passes.
14574+ def class_body_call_type_signature
14575+ @meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/") + "/" + @cls_cmeth_ptypes.join("/")
14576+ end
14577+
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