Skip to content

Commit ca2d6aa

Browse files
authored
speed up bootstrapping by compiling few optimizer subroutines earlier (JuliaLang#56501)
Speeds up the bootstrapping process by about 30 seconds.
1 parent 62f8cff commit ca2d6aa

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Compiler/src/bootstrap.jl

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ function bootstrap!()
1212
println("Compiling the compiler. This may take several minutes ...")
1313
interp = NativeInterpreter()
1414

15-
# analyze_escapes_tt = Tuple{typeof(analyze_escapes), IRCode, Int, TODO}
15+
ssa_inlining_pass!_tt = Tuple{typeof(ssa_inlining_pass!), IRCode, InliningState{NativeInterpreter}, Bool}
1616
optimize_tt = Tuple{typeof(optimize), NativeInterpreter, OptimizationState{NativeInterpreter}, InferenceResult}
17+
typeinf_ext_tt = Tuple{typeof(typeinf_ext), NativeInterpreter, MethodInstance, UInt8}
18+
typeinf_tt = Tuple{typeof(typeinf), NativeInterpreter, InferenceState}
19+
typeinf_edge_tt = Tuple{typeof(typeinf_edge), NativeInterpreter, Method, Any, SimpleVector, InferenceState, Bool, Bool}
1720
fs = Any[
1821
# we first create caches for the optimizer, because they contain many loop constructions
1922
# and they're better to not run in interpreter even during bootstrapping
20-
#=analyze_escapes_tt,=# optimize_tt,
23+
compact!, ssa_inlining_pass!_tt, optimize_tt,
2124
# then we create caches for inference entries
22-
typeinf_ext, typeinf, typeinf_edge,
25+
typeinf_ext_tt, typeinf_tt, typeinf_edge_tt,
2326
]
2427
# tfuncs can't be inferred from the inference entries above, so here we infer them manually
2528
for x in T_FFUNC_VAL
@@ -40,14 +43,19 @@ function bootstrap!()
4043
else
4144
tt = Tuple{typeof(f), Vararg{Any}}
4245
end
43-
for m in _methods_by_ftype(tt, 10, get_world_counter())::Vector
44-
# remove any TypeVars from the intersection
45-
m = m::MethodMatch
46-
typ = Any[m.spec_types.parameters...]
47-
for i = 1:length(typ)
48-
typ[i] = unwraptv(typ[i])
46+
matches = _methods_by_ftype(tt, 10, get_world_counter())::Vector
47+
if isempty(matches)
48+
println(stderr, "WARNING: no matching method found for `", tt, "`")
49+
else
50+
for m in matches
51+
# remove any TypeVars from the intersection
52+
m = m::MethodMatch
53+
params = Any[m.spec_types.parameters...]
54+
for i = 1:length(params)
55+
params[i] = unwraptv(params[i])
56+
end
57+
typeinf_type(interp, m.method, Tuple{params...}, m.sparams)
4958
end
50-
typeinf_type(interp, m.method, Tuple{typ...}, m.sparams)
5159
end
5260
end
5361
endtime = time()

0 commit comments

Comments
 (0)