Skip to content

Commit

Permalink
Add tests for newmeth/specialization tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Apr 15, 2016
1 parent 2840b13 commit 79b2dd8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,29 @@ test_typed_ast_printing(g15714, Tuple{Vector{Float32}},
[:array_var15714, :index_var15714])
@test used_dup_var_tested15714
@test used_unique_var_tested15714

# Linfo Tracing test
tracefoo(x, y) = x+y
didtrace = false
tracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), LambdaInfo); global didtrace = true; nothing)
ccall(:jl_register_tracer, Void, (Ptr{Void},), cfunction(tracer, Void, (Ptr{Void},)))
mlinfo = first(methods(tracefoo)).func
ccall(:jl_trace_linfo, Void, (Any,), mlinfo)
@test tracefoo(1, 2) == 3
ccall(:jl_untrace_linfo, Void, (Any,), mlinfo)
@test didtrace
didtrace = false
@test tracefoo(1.0, 2.0) == 3.0
@test !didtrace
ccall(:jl_register_tracer, Void, (Ptr{Void},), C_NULL)

# Method Tracing test
methtracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), Method); global didtrace = true; nothing)
ccall(:jl_register_newmeth_tracer, Void, (Ptr{Void},), cfunction(methtracer, Void, (Ptr{Void},)))
tracefoo2(x, y) = x*y
@test didtrace
didtrace = false
tracefoo(x::Int64, y::Int64) = x*y
@test didtrace
didtrace = false
ccall(:jl_register_newmeth_tracer, Void, (Ptr{Void},), C_NULL)

0 comments on commit 79b2dd8

Please sign in to comment.