Skip to content

Commit

Permalink
add a very basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored and jpsamaroo committed Feb 3, 2022
1 parent ab670d1 commit 501960e
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions test/EscapeAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2294,24 +2294,25 @@ end # @static if isdefined(Core, :ImmutableArray)
end
end

# # TODO implement a finalizer elision pass
# mutable struct WithFinalizer
# v
# function WithFinalizer(v)
# x = new(v)
# f(t) = @async println("Finalizing $t.")
# return finalizer(x, x)
# end
# end
# make_m(v = 10) = MyMutable(v)
# function simple(cond)
# m = make_m()
# if cond
# # println(m.v)
# return nothing # <= insert `finalize` call here
# end
# return m
# end
mutable struct WithFinalizer
v
function WithFinalizer(v)
x = new(v)
f(t) = @async println("Finalizing $t.")
return finalizer(f, x)
end
end
function simple(cond)
obj = WithFinalizer(42)
if cond
# println(m.v)
return nothing # <= insert `finalize` call here
end
return obj
end
let result = code_escapes(simple, (Bool,))
@test has_finalizer_escape(result.state[SSAValue(2)]) # m
end

# IPO cache
# =========
Expand Down

0 comments on commit 501960e

Please sign in to comment.