@@ -11,6 +11,7 @@ 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
+ # The case where `methodtables[idx]` is a `Compiled` has already been handled in `bypass_builtins`
14
15
d_meth = d_meth1 = parentframe. methodtables[idx]:: DispatchableMethod
15
16
local d_methprev
16
17
depth = 1
@@ -20,8 +21,12 @@ function get_call_framecode(fargs::Vector{Any}, parentframe::FrameCode, idx::Int
20
21
sig = d_meth. sig. parameters:: SimpleVector
21
22
if length (sig) == nargs
22
23
# If this is generated, match only if `enter_generated` also matches
23
- fi = d_meth. frameinstance:: FrameInstance
24
- matches = ! is_generated (scopeof (fi. framecode)) || enter_generated == fi. enter_generated
24
+ fi = d_meth. frameinstance
25
+ if fi isa FrameInstance
26
+ matches = ! is_generated (scopeof (fi. framecode)) || enter_generated == fi. enter_generated
27
+ else
28
+ matches = ! enter_generated
29
+ end
25
30
if matches
26
31
for i = 1 : nargs
27
32
if ! isa (fargs[i], sig[i])
@@ -38,7 +43,11 @@ function get_call_framecode(fargs::Vector{Any}, parentframe::FrameCode, idx::Int
38
43
d_methprev. next = d_meth. next
39
44
d_meth. next = d_meth1
40
45
end
41
- return fi. framecode, fi. sparam_vals
46
+ if fi isa Compiled
47
+ return Compiled (), nothing
48
+ else
49
+ return fi. framecode, fi. sparam_vals
50
+ end
42
51
end
43
52
end
44
53
depth += 1
@@ -52,11 +61,16 @@ function get_call_framecode(fargs::Vector{Any}, parentframe::FrameCode, idx::Int
52
61
fargs[1 ] = f = to_function (fargs[1 ])
53
62
ret = prepare_call (f, fargs; enter_generated= enter_generated)
54
63
ret === nothing && return f (fargs[2 : end ]. .. ), nothing
55
- isa (ret, Compiled) && return ret, nothing
56
- framecode, args, env, argtypes = ret
57
- # Store the results of the method lookup in the local method table
58
- fi = FrameInstance (framecode, env, is_generated (scopeof (framecode)) && enter_generated)
59
- d_meth = DispatchableMethod (nothing , fi, argtypes)
64
+ is_compiled = isa (ret[1 ], Compiled)
65
+ local framecode
66
+ if is_compiled
67
+ d_meth = DispatchableMethod (nothing , Compiled (), ret[2 ])
68
+ else
69
+ framecode, args, env, argtypes = ret
70
+ # Store the results of the method lookup in the local method table
71
+ fi = FrameInstance (framecode, env, is_generated (scopeof (framecode)) && enter_generated)
72
+ d_meth = DispatchableMethod (nothing , fi, argtypes)
73
+ end
60
74
if isassigned (parentframe. methodtables, idx)
61
75
d_meth. next = parentframe. methodtables[idx]
62
76
# Drop the oldest d_meth, if necessary
@@ -74,5 +88,9 @@ function get_call_framecode(fargs::Vector{Any}, parentframe::FrameCode, idx::Int
74
88
d_meth. next = nothing
75
89
end
76
90
parentframe. methodtables[idx] = d_meth
77
- return framecode, env
91
+ if is_compiled
92
+ return Compiled (), nothing
93
+ else
94
+ return framecode, env
95
+ end
78
96
end
0 commit comments