Skip to content

Commit c737bac

Browse files
authored
Improve inference in several places (#438)
This disabling of the debugging statements may be a bit unfortunate, but we haven't needed them lately and they are easy to uncomment. xref timholy/CodeTracking.jl#73
1 parent 8bd596b commit c737bac

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/breakpoints.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ end
156156

157157
function framecode_matches_breakpoint(framecode::FrameCode, bp::BreakpointFileLocation)
158158
if framecode.scope isa Method
159-
meth = framecode.scope
159+
meth = framecode.scope::Method
160160
methpath = CodeTracking.maybe_fix_path(String(meth.file))
161161
ispath(methpath) && (methpath = realpath(methpath))
162162
if bp.abspath == methpath || endswith(methpath, bp.path)

src/construct.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function prepare_framecode(method::Method, @nospecialize(argtypes); enter_genera
158158
argtypes, sig)::SimpleVector
159159
enter_generated &= is_generated(method)
160160
if is_generated(method) && !enter_generated
161-
framecode = get(genframedict, (method, argtypes), nothing)
161+
framecode = get(genframedict, (method, argtypes::Type), nothing)
162162
else
163163
framecode = get(framedict, method, nothing)
164164
end
@@ -505,7 +505,7 @@ function queuenext!(iter::ExprSplitter)
505505
end
506506
end
507507
elseif head === :macrocall
508-
iter.lnn = ex.args[2]
508+
iter.lnn = ex.args[2]::LineNumberNode
509509
elseif head === :block || head === :toplevel
510510
# Container expression
511511
idx = iter.index[end]

src/interpret.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ function lookup_or_eval(@nospecialize(recurse), frame, @nospecialize(node))
100100
error("unknown call f ", f)
101101
end
102102
else
103-
dump(ex)
104103
error("unknown expr ", ex)
105104
end
106105
elseif isa(node, Int) || isa(node, Number) # Number is slow, requires subtyping
@@ -425,10 +424,10 @@ const _location = Dict{Tuple{Method,Int},Int}()
425424

426425
function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplevel::Bool)
427426
pc, code, data = frame.pc, frame.framecode, frame.framedata
428-
if !is_leaf(frame)
429-
show_stackloc(frame)
430-
@show node
431-
end
427+
# if !is_leaf(frame)
428+
# show_stackloc(frame)
429+
# @show node
430+
# end
432431
@assert is_leaf(frame)
433432
local rhs
434433
# For debugging:
@@ -557,9 +556,9 @@ function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplev
557556
end
558557
@isdefined(rhs) && isa(rhs, BreakpointRef) && return rhs
559558
if isassign(frame, pc)
560-
if !@isdefined(rhs)
561-
@show frame node
562-
end
559+
# if !@isdefined(rhs)
560+
# @show frame node
561+
# end
563562
lhs = SSAValue(pc)
564563
do_assignment!(frame, lhs, rhs)
565564
end

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function is_bodyfunc(@nospecialize(arg))
208208
arg = arg.value
209209
end
210210
if isa(arg, Function)
211-
fname = String(typeof(arg).name.name)
211+
fname = String((typeof(arg).name::Core.TypeName).name)
212212
return startswith(fname, "##") && match(r"#\d+$", fname) !== nothing
213213
end
214214
return false
@@ -319,8 +319,8 @@ function CodeTracking.whereis(framecode::FrameCode, pc::Int)
319319
codeloc = codelocation(framecode.src, pc)
320320
codeloc == 0 && return nothing
321321
lineinfo = linetable(framecode, codeloc)
322-
return isa(framecode.scope, Method) ?
323-
whereis(lineinfo, framecode.scope) : (getfile(lineinfo), getline(lineinfo))
322+
m = framecode.scope
323+
return isa(m, Method) ? whereis(lineinfo, m) : (getfile(lineinfo), getline(lineinfo))
324324
end
325325
CodeTracking.whereis(frame::Frame, pc::Int=frame.pc) = whereis(frame.framecode, pc)
326326

0 commit comments

Comments
 (0)