Skip to content

Commit f22dacf

Browse files
authored
Merge pull request #28 from juliamatlab/create-pull-request/SnoopCompile
[AUTO] Update precompile_*.jl file
2 parents a65729a + 9e0e00e commit f22dacf

File tree

1 file changed

+66
-11
lines changed

1 file changed

+66
-11
lines changed

deps/SnoopCompile/precompile/precompile_MatLang.jl

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,62 @@
1+
const __bodyfunction__ = Dict{Method,Any}()
2+
3+
# Find keyword "body functions" (the function that contains the body
4+
# as written by the developer, called after all missing keyword-arguments
5+
# have been assigned values), in a manner that doesn't depend on
6+
# gensymmed names.
7+
# `mnokw` is the method that gets called when you invoke it without
8+
# supplying any keywords.
9+
function __lookup_kwbody__(mnokw::Method)
10+
function getsym(arg)
11+
isa(arg, Symbol) && return arg
12+
@assert isa(arg, GlobalRef)
13+
return arg.name
14+
end
15+
16+
f = get(__bodyfunction__, mnokw, nothing)
17+
if f === nothing
18+
fmod = mnokw.module
19+
# The lowered code for `mnokw` should look like
20+
# %1 = mkw(kwvalues..., #self#, args...)
21+
# return %1
22+
# where `mkw` is the name of the "active" keyword body-function.
23+
ast = Base.uncompressed_ast(mnokw)
24+
if isa(ast, Core.CodeInfo) && length(ast.code) >= 2
25+
callexpr = ast.code[end-1]
26+
if isa(callexpr, Expr) && callexpr.head == :call
27+
fsym = callexpr.args[1]
28+
if isa(fsym, Symbol)
29+
f = getfield(fmod, fsym)
30+
elseif isa(fsym, GlobalRef)
31+
if fsym.mod === Core && fsym.name === :_apply
32+
f = getfield(mnokw.module, getsym(callexpr.args[2]))
33+
elseif fsym.mod === Core && fsym.name === :_apply_iterate
34+
f = getfield(mnokw.module, getsym(callexpr.args[3]))
35+
else
36+
f = getfield(fsym.mod, fsym.name)
37+
end
38+
else
39+
f = missing
40+
end
41+
else
42+
f = missing
43+
end
44+
else
45+
f = missing
46+
end
47+
__bodyfunction__[mnokw] = f
48+
end
49+
return f
50+
end
51+
152
function _precompile_()
253
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
3-
isdefined(MatLang, Symbol("##sortperm#31")) && precompile(Tuple{getfield(MatLang, Symbol("##sortperm#31")),Int64,Bool,typeof(sortperm),Array{Int64,2}})
454
isdefined(MatLang, Symbol("#32#33")) && precompile(Tuple{getfield(MatLang, Symbol("#32#33")),Array{Int64,1}})
55+
let fbody = try __lookup_kwbody__(which(sortperm, (Array{Int64,2},))) catch missing end
56+
if !ismissing(fbody)
57+
precompile(fbody, (Int64,Bool,typeof(sortperm),Array{Int64,2},))
58+
end
59+
end
560
precompile(Tuple{Core.kwftype(typeof(MatLang.eyeM)),NamedTuple{(:like,),Tuple{Array{Int8,2}}},typeof(eyeM),Int64,Int64})
661
precompile(Tuple{Core.kwftype(typeof(MatLang.freqspaceM)),NamedTuple{(:dim,),Tuple{Int64}},typeof(freqspaceM),Int64})
762
precompile(Tuple{Core.kwftype(typeof(MatLang.ndgridM)),NamedTuple{(:dim,),Tuple{Int64}},typeof(ndgridM),StepRange{Int64,Int64}})
@@ -29,9 +84,9 @@ function _precompile_()
2984
precompile(Tuple{typeof(eyeM),Int64,Int64})
3085
precompile(Tuple{typeof(eyeM),Int64})
3186
precompile(Tuple{typeof(eyeM),Tuple{Int64,Int64}})
32-
precompile(Tuple{typeof(eyeM),Type,Array{Int64,1}})
33-
precompile(Tuple{typeof(eyeM),Type,Int64,Int64})
34-
precompile(Tuple{typeof(eyeM),Type,Tuple{Int64,Int64}})
87+
precompile(Tuple{typeof(eyeM),Type{T} where T,Array{Int64,1}})
88+
precompile(Tuple{typeof(eyeM),Type{T} where T,Int64,Int64})
89+
precompile(Tuple{typeof(eyeM),Type{T} where T,Tuple{Int64,Int64}})
3590
precompile(Tuple{typeof(falseM),Array{Int64,1}})
3691
precompile(Tuple{typeof(falseM),Int64})
3792
precompile(Tuple{typeof(falseM),Symbol,Int64})
@@ -131,16 +186,16 @@ function _precompile_()
131186
precompile(Tuple{typeof(onesM),Int64})
132187
precompile(Tuple{typeof(onesM),Symbol,Int64})
133188
precompile(Tuple{typeof(onesM),Tuple{Int64,Int64}})
134-
precompile(Tuple{typeof(onesM),Type,Int64,Int64})
135-
precompile(Tuple{typeof(onesM),Type,Tuple{Int64,Int64}})
136189
precompile(Tuple{typeof(onesM),Type{Int32},Array{Int64,1}})
190+
precompile(Tuple{typeof(onesM),Type{T} where T,Int64,Int64})
191+
precompile(Tuple{typeof(onesM),Type{T} where T,Tuple{Int64,Int64}})
137192
precompile(Tuple{typeof(randM),Array{Int64,1}})
138193
precompile(Tuple{typeof(randM),Int64})
139194
precompile(Tuple{typeof(randM),Symbol,Int64})
140195
precompile(Tuple{typeof(randM),Tuple{Int64,Int64}})
141-
precompile(Tuple{typeof(randM),Type,Int64,Int64})
142-
precompile(Tuple{typeof(randM),Type,Tuple{Int64,Int64}})
143196
precompile(Tuple{typeof(randM),Type{Int32},Array{Int64,1}})
197+
precompile(Tuple{typeof(randM),Type{T} where T,Int64,Int64})
198+
precompile(Tuple{typeof(randM),Type{T} where T,Tuple{Int64,Int64}})
144199
precompile(Tuple{typeof(repelemM),Array{Int64,2},Int64})
145200
precompile(Tuple{typeof(repmatM),Array{Int64,1},Array{Int64,1}})
146201
precompile(Tuple{typeof(repmatM),Array{Int64,1},Int64,Int64})
@@ -171,8 +226,8 @@ function _precompile_()
171226
precompile(Tuple{typeof(zerosM),Int64})
172227
precompile(Tuple{typeof(zerosM),Symbol,Int64})
173228
precompile(Tuple{typeof(zerosM),Tuple{Int64,Int64}})
174-
precompile(Tuple{typeof(zerosM),Type,Int64,Int64,Int64})
175-
precompile(Tuple{typeof(zerosM),Type,Int64,Int64})
176-
precompile(Tuple{typeof(zerosM),Type,Tuple{Int64,Int64}})
177229
precompile(Tuple{typeof(zerosM),Type{Int32},Array{Int64,1}})
230+
precompile(Tuple{typeof(zerosM),Type{T} where T,Int64,Int64,Int64})
231+
precompile(Tuple{typeof(zerosM),Type{T} where T,Int64,Int64})
232+
precompile(Tuple{typeof(zerosM),Type{T} where T,Tuple{Int64,Int64}})
178233
end

0 commit comments

Comments
 (0)