@@ -11,17 +11,17 @@ function get_call_framecode(fargs::Vector{Any}, parentframe::FrameCode, idx::Int
11
11
nargs = length (fargs) # includes f as the first "argument"
12
12
# Determine whether we can look up the appropriate framecode in the local method table
13
13
if isassigned (parentframe. methodtables, idx) # if this is the first call, this may not yet be set
14
- tme = tme1 = parentframe. methodtables[idx]:: TypeMapEntry
15
- local tmeprev
14
+ d_meth = d_meth1 = parentframe. methodtables[idx]:: DispatchableMethod
15
+ local d_methprev
16
16
depth = 1
17
17
while true
18
18
# TODO : consider using world age bounds to handle cache invalidation
19
19
# Determine whether the argument types match the signature
20
- sig = tme . sig. parameters:: SimpleVector
20
+ sig = d_meth . sig. parameters:: SimpleVector
21
21
if length (sig) == nargs
22
22
# If this is generated, match only if `enter_generated` also matches
23
- mi = tme . func :: FrameInstance
24
- matches = ! is_generated (scopeof (mi . framecode)) || enter_generated == mi. enter_generated
23
+ fi = d_meth . frameinstance :: FrameInstance
24
+ matches = ! is_generated (scopeof (fi . framecode)) || enter_generated == mi. enter_generated
25
25
if matches
26
26
for i = 1 : nargs
27
27
if ! isa (fargs[i], sig[i])
@@ -34,18 +34,18 @@ function get_call_framecode(fargs::Vector{Any}, parentframe::FrameCode, idx::Int
34
34
# Rearrange the list to place this method first
35
35
# (if we're in a loop, we'll likely match this one again on the next iteration)
36
36
if depth > 1
37
- parentframe. methodtables[idx] = tme
38
- tmeprev . next = tme . next
39
- tme . next = tme1
37
+ parentframe. methodtables[idx] = d_meth
38
+ d_methprev . next = d_meth . next
39
+ d_meth . next = d_meth1
40
40
end
41
- return mi . framecode, mi . sparam_vals
41
+ return fi . framecode, fi . sparam_vals
42
42
end
43
43
end
44
44
depth += 1
45
- tmeprev = tme
46
- tme = tme . next
47
- tme === nothing && break
48
- tme = tme :: TypeMapEntry
45
+ d_methprev = d_meth
46
+ d_meth = d_meth . next
47
+ d_meth === nothing && break
48
+ d_meth = d_meth :: DispatchableMethod
49
49
end
50
50
end
51
51
# We haven't yet encountered this argtype combination and need to look it up by dispatch
@@ -55,33 +55,24 @@ function get_call_framecode(fargs::Vector{Any}, parentframe::FrameCode, idx::Int
55
55
isa (ret, Compiled) && return ret, nothing
56
56
framecode, args, env, argtypes = ret
57
57
# Store the results of the method lookup in the local method table
58
- mi = FrameInstance (framecode, env, is_generated (scopeof (framecode)) & enter_generated)
59
- # it's sort of odd to call this a TypeMapEntry, then set most of the fields incorrectly
60
- # but since we're just using it as a linked list, it's probably ok
61
- tme = ccall (:jl_new_struct_uninit , Any, (Any,), TypeMapEntry):: TypeMapEntry
62
- tme. func = mi
63
- tme. simplesig = nothing
64
- tme. sig = argtypes
65
- tme. isleafsig = true
66
- tme. issimplesig = false
67
- method = framecode. scope:: Method
68
- tme. va = method. isva
58
+ fi = FrameInstance (framecode, env, is_generated (scopeof (framecode)) && enter_generated)
59
+ d_meth = DispatchableMethod (nothing , fi, argtypes)
69
60
if isassigned (parentframe. methodtables, idx)
70
- tme . next = parentframe. methodtables[idx]
71
- # Drop the oldest tme , if necessary
72
- tmetmp = tme . next
61
+ d_meth . next = parentframe. methodtables[idx]
62
+ # Drop the oldest d_meth , if necessary
63
+ d_methtmp = d_meth . next
73
64
depth = 2
74
- while isdefined (tmetmp, :next ) && tmetmp . next != = nothing
65
+ while d_methtmp . next != = nothing
75
66
depth += 1
76
- tmetmp = tmetmp . next
67
+ d_methtmp = d_methtmp . next
77
68
depth >= max_methods && break
78
69
end
79
70
if depth >= max_methods
80
- tmetmp . next = nothing
71
+ d_methtmp . next = nothing
81
72
end
82
73
else
83
- tme . next = nothing
74
+ d_meth . next = nothing
84
75
end
85
- parentframe. methodtables[idx] = tme
76
+ parentframe. methodtables[idx] = d_meth
86
77
return framecode, env
87
78
end
0 commit comments