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 = 014233+
# Stop this local propagation loop once the class-body call type tables14234+
# stop changing; later passes would rescan the same bodies without14235+
# teaching any callee a new argument type. Keep the previous pass's14236+
# signature instead of recomputing it at the top of every pass, because14237+
# the prior `cur_sig` is exactly the next pass's `prev_sig`.14238+
prev_sig = class_body_call_type_signature1423314239
while pass < 51423414240
ci = 01423514241
while ci < @cls_names.length@@ -14342,6 +14348,11 @@
1434214348
@current_method_name = saved_meth_cb1434314349
ci = ci + 11434414350
end14351+
cur_sig = class_body_call_type_signature14352+
if cur_sig == prev_sig14353+
break14354+
end14355+
prev_sig = cur_sig1434514356
pass = pass + 11434614357
end1434714358
end@@ -14505,6 +14516,15 @@
1450514516
@meth_return_types.join("|") + "/" + @cls_ivar_types.join("|") + "/" + @meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/")1450614517
end1450714518
14519+
# `inference_signature` covers the wider analyze-phase fixpoint, including14520+
# return and ivar types that `infer_class_body_call_types` does not refine14521+
# directly. This narrower fingerprint tracks only the param-type tables that14522+
# can affect the next class-body call pass, so an unrelated wider signature14523+
# change does not force this local loop to spend all five passes.14524+
def class_body_call_type_signature14525+
@meth_param_types.join("|") + "/" + @cls_meth_ptypes.join("/") + "/" + @cls_cmeth_ptypes.join("/")14526+
end14527+
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