Skip to content

Commit 16bc3a1

Browse files
authored
Improve precompiles (#21)
1 parent 6df86ff commit 16bc3a1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/LoweredCodeUtils.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ occurs for "empty method" expressions, e.g., `:(function foo end)`. `pc` will be
485485
By default the method will be defined (evaluated). You can prevent this by setting `define=false`.
486486
This is recommended if you are simply extracting signatures from code that has already been evaluated.
487487
"""
488-
function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecialize(stmt), pc::Int; define=true)
488+
function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecialize(stmt), pc::Int; define::Bool=true)
489489
framecode, pcin = frame.framecode, pc
490490
if ismethod3(stmt)
491491
pc3 = pc
@@ -656,12 +656,20 @@ if ccall(:jl_generating_output, Cint, ()) == 1
656656
kwdefine = NamedTuple{(:define,),Tuple{Bool}}
657657
for ct in (Vector{Any}, Set{Any})
658658
f = methoddef!
659-
@assert precompile(Tuple{typeof(f), Any, ct, Frame, Expr, Int})
660-
# @assert precompile(Tuple{Core.kwftype(typeof(f)), kwdefine, typeof(f), Any, ct, Frame, Expr, Int})
659+
m = which(f, Tuple{Function, ct, Frame, Expr, Int})
660+
@assert precompile(Tuple{typeof(f), Function, ct, Frame, Expr, Int})
661+
mbody = bodymethod(m)
662+
@assert precompile(Tuple{mbody.sig.parameters[1], Bool, typeof(f), Function, ct, Frame, Expr, Int})
663+
@assert precompile(Tuple{Core.kwftype(typeof(f)), kwdefine, typeof(f), Function, ct, Frame, Expr, Int})
661664
f = methoddefs!
662665
@assert precompile(Tuple{typeof(f), Any, ct, Frame})
663-
# @assert precompile(Tuple{Core.kwftype(typeof(f)), kwdefine, typeof(f), Any, ct, Frame})
666+
@assert precompile(Tuple{Core.kwftype(typeof(f)), kwdefine, typeof(f), Function, ct, Frame})
664667
end
668+
@assert precompile(Tuple{typeof(rename_framemethods!), Any, Frame, Dict{Symbol,MethodInfo},
669+
Vector{NamedTuple{(:linetop, :linebody, :callee, :caller),Tuple{Int64,Int64,Symbol,Union{Bool, Symbol}}}},
670+
Dict{Symbol,Union{Bool, Symbol}}})
671+
@assert precompile(Tuple{typeof(identify_framemethod_calls), Frame})
672+
@assert precompile(Tuple{typeof(callchain), Vector{NamedTuple{(:linetop, :linebody, :callee, :caller),Tuple{Int64,Int64,Symbol,Union{Bool, Symbol}}}}})
665673
end
666674

667675
end # module

0 commit comments

Comments
 (0)