Skip to content

Commit

Permalink
Add an interface extension point to prepare before anything happens. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Apr 18, 2024
1 parent 0c8d55e commit 0c9292f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ function codegen(output::Symbol, @nospecialize(job::CompilerJob);
validate && check_invocation(job)
end

prepare_job!(job)


## LLVM IR

Expand Down
4 changes: 4 additions & 0 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ end

## extension points at important stages of compilation

# prepare the environment for compilation of a job. this can involve, e.g.,
# priming the cache with entries that cannot be easily inferred.
prepare_job!(@nospecialize(job::CompilerJob)) = return

# early extension point used to link-in external bitcode files.
# this is typically used by downstream packages to link vendor libraries.
link_libraries!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
Expand Down
1 change: 1 addition & 0 deletions src/jlgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ end # HAS_INTEGRATED_CACHE
function ci_cache_populate(interp, cache, mi, min_world, max_world)
if VERSION >= v"1.12.0-DEV.15"
inferred_ci = CC.typeinf_ext_toplevel(interp, mi, CC.SOURCE_MODE_FORCE_SOURCE) # or SOURCE_MODE_FORCE_SOURCE_UNCACHED?
@assert inferred_ci !== nothing "Inference of $mi failed"

# inference should have populated our cache
wvc = WorldView(cache, min_world, max_world)
Expand Down

0 comments on commit 0c9292f

Please sign in to comment.