Commit 7b14b0a6

7b14b0a63c06Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

Merge pull request #179 from mame/pr/unify-call-site-param-poly

fix(codegen): unify disagreeing call-site param types to poly + box

Conflicts:

spinel_codegen.rb

Details

Commit
7b14b0a63c06
Parent
dd03d810b5e0
Merge parent
19f0f007c216

spinel_codegen.rbmodifiedView file

@@ -6888,6 +6888,14 @@
68886888 while kk < arg_ids.length
68896889 at = infer_type(arg_ids[kk])
68906890 if kk < ptypes.length
6891+ # Unify against the existing param type rather
6892+ # than only widening from "int". The previous
6893+ # rule let the FIRST non-int call site freeze
6894+ # the param type; subsequent disagreeing calls
6895+ # (e.g. addr arg seen as Range from one site
6896+ # and as Integer from another) compiled to a
6897+ # signature mismatch. unify_call_types collapses
6898+ # incompatible types to "poly".
68916899 ptypes[kk] = unify_call_types(ptypes[kk], at, arg_ids[kk])
68926900 end
68936901 kk = kk + 1
@@ -10008,6 +10016,13 @@
1000810016 while kk < arg_ids.length
1000910017 at = infer_type(arg_ids[kk])
1001010018 if kk < ptypes.length
10019+ # Same unify-instead-of-only-widen-from-int change as
10020+ # the obj-recv path in scan_new_calls. A no-recv self
10021+ # call inside the same class is the path that, e.g.,
10022+ # `def boot; add_mappings(0x..0x, ...); end` inside
10023+ # CPU#boot lands on, and disagreeing arg types from
10024+ # different self-calls need to widen to poly rather
10025+ # than freezing on the first non-int call site.
1001110026 ptypes[kk] = unify_call_types(ptypes[kk], at, arg_ids[kk])
1001210027 end
1001310028 kk = kk + 1