Skip to content

Commit 8be0eee

Browse files
authored
Merge branch 'master' into allow-cert-file
2 parents 4f2f105 + c4825b0 commit 8be0eee

File tree

111 files changed

+1577
-1528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1577
-1528
lines changed

Compiler/src/bootstrap.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ function activate_codegen!()
1515
end)
1616
end
1717

18+
global bootstrapping_compiler::Bool = false
1819
function bootstrap!()
20+
global bootstrapping_compiler = true
1921
let time() = ccall(:jl_clock_now, Float64, ())
2022
println("Compiling the compiler. This may take several minutes ...")
21-
interp = NativeInterpreter()
2223

2324
ssa_inlining_pass!_tt = Tuple{typeof(ssa_inlining_pass!), IRCode, InliningState{NativeInterpreter}, Bool}
2425
optimize_tt = Tuple{typeof(optimize), NativeInterpreter, OptimizationState{NativeInterpreter}, InferenceResult}
@@ -45,13 +46,15 @@ function bootstrap!()
4546
end
4647
end
4748
starttime = time()
49+
methods = Any[]
50+
world = get_world_counter()
4851
for f in fs
4952
if isa(f, DataType) && f.name === typename(Tuple)
5053
tt = f
5154
else
5255
tt = Tuple{typeof(f), Vararg{Any}}
5356
end
54-
matches = _methods_by_ftype(tt, 10, get_world_counter())::Vector
57+
matches = _methods_by_ftype(tt, 10, world)::Vector
5558
if isempty(matches)
5659
println(stderr, "WARNING: no matching method found for `", tt, "`")
5760
else
@@ -62,14 +65,25 @@ function bootstrap!()
6265
for i = 1:length(params)
6366
params[i] = unwraptv(params[i])
6467
end
65-
typeinf_type(interp, m.method, Tuple{params...}, m.sparams)
68+
mi = specialize_method(m.method, Tuple{params...}, m.sparams)
69+
#isa_compileable_sig(mi) || println(stderr, "WARNING: inferring `", mi, "` which isn't expected to be called.")
70+
push!(methods, mi)
6671
end
6772
end
6873
end
74+
codeinfos = typeinf_ext_toplevel(methods, [world], false)
75+
for i = 1:2:length(codeinfos)
76+
ci = codeinfos[i]::CodeInstance
77+
src = codeinfos[i + 1]::CodeInfo
78+
isa_compileable_sig(ci.def) || continue # println(stderr, "WARNING: compiling `", ci.def, "` which isn't expected to be called.")
79+
ccall(:jl_add_codeinst_to_jit, Cvoid, (Any, Any), ci, src)
80+
end
6981
endtime = time()
7082
println("Base.Compiler ──── ", sub_float(endtime,starttime), " seconds")
7183
end
7284
activate_codegen!()
85+
global bootstrapping_compiler = false
86+
nothing
7387
end
7488

7589
function activate!(; reflection=true, codegen=false)

Compiler/src/tfuncs.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ macro nospecs(ex)
4242
push!(names, arg)
4343
end
4444
@assert isexpr(body, :block)
45-
if !isempty(names)
46-
lin = first(body.args)::LineNumberNode
47-
nospec = Expr(:macrocall, Symbol("@nospecialize"), lin, names...)
48-
insert!(body.args, 2, nospec)
49-
end
45+
isempty(names) && throw(ArgumentError("no arguments for @nospec"))
46+
lin = first(body.args)::LineNumberNode
47+
nospec = Expr(:macrocall, GlobalRef(@__MODULE__, :var"@nospecialize"), lin, names...)
48+
insert!(body.args, 2, nospec)
5049
return esc(ex)
5150
end
5251

@@ -2115,7 +2114,7 @@ add_tfunc(memoryrefoffset, 1, 1, memoryrefoffset_tfunc, 5)
21152114
return true
21162115
end
21172116

2118-
@nospecs function memoryref_elemtype(@nospecialize mem)
2117+
@nospecs function memoryref_elemtype(mem)
21192118
m = widenconst(mem)
21202119
if !has_free_typevars(m) && m <: GenericMemoryRef
21212120
m0 = m
@@ -2131,7 +2130,7 @@ end
21312130
return Any
21322131
end
21332132

2134-
@nospecs function _memoryref_elemtype(@nospecialize mem)
2133+
@nospecs function _memoryref_elemtype(mem)
21352134
m = widenconst(mem)
21362135
if !has_free_typevars(m) && m <: GenericMemoryRef
21372136
m0 = m
@@ -2166,7 +2165,7 @@ end
21662165
end
21672166

21682167
# whether getindex for the elements can potentially throw UndefRef
2169-
function array_type_undefable(@nospecialize(arytype))
2168+
@nospecs function array_type_undefable(arytype)
21702169
arytype = unwrap_unionall(arytype)
21712170
if isa(arytype, Union)
21722171
return array_type_undefable(arytype.a) || array_type_undefable(arytype.b)
@@ -2247,7 +2246,7 @@ end
22472246
return boundscheck Bool && memtype GenericMemoryRef && order Symbol
22482247
end
22492248

2250-
@nospecs function memorynew_nothrow(argtypes::Vector{Any})
2249+
function memorynew_nothrow(argtypes::Vector{Any})
22512250
if !(argtypes[1] isa Const && argtypes[2] isa Const)
22522251
return false
22532252
end
@@ -2263,6 +2262,7 @@ end
22632262
overflows = checked_smul_int(len, elsz)[2]
22642263
return !overflows
22652264
end
2265+
22662266
# Query whether the given builtin is guaranteed not to throw given the `argtypes`.
22672267
# `argtypes` can be assumed not to contain varargs.
22682268
function _builtin_nothrow(𝕃::AbstractLattice, @nospecialize(f::Builtin), argtypes::Vector{Any},

0 commit comments

Comments
 (0)