Skip to content

Commit

Permalink
Serialize new method roots
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Jan 30, 2022
1 parent 4abf26e commit aa8e544
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 24 deletions.
10 changes: 10 additions & 0 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

# Tracking of newly-inferred MethodInstances during precompilation
const track_newly_inferred = RefValue{Bool}(false)
const newly_inferred = MethodInstance[]

# build (and start inferring) the inference frame for the top-level MethodInstance
function typeinf(interp::AbstractInterpreter, result::InferenceResult, cache::Symbol)
frame = InferenceState(result, cache, interp)
Expand Down Expand Up @@ -386,6 +390,12 @@ function cache_result!(interp::AbstractInterpreter, result::InferenceResult)
inferred_result = transform_result_for_cache(interp, linfo, valid_worlds, result.src)
relocatability = isa(inferred_result, Vector{UInt8}) ? inferred_result[end] : UInt8(0)
code_cache(interp)[linfo] = CodeInstance(result, inferred_result, valid_worlds, relocatability)
if track_newly_inferred[]
m = linfo.def
if isa(m, Method)
m.module != Core && push!(newly_inferred, linfo)
end
end
end
unlock_mi_inference(interp, linfo)
nothing
Expand Down
3 changes: 3 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1410,13 +1410,16 @@ function include_package_for_output(pkg::PkgId, input::String, depot_path::Vecto
task_local_storage()[:SOURCE_PATH] = source
end

Core.Compiler.track_newly_inferred.x = true
try
Base.include(Base.__toplevel__, input)
catch ex
precompilableerror(ex) || rethrow()
@debug "Aborting `create_expr_cache'" exception=(ErrorException("Declaration of __precompile__(false) not allowed"), catch_backtrace())
exit(125) # we define status = 125 means PrecompileableError
end
Core.Compiler.track_newly_inferred.x = false
ccall(:jl_set_newly_inferred, Cvoid, (Any,), Core.Compiler.newly_inferred)
end

const PRECOMPILE_TRACE_COMPILE = Ref{String}()
Expand Down
Loading

0 comments on commit aa8e544

Please sign in to comment.