Commit 822d8ff0

822d8ff0270eMerged

shigeru.nakajima <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

perf(analyze): stop class body call inference after convergence

Details

Commit
822d8ff0270e
Parent
3c07fba9b1ad

spinel_analyze.rbmodifiedView file

@@ -14230,6 +14230,12 @@
1423014230 # Update called method param types from argument types at call sites.
1423114231 # Run multiple passes for propagation.
1423214232 pass = 0
14233+ # Stop this local propagation loop once the class-body call type tables
14234+ # stop changing; later passes would rescan the same bodies without
14235+ # teaching any callee a new argument type. Keep the previous pass's
14236+ # signature instead of recomputing it at the top of every pass, because
14237+ # the prior `cur_sig` is exactly the next pass's `prev_sig`.
14238+ prev_sig = class_body_call_type_signature
1423314239 while pass < 5
1423414240 ci = 0
1423514241 while ci < @cls_names.length
@@ -14342,6 +14348,11 @@
1434214348 @current_method_name = saved_meth_cb
1434314349 ci = ci + 1
1434414350 end
14351+ cur_sig = class_body_call_type_signature
14352+ if cur_sig == prev_sig
14353+ break
14354+ end
14355+ prev_sig = cur_sig
1434514356 pass = pass + 1
1434614357 end
1434714358 end
@@ -14505,6 +14516,15 @@
1450514516 @meth_return_types.join("|") + "/" + @cls_ivar_types.join("|") + "/" + @meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/")
1450614517 end
1450714518
14519+ # `inference_signature` covers the wider analyze-phase fixpoint, including
14520+ # return and ivar types that `infer_class_body_call_types` does not refine
14521+ # directly. This narrower fingerprint tracks only the param-type tables that
14522+ # can affect the next class-body call pass, so an unrelated wider signature
14523+ # change does not force this local loop to spend all five passes.
14524+ def class_body_call_type_signature
14525+ @meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/") + "/" + @cls_cmeth_ptypes.join("/")
14526+ end
14527+
1450814528
1450914529 # End-to-end whole-program analysis. Splits cleanly out of `compile`
1451014530 # so the same work can be invoked once and its results serialized