Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quality improvement for recompile_invalidations #36

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/invalidations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@
by users in creating "Startup" packages to ensure that the code compiled by package authors is not invalidated.
"""
macro recompile_invalidations(expr)
list = gensym(:list)
Expr(:toplevel,
:($list = ccall(:jl_debug_method_invalidation, Any, (Cint,), 1)),
Expr(:tryfinally,
esc(expr),
:(ccall(:jl_debug_method_invalidation, Any, (Cint,), 0))
),
:(if ccall(:jl_generating_output, Cint, ()) == 1
foreach($PrecompileTools.precompile_mi, $PrecompileTools.invalidation_leaves($list))
end)
)
# use QuoteNode instead of esc(Expr(:quote)) so that $ is not permitted as usual (instead of having this macro work like `@eval`)
return :(recompile_invalidations($__module__, $(QuoteNode(expr))))
end

function recompile_invalidations(__module__::Module, @nospecialize expr)
list = ccall(:jl_debug_method_invalidation, Any, (Cint,), 1)
try
Core.eval(__module__, expr)
finally
ccall(:jl_debug_method_invalidation, Any, (Cint,), 0)
end
if ccall(:jl_generating_output, Cint, ()) == 1
foreach(precompile_mi, invalidation_leaves(list))
end
nothing

Check warning on line 25 in src/invalidations.jl

View check run for this annotation

Codecov / codecov/patch

src/invalidations.jl#L25

Added line #L25 was not covered by tests
end

function invalidation_leaves(invlist)
Expand Down
Loading