Skip to content

Commit 1117df6

Browse files
Remove try-finally scope from @time_imports @trace_compile @trace_dispatch (#58011)
Matches `@time` `@profile` etc.
1 parent a0740d0 commit 1117df6

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

base/timing.jl

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -643,33 +643,36 @@ end
643643
# here so it's possible to time/trace all imports, including InteractiveUtils and its deps
644644
macro time_imports(ex)
645645
quote
646-
try
647-
Base.Threads.atomic_add!(Base.TIMING_IMPORTS, 1)
648-
$(esc(ex))
649-
finally
646+
Base.Threads.atomic_add!(Base.TIMING_IMPORTS, 1)
647+
@__tryfinally(
648+
# try
649+
$(esc(ex)),
650+
# finally
650651
Base.Threads.atomic_sub!(Base.TIMING_IMPORTS, 1)
651-
end
652+
)
652653
end
653654
end
654655

655656
macro trace_compile(ex)
656657
quote
657-
try
658-
ccall(:jl_force_trace_compile_timing_enable, Cvoid, ())
659-
$(esc(ex))
660-
finally
658+
ccall(:jl_force_trace_compile_timing_enable, Cvoid, ())
659+
@__tryfinally(
660+
# try
661+
$(esc(ex)),
662+
# finally
661663
ccall(:jl_force_trace_compile_timing_disable, Cvoid, ())
662-
end
664+
)
663665
end
664666
end
665667

666668
macro trace_dispatch(ex)
667669
quote
668-
try
669-
ccall(:jl_force_trace_dispatch_enable, Cvoid, ())
670-
$(esc(ex))
671-
finally
670+
ccall(:jl_force_trace_dispatch_enable, Cvoid, ())
671+
@__tryfinally(
672+
# try
673+
$(esc(ex)),
674+
# finally
672675
ccall(:jl_force_trace_dispatch_disable, Cvoid, ())
673-
end
676+
)
674677
end
675678
end

0 commit comments

Comments
 (0)