Skip to content

Commit 65b4924

Browse files
authored
Require method ownership (#154)
Based on poking around Julia's `src/dump.c`, it's my understanding that a *disconnected* (backedge-free) `MethodInstance` needs to be cached in the module owning the `Method`. The implication is that Base methods that get called on package-defined objects cannot be cached on their own merits, so we should exclude such `MethodInstance`s. The way to fix this is to make such calls inferrable, in which case they will be cached in the package module thanks to their backedges.
1 parent aeba47a commit 65b4924

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/parcel_snoopi.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,16 @@ function parcel(tinf::AbstractVector{Tuple{Float64, Core.MethodInstance}};
247247
# need to be defined; we collect all the corresponding modules and assign it to the
248248
# "topmost".
249249
empty!(mods)
250-
push!(mods, Base.moduleroot(m.module))
250+
mroot = Base.moduleroot(m.module)
251+
push!(mods, mroot)
251252
addmodules!(mods, tt.parameters)
252253
topmod = topmodule(mods)
253254
if topmod === nothing
254255
@debug "Skipping $tt due to lack of a suitable top module"
255256
continue
257+
elseif topmod !== mroot
258+
@debug "Skipping $tt due to lack of method ownership"
259+
continue
256260
end
257261
# If we haven't yet started the list for this module, initialize
258262
topmodname = nameof(topmod)

test/snoopi.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ uncompiled(x) = x + 1
7272
end
7373
pc = SnoopCompile.parcel(tinf)
7474
FK = pc[:Base]
75-
@test any(str->occursin("kwftype", str), FK)
75+
@test any(str->occursin("kwftype", str), FK)
76+
@test !any(str->occursin(r"Type\{NamedTuple.*typeof\(sin\)", str), FK)
7677
if VERSION >= v"1.4.0-DEV.215"
7778
@test any(str->occursin("__lookup_kwbody__", str), FK)
7879
else

0 commit comments

Comments
 (0)