Skip to content

Commit c3854f5

Browse files
authored
Fix precompiles and enforce their validity (#208)
`precompile` doesn't error when the specified signature doesn't exist, it just returns `false`. This enforces a match and fixes the few cases where we were specifying a nonexistent method.
1 parent 303075b commit c3854f5

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

src/precompile.jl

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
function _precompile_()
22
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
3-
precompile(Tuple{typeof(maybe_evaluate_builtin), Frame, Expr, Bool})
4-
precompile(Tuple{typeof(getargs), Vector{Any}, Frame})
5-
precompile(Tuple{typeof(get_call_framecode), Vector{Any}, FrameCode, Int})
6-
for f in (evaluate_call!,
7-
evaluate_structtype,
3+
@assert precompile(Tuple{typeof(maybe_evaluate_builtin), Frame, Expr, Bool})
4+
@assert precompile(Tuple{typeof(getargs), Vector{Any}, Frame})
5+
@assert precompile(Tuple{typeof(get_call_framecode), Vector{Any}, FrameCode, Int})
6+
@assert precompile(evaluate_call_recurse!, (Function, Frame, Expr))
7+
@assert precompile(evaluate_call_compiled!, (Compiled, Frame, Expr))
8+
for f in (evaluate_structtype,
89
evaluate_abstracttype,
910
evaluate_primitivetype)
10-
precompile(Tuple{typeof(f), Any, Frame, Expr})
11+
@assert precompile(Tuple{typeof(f), Any, Frame, Expr})
1112
end
12-
precompile(Tuple{typeof(evaluate_foreigncall), Frame, Expr})
13-
precompile(Tuple{typeof(evaluate_methoddef), Frame, Expr})
14-
precompile(Tuple{typeof(lookup_global_refs!), Expr})
15-
precompile(Tuple{typeof(lookup_or_eval), Any, Frame, Any})
16-
precompile(Tuple{typeof(eval_rhs), Any, Frame, Expr})
17-
precompile(Tuple{typeof(step_expr!), Any, Frame, Any, Bool})
13+
@assert precompile(Tuple{typeof(evaluate_foreigncall), Frame, Expr})
14+
@assert precompile(Tuple{typeof(evaluate_methoddef), Frame, Expr})
15+
@assert precompile(Tuple{typeof(lookup_global_refs!), Expr})
16+
@assert precompile(Tuple{typeof(lookup_or_eval), Any, Frame, Any})
17+
@assert precompile(Tuple{typeof(eval_rhs), Any, Frame, Expr})
18+
@assert precompile(Tuple{typeof(step_expr!), Any, Frame, Any, Bool})
1819
for f in (finish!, finish_and_return!, finish_stack!, next_call!, maybe_next_call!, next_line!)
19-
precompile(Tuple{typeof(f), Any, Frame, Bool})
20+
@assert precompile(Tuple{typeof(f), Any, Frame, Bool})
2021
end
21-
precompile(Tuple{typeof(through_methoddef_or_done!), Any, Frame})
22-
precompile(Tuple{typeof(split_expressions), Module, Expr})
23-
precompile(Tuple{typeof(split_expressions!), Vector{Tuple{Module,Expr}}, Dict{Module,Vector{Expr}}, Expr, Module, Expr})
24-
precompile(Tuple{typeof(prepare_thunk), Module, Expr})
25-
precompile(Tuple{typeof(prepare_thunk), Module, Expr, Bool})
26-
precompile(Tuple{typeof(prepare_framedata), FrameCode, Vector{Any}})
27-
precompile(Tuple{typeof(prepare_args), Any, Vector{Any}, Vector{Any}})
28-
precompile(Tuple{typeof(prepare_call), Any, Vector{Any}})
29-
precompile(Tuple{typeof(Core.kwfunc(prepare_call)), NamedTuple{(:enter_generated,),Tuple{Bool}}, typeof(prepare_call), Function, Vector{Any}})
30-
precompile(Tuple{typeof(Core.kwfunc(prepare_framecode)), NamedTuple{(:enter_generated,),Tuple{Bool}}, typeof(prepare_framecode), Method, Type})
31-
precompile(Tuple{typeof(prepare_frame), FrameCode, Vector{Any}, Core.SimpleVector})
32-
precompile(Tuple{typeof(extract_args), Module, Expr})
33-
precompile(Tuple{typeof(enter_call), Int, Int})
34-
precompile(Tuple{typeof(enter_call_expr), Expr})
35-
precompile(Tuple{typeof(copy_codeinfo), Core.CodeInfo})
36-
precompile(Tuple{typeof(optimize!), Core.CodeInfo, Module})
37-
precompile(Tuple{typeof(set_structtype_const), Module, Symbol})
38-
precompile(Tuple{typeof(namedtuple), Vector{Any}})
39-
precompile(Tuple{typeof(resolvefc), Any})
40-
precompile(Tuple{typeof(check_isdefined), Frame, Any})
41-
precompile(Tuple{typeof(find_used), Core.CodeInfo})
42-
precompile(Tuple{typeof(do_assignment!), Frame, Any, Any})
43-
precompile(Tuple{typeof(pc_expr), Frame})
22+
@assert precompile(Tuple{typeof(through_methoddef_or_done!), Any, Frame})
23+
@assert precompile(Tuple{typeof(split_expressions), Module, Expr})
24+
@assert precompile(Tuple{typeof(split_expressions!), Vector{Tuple{Module,Expr}}, Dict{Module,Vector{Expr}}, Expr, Module, Expr})
25+
@assert precompile(Tuple{typeof(prepare_thunk), Module, Expr})
26+
@assert precompile(Tuple{typeof(prepare_thunk), Module, Expr, Bool})
27+
@assert precompile(Tuple{typeof(prepare_framedata), FrameCode, Vector{Any}})
28+
@assert precompile(Tuple{typeof(prepare_args), Any, Vector{Any}, Vector{Any}})
29+
@assert precompile(Tuple{typeof(prepare_call), Any, Vector{Any}})
30+
@assert precompile(Tuple{typeof(Core.kwfunc(prepare_call)), NamedTuple{(:enter_generated,),Tuple{Bool}}, typeof(prepare_call), Function, Vector{Any}})
31+
@assert precompile(Tuple{typeof(Core.kwfunc(prepare_framecode)), NamedTuple{(:enter_generated,),Tuple{Bool}}, typeof(prepare_framecode), Method, Tuple{Int}})
32+
@assert precompile(Tuple{typeof(prepare_frame), FrameCode, Vector{Any}, Core.SimpleVector})
33+
@assert precompile(Tuple{typeof(extract_args), Module, Expr})
34+
@assert precompile(Tuple{typeof(enter_call), Int, Int})
35+
@assert precompile(Tuple{typeof(enter_call_expr), Expr})
36+
@assert precompile(Tuple{typeof(copy_codeinfo), Core.CodeInfo})
37+
@assert precompile(Tuple{typeof(optimize!), Core.CodeInfo, Module})
38+
@assert precompile(Tuple{typeof(set_structtype_const), Module, Symbol})
39+
@assert precompile(Tuple{typeof(namedtuple), Vector{Any}})
40+
@assert precompile(Tuple{typeof(resolvefc), Frame, Any})
41+
@assert precompile(Tuple{typeof(check_isdefined), Frame, Any})
42+
@assert precompile(Tuple{typeof(find_used), Core.CodeInfo})
43+
@assert precompile(Tuple{typeof(do_assignment!), Frame, Any, Any})
44+
@assert precompile(Tuple{typeof(pc_expr), Frame})
4445
end

0 commit comments

Comments
 (0)