Skip to content

Commit 1efae18

Browse files
authored
remove AbstractFrameInstance (#608)
Slightly improving type stability
1 parent 0138e60 commit 1efae18

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/types.jl

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,17 @@ function breakpointchar(bps::BreakpointState)
5656
return bps.condition === falsecondition ? ' ' : 'd' # no breakpoint : disabled
5757
end
5858

59-
abstract type AbstractFrameInstance end
60-
mutable struct DispatchableMethod
61-
next::Union{Nothing,DispatchableMethod} # linked-list representation
62-
frameinstance::Union{Compiled, AbstractFrameInstance} # really a Union{Compiled, FrameInstance} but we have a cyclic dependency
59+
struct _FrameInstance{FrameCode}
60+
framecode::FrameCode
61+
sparam_vals::SimpleVector
62+
enter_generated::Bool
63+
end
64+
Base.show(io::IO, instance::_FrameInstance) =
65+
print(io, "FrameInstance(", scopeof(instance.framecode), ", ", instance.sparam_vals, ", ", instance.enter_generated, ')')
66+
67+
mutable struct _DispatchableMethod{FrameCode}
68+
next::Union{Nothing,_DispatchableMethod{FrameCode}} # linked-list representation
69+
frameinstance::Union{Compiled,_FrameInstance{FrameCode}} # really a Union{Compiled, FrameInstance} but we have a cyclic dependency
6370
sig::Type # for speed of matching, this is a *concrete* signature. `sig <: frameinstance.framecode.scope.sig`
6471
end
6572

@@ -91,7 +98,7 @@ Important fields:
9198
struct FrameCode
9299
scope::Union{Method,Module}
93100
src::CodeInfo
94-
methodtables::Vector{Union{Compiled,DispatchableMethod}} # line-by-line method tables for generic-function :call Exprs
101+
methodtables::Vector{Union{Compiled,_DispatchableMethod{FrameCode}}} # line-by-line method tables for generic-function :call Exprs
95102
breakpoints::Vector{BreakpointState}
96103
slotnamelists::Dict{Symbol,Vector{Int}}
97104
used::BitSet
@@ -100,6 +107,16 @@ struct FrameCode
100107
unique_files::Set{Symbol}
101108
end
102109

110+
"""
111+
`FrameInstance` represents a method specialized for particular argument types.
112+
113+
Fields:
114+
- `framecode`: the [`FrameCode`](@ref) for the method.
115+
- `sparam_vals`: the static parameter values for the method.
116+
"""
117+
const FrameInstance = _FrameInstance{FrameCode}
118+
const DispatchableMethod = _DispatchableMethod{FrameCode}
119+
103120
const BREAKPOINT_EXPR = :($(QuoteNode(getproperty))($JuliaInterpreter, :__BREAKPOINT_MARKER__))
104121
function is_breakpoint_expr(ex::Expr)
105122
# Sadly, comparing QuoteNodes calls isequal(::Any, ::Any), and === seems not to work.
@@ -166,22 +183,6 @@ nstatements(framecode::FrameCode) = length(framecode.src.code)
166183

167184
Base.show(io::IO, framecode::FrameCode) = print_framecode(io, framecode)
168185

169-
"""
170-
`FrameInstance` represents a method specialized for particular argument types.
171-
172-
Fields:
173-
- `framecode`: the [`FrameCode`](@ref) for the method.
174-
- `sparam_vals`: the static parameter values for the method.
175-
"""
176-
struct FrameInstance <: AbstractFrameInstance
177-
framecode::FrameCode
178-
sparam_vals::SimpleVector
179-
enter_generated::Bool
180-
end
181-
182-
Base.show(io::IO, instance::FrameInstance) =
183-
print(io, "FrameInstance(", scopeof(instance.framecode), ", ", instance.sparam_vals, ", ", instance.enter_generated, ')')
184-
185186
"""
186187
`FrameData` holds the arguments, local variables, and intermediate execution state
187188
in a particular call frame.

0 commit comments

Comments
 (0)