Skip to content

allow path=nothing in make_tracer #1309

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
28 changes: 19 additions & 9 deletions src/Tracing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ function make_tracer(
return prev
end
append_path(@nospecialize(path), i) = (path..., i)
append_path(::Nothing, i) = nothing

Base.@nospecializeinfer function make_tracer_via_immutable_constructor(
seen,
Expand Down Expand Up @@ -1283,21 +1284,24 @@ Base.@nospecializeinfer function make_tracer(
return nothing
end
if mode == TracedTrack
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if !haskey(seen, prev)
return seen[prev] = prev
end
return prev
end
if mode == NoStopTracedTrack
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if !haskey(seen, prev)
seen[prev] = prev # don't return!
end
return prev
end
if mode == TracedSetPath
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if haskey(seen, prev)
return seen[prev]
end
Expand Down Expand Up @@ -1361,21 +1365,24 @@ Base.@nospecializeinfer function make_tracer(
return nothing
end
if mode == TracedTrack
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if !haskey(seen, prev)
return seen[prev] = prev
end
return prev
end
if mode == NoStopTracedTrack
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if !haskey(seen, prev)
seen[prev] = prev # don't return!
end
return prev
end
if mode == TracedSetPath
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if haskey(seen, prev)
return seen[prev]
end
Expand Down Expand Up @@ -1430,21 +1437,24 @@ Base.@nospecializeinfer function make_tracer(
throw("Cannot have MissingTracedValue as function call argument.")
end
if mode == TracedTrack
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if !haskey(seen, prev)
return seen[prev] = prev
end
return prev
end
if mode == NoStopTracedTrack
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
if !haskey(seen, prev)
seen[prev] = prev # don't return!
end
return prev
end
if mode == TracedSetPath
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
!isnothing(path) &&
TracedUtils.set_paths!(prev, (TracedUtils.get_paths(prev)..., path))
haskey(seen, prev) && return seen[prev]
res = MissingTracedValue((path,))
seen[res] = res
Expand Down
Loading