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

WIP add a test for @interpret^2 #252

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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