Skip to content

Commit 469db0f

Browse files
committed
improve macro
1 parent dbccb83 commit 469db0f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

SnoopCompileCore/src/snoop_invalidations.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@ Method insertion results in the sequence
3131
The authoritative reference is Julia's own `src/gf.c` file.
3232
"""
3333
macro snoop_invalidations(expr)
34-
quote
35-
logedges = Base.StaticData.debug_method_invalidation(true)
36-
logmeths = ccall(:jl_debug_method_invalidation, Any, (Cint,), 1)
37-
try
38-
$(esc(expr))
39-
finally
34+
# It's a little unclear why this is better than a quoted try/finally, but it seems to be
35+
# Guessing it's a lack of a block around `expr`
36+
exoff = Expr(:tryfinally,
37+
esc(expr),
38+
quote
4039
Base.StaticData.debug_method_invalidation(false)
4140
ccall(:jl_debug_method_invalidation, Any, (Cint,), 0)
4241
end
43-
InvalidationLists(logedges, logmeths)
42+
)
43+
return quote
44+
local logedges = Base.StaticData.debug_method_invalidation(true)
45+
local logmeths = ccall(:jl_debug_method_invalidation, Any, (Cint,), 1)
46+
$exoff
47+
$InvalidationLists(logedges, logmeths)
4448
end
4549
end

0 commit comments

Comments
 (0)