diff --git a/base/compiler/ssair/ir.jl b/base/compiler/ssair/ir.jl index c23f89e01f664..222ec91f7c01a 100644 --- a/base/compiler/ssair/ir.jl +++ b/base/compiler/ssair/ir.jl @@ -177,40 +177,41 @@ end # mutable version of the compressed DebugInfo mutable struct DebugInfoStream def::Union{MethodInstance,Symbol,Nothing} - linetable::Union{Nothing,Core.DebugInfo} - edges::Vector{Any} # Vector{Core.DebugInfo} + linetable::Union{Nothing,DebugInfo} + edges::Vector{DebugInfo} firstline::Int32 # the starting line for this block (specified by having an index of 0) codelocs::Vector{Int32} # for each statement: # index into linetable (if defined), else a line number (in the file represented by def) # then index into edges # then index into edges[linetable] function DebugInfoStream(codelocs::Vector{Int32}) - return new(nothing, nothing, [], 0, codelocs) + return new(nothing, nothing, DebugInfo[], 0, codelocs) end - #DebugInfoStream(def::Union{MethodInstance,Nothing}, di::DebugInfo, nstmts::Int) = - # if debuginfo_file1(di.def) === debuginfo_file1(di.def) - # new(def, di.linetable, Core.svec(di.edges...), getdebugidx(di, 0), - # ccall(:jl_uncompress_codelocs, Any, (Any, Int), di.codelocs, nstmts)::Vector{Int32}) - # else + # DebugInfoStream(def::Union{MethodInstance,Nothing}, di::DebugInfo, nstmts::Int) = + # if debuginfo_file1(di.def) === debuginfo_file1(di.def) + # new(def, di.linetable, Core.svec(di.edges...), getdebugidx(di, 0), + # ccall(:jl_uncompress_codelocs, Any, (Any, Int), di.codelocs, nstmts)::Vector{Int32}) + # else function DebugInfoStream(def::Union{MethodInstance,Nothing}, di::DebugInfo, nstmts::Int) codelocs = zeros(Int32, nstmts * 3) for i = 1:nstmts codelocs[3i - 2] = i end - return new(def, di, Vector{Any}(), 0, codelocs) + return new(def, di, DebugInfo[], 0, codelocs) end global copy(di::DebugInfoStream) = new(di.def, di.linetable, di.edges, di.firstline, di.codelocs) end Core.DebugInfo(di::DebugInfoStream, nstmts::Int) = - Core.DebugInfo(something(di.def), di.linetable, Core.svec(di.edges...), + DebugInfo(something(di.def), di.linetable, Core.svec(di.edges...), ccall(:jl_compress_codelocs, Any, (Int32, Any, Int), di.firstline, di.codelocs, nstmts)::String) -getdebugidx(debuginfo::Core.DebugInfo, pc::Int) = ccall(:jl_uncompress1_codeloc, NTuple{3,Int32}, (Any, Int), debuginfo.codelocs, pc) +getdebugidx(debuginfo::DebugInfo, pc::Int) = + ccall(:jl_uncompress1_codeloc, NTuple{3,Int32}, (Any, Int), debuginfo.codelocs, pc) function getdebugidx(debuginfo::DebugInfoStream, pc::Int) if 3 <= 3pc <= length(debuginfo.codelocs) - return (debuginfo.codelocs[3pc - 2], debuginfo.codelocs[3pc - 1], debuginfo.codelocs[3pc - 0]) + return (debuginfo.codelocs[3pc-2], debuginfo.codelocs[3pc-1], debuginfo.codelocs[3pc-0]) elseif pc == 0 return (Int32(debuginfo.firstline), Int32(0), Int32(0)) else diff --git a/base/compiler/ssair/show.jl b/base/compiler/ssair/show.jl index 2c0385a808801..cfcd2ce8f3d2b 100644 --- a/base/compiler/ssair/show.jl +++ b/base/compiler/ssair/show.jl @@ -327,7 +327,7 @@ Base.show(io::IO, code::Union{IRCode, IncrementalCompact}) = show_ir(io, code) lineinfo_disabled(io::IO, linestart::String, idx::Int) = "" # utility function to extract the file name from a DebugInfo object -function debuginfo_file1(debuginfo::Union{Core.DebugInfo,DebugInfoStream}) +function debuginfo_file1(debuginfo::Union{DebugInfo,DebugInfoStream}) def = debuginfo.def if def isa MethodInstance def = def.def @@ -342,7 +342,7 @@ function debuginfo_file1(debuginfo::Union{Core.DebugInfo,DebugInfoStream}) end # utility function to extract the first line number and file of a block of code -function debuginfo_firstline(debuginfo::Union{Core.DebugInfo,DebugInfoStream}) +function debuginfo_firstline(debuginfo::Union{DebugInfo,DebugInfoStream}) linetable = debuginfo.linetable while linetable != nothing debuginfo = linetable @@ -375,7 +375,7 @@ function append_scopes!(scopes::Vector{LineInfoNode}, pc::Int, debuginfo, @nospe line < 0 && (doupdate = false; line = 0) # broken debug info push!(scopes, LineInfoNode(def, debuginfo_file1(debuginfo), Int32(line))) else - doupdate = append_scopes!(scopes, line, debuginfo.linetable::Core.DebugInfo, def) && doupdate + doupdate = append_scopes!(scopes, line, debuginfo.linetable::DebugInfo, def) && doupdate end inl_to == 0 && return doupdate def = :var"macro expansion" diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index b77d2e83d5780..02ec583316de0 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -328,7 +328,7 @@ function CodeInstance(interp::AbstractInterpreter, result::InferenceResult; end # n.b. relocatability = (isa(inferred_result, String) && inferred_result[end]) || inferred_result === nothing if !@isdefined edges - edges = Core.DebugInfo(result.linfo) + edges = DebugInfo(result.linfo) end return CodeInstance(result.linfo, owner, widenconst(result_type), widenconst(result.exc_result), rettype_const, inferred_result, @@ -923,7 +923,7 @@ function codeinfo_for_const(interp::AbstractInterpreter, mi::MethodInstance, @no tree.slotnames = ccall(:jl_uncompress_argnames, Vector{Symbol}, (Any,), method.slot_syms) tree.slotflags = fill(0x00, nargs) tree.ssavaluetypes = 1 - tree.debuginfo = Core.DebugInfo(mi) + tree.debuginfo = DebugInfo(mi) tree.ssaflags = UInt32[0] set_inlineable!(tree, true) tree.parent = mi