Skip to content

Commit

Permalink
Update precompile_*.jl file (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: BeastyBlacksmith <BeastyBlacksmith@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and BeastyBlacksmith authored Jul 29, 2022
1 parent c9951fa commit 228e8c3
Showing 1 changed file with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,57 @@ macro warnpcfail(ex::Expr)
end


const __bodyfunction__ = Dict{Method,Any}()

# Find keyword "body functions" (the function that contains the body
# as written by the developer, called after all missing keyword-arguments
# have been assigned values), in a manner that doesn't depend on
# gensymmed names.
# `mnokw` is the method that gets called when you invoke it without
# supplying any keywords.
function __lookup_kwbody__(mnokw::Method)
function getsym(arg)
isa(arg, Symbol) && return arg
@assert isa(arg, GlobalRef)
return arg.name
end

f = get(__bodyfunction__, mnokw, nothing)
if f === nothing
fmod = mnokw.module
# The lowered code for `mnokw` should look like
# %1 = mkw(kwvalues..., #self#, args...)
# return %1
# where `mkw` is the name of the "active" keyword body-function.
ast = Base.uncompressed_ast(mnokw)
if isa(ast, Core.CodeInfo) && length(ast.code) >= 2
callexpr = ast.code[end-1]
if isa(callexpr, Expr) && callexpr.head == :call
fsym = callexpr.args[1]
if isa(fsym, Symbol)
f = getfield(fmod, fsym)
elseif isa(fsym, GlobalRef)
if fsym.mod === Core && fsym.name === :_apply
f = getfield(mnokw.module, getsym(callexpr.args[2]))
elseif fsym.mod === Core && fsym.name === :_apply_iterate
f = getfield(mnokw.module, getsym(callexpr.args[3]))
else
f = getfield(fsym.mod, fsym.name)
end
else
f = missing
end
else
f = missing
end
else
f = missing
end
__bodyfunction__[mnokw] = f
end
return f
end

function _precompile_()
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol, Any},AbstractMatrix})
Expand All @@ -22,12 +73,13 @@ function _precompile_()
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol, Any},GroupBy,Any,Any})
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol, Any},GroupBy,Any})
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol, Any},Type{SliceIt},Any,Any,Any})
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol, Any},Type{typeof(sin)},typeof(sin)})
Base.precompile(Tuple{typeof(RecipesBase.apply_recipe),AbstractDict{Symbol, Any},Vector{Function},Number,Number})
Base.precompile(Tuple{typeof(_apply_type_recipe),Any,AbstractArray,Any})
Base.precompile(Tuple{typeof(_apply_type_recipe),Any,Surface,Any})
Base.precompile(Tuple{typeof(_compute_xyz),Vector{Float64},Function,Nothing,Bool})
Base.precompile(Tuple{typeof(_compute_xyz),Vector{String},Vector{String},Nothing,Bool})
Base.precompile(Tuple{typeof(_extract_group_attributes),Vector{String}})
Base.precompile(Tuple{typeof(_prepare_series_data),Matrix{Union{Missing, Float64}}})
Base.precompile(Tuple{typeof(_process_seriesrecipe),Any,Any})
Base.precompile(Tuple{typeof(_process_seriesrecipes!),Any,Any})
Base.precompile(Tuple{typeof(_scaled_adapted_grid),Function,Symbol,Symbol,Float64,Irrational{}})
Expand All @@ -48,4 +100,9 @@ function _precompile_()
Base.precompile(Tuple{typeof(unzip),Vector{Tuple{Int64, Real}}})
Base.precompile(Tuple{typeof(unzip),Vector{Tuple{Vector{Float64}, Vector{Float64}}}})
isdefined(RecipesPipeline, Symbol("#11#12")) && Base.precompile(Tuple{getfield(RecipesPipeline, Symbol("#11#12")),Int64})
let fbody = try __lookup_kwbody__(which(_extract_group_attributes, (Vector{String},Vector{Float64},))) catch missing end
if !ismissing(fbody)
precompile(fbody, (Function,typeof(_extract_group_attributes),Vector{String},Vector{Float64},))
end
end
end

0 comments on commit 228e8c3

Please sign in to comment.