diff --git a/src/construct.jl b/src/construct.jl index c524d2bd..4b623650 100644 --- a/src/construct.jl +++ b/src/construct.jl @@ -28,8 +28,10 @@ const compiled_modules = Set{Module}() const junk = FrameData[] # to allow re-use of allocated memory (this is otherwise a bottleneck) const debug_recycle = Base.RefValue(false) +const disable_recycle = Base.RefValue(false) @noinline _check_frame_not_in_junk(frame) = @assert frame.framedata ∉ junk @inline function recycle(frame) + disable_recycle[] && return debug_recycle[] && _check_frame_not_in_junk(frame) push!(junk, frame.framedata) end diff --git a/test/interpret.jl b/test/interpret.jl index 05a6f026..8f75d156 100644 --- a/test/interpret.jl +++ b/test/interpret.jl @@ -504,3 +504,13 @@ end # Test exception type for undefined variables f() = s = s + 1 @test_throws UndefVarError @interpret f() + +# Interpret squared +f() = @interpret 1+1 +JuliaInterpreter.disable_recycle[] = true +empty!(JuliaInterpreter.junk) +try + @test (@interpret f()) == 2 +finally + JuliaInterpreter.disable_recycle[] = false +end