Skip to content

Commit 79b2dd8

Browse files
committed
Add tests for newmeth/specialization tracing
1 parent 2840b13 commit 79b2dd8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/reflection.jl

+26
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,29 @@ test_typed_ast_printing(g15714, Tuple{Vector{Float32}},
374374
[:array_var15714, :index_var15714])
375375
@test used_dup_var_tested15714
376376
@test used_unique_var_tested15714
377+
378+
# Linfo Tracing test
379+
tracefoo(x, y) = x+y
380+
didtrace = false
381+
tracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), LambdaInfo); global didtrace = true; nothing)
382+
ccall(:jl_register_tracer, Void, (Ptr{Void},), cfunction(tracer, Void, (Ptr{Void},)))
383+
mlinfo = first(methods(tracefoo)).func
384+
ccall(:jl_trace_linfo, Void, (Any,), mlinfo)
385+
@test tracefoo(1, 2) == 3
386+
ccall(:jl_untrace_linfo, Void, (Any,), mlinfo)
387+
@test didtrace
388+
didtrace = false
389+
@test tracefoo(1.0, 2.0) == 3.0
390+
@test !didtrace
391+
ccall(:jl_register_tracer, Void, (Ptr{Void},), C_NULL)
392+
393+
# Method Tracing test
394+
methtracer(x::Ptr{Void}) = (@test isa(unsafe_pointer_to_objref(x), Method); global didtrace = true; nothing)
395+
ccall(:jl_register_newmeth_tracer, Void, (Ptr{Void},), cfunction(methtracer, Void, (Ptr{Void},)))
396+
tracefoo2(x, y) = x*y
397+
@test didtrace
398+
didtrace = false
399+
tracefoo(x::Int64, y::Int64) = x*y
400+
@test didtrace
401+
didtrace = false
402+
ccall(:jl_register_newmeth_tracer, Void, (Ptr{Void},), C_NULL)

0 commit comments

Comments
 (0)