-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make delete_method work #6
Conversation
Sorry i didn't review this earlier, but this surprises me! Why does having edges to all the methods fix method deletions? Is it just because you're also adding a method to the method table? I would assume that whatever mechanism normally handles method deletions should apply in this situation as well, no? |
For example, here, there's only a single back-edge from
(Where |
Oh that was a bit excessive. yeah. Needs a follow up to cut them down to just the ones that match this.
I assume I am hooking into whatever mechanism normally handles method deletions. We can't directly use that mechanism without manually hooking because this is a generated function. |
gottttcha, you were trying to hit all the method instances 👍 It's kinda dumb, but this is what i've done in the past to get all the specializations:
|
Okay, yeah, it might actually be doing exactly that:
One thing to note, though, I think julia> f(x) = "Any"
f (generic function with 1 method)
julia> NHDalyUtils.func_all_backedges(f)
Dict{Symbol,Array{Any,1}} with 1 entry:
:MethodTable => Any[]
julia> method_insts = Core.Compiler.method_instances(f, (String,), typemax(UInt))
1-element Array{Core.MethodInstance,1}:
MethodInstance for f(::String)
julia> method_insts = Core.Compiler.method_instances(f, (Any,), typemax(UInt))
1-element Array{Core.MethodInstance,1}:
MethodInstance for f(::Any)
julia> NHDalyUtils.func_all_backedges(f)
Dict{Any,Array{Any,1}} with 3 entries:
(f(x) in Main at REPL[41]:1, Tuple{typeof(f),Any}) => Any[]
(f(x) in Main at REPL[41]:1, Tuple{typeof(f),String}) => Any[]
:MethodTable => Any[]
|
How do I go from that
|
Huh, that's surprising. I guess he means that it depends on the context? I'm not sure. Maybe i'm missing something, but I think it's just there in the julia> m = methods(f).ms[1]
f(x) in Main at REPL[1]:1
julia> specializations = let
out = []
s = m.specializations
while s isa Core.TypeMapEntry
push!(out, s)
s=s.next
end
out
end
1-element Array{Any,1}:
Core.TypeMapEntry(nothing, Tuple{typeof(f),Int64}, nothing, svec(), 1, -1, MethodInstance for f(::Int64), true, true, false)
julia> mis = [s.func for s in specializations]
1-element Array{Core.MethodInstance,1}:
MethodInstance for f(::Int64)
julia> mis == Core.Compiler.method_instances(f, (Int,))
true |
Closes #1
@NHDaly might review