@@ -67,20 +67,25 @@ function invalidate_method_for_globalref!(gr::GlobalRef, method::Method, invalid
67
67
binding = convert (Core. Binding, gr)
68
68
if isdefined (method, :source )
69
69
src = _uncompressed_ir (method)
70
- old_stmts = src. code
71
70
invalidate_all = should_invalidate_code_for_globalref (gr, src)
72
71
end
72
+ invalidated_any = false
73
73
for mi in specializations (method)
74
74
isdefined (mi, :cache ) || continue
75
75
ci = mi. cache
76
+ invalidated = false
76
77
while true
77
78
if ci. max_world > new_max_world && (invalidate_all || scan_edge_list (ci, binding))
78
79
ccall (:jl_invalidate_code_instance , Cvoid, (Any, UInt), ci, new_max_world)
80
+ invalidated = true
79
81
end
80
82
isdefined (ci, :next ) || break
81
83
ci = ci. next
82
84
end
85
+ invalidated && ccall (:jl_maybe_log_binding_invalidation , Cvoid, (Any,), mi)
86
+ invalidated_any |= invalidated
83
87
end
88
+ return invalidated_any
84
89
end
85
90
86
91
export_affecting_partition_flags (bpart:: Core.BindingPartition ) =
@@ -104,18 +109,21 @@ function invalidate_code_for_globalref!(b::Core.Binding, invalidated_bpart::Core
104
109
need_to_invalidate_export = export_affecting_partition_flags (invalidated_bpart) != =
105
110
export_affecting_partition_flags (new_bpart)
106
111
112
+ invalidated_any = false
113
+ queued_bindings = Tuple{Core. Binding, Core. BindingPartition, Core. BindingPartition}[] # defer handling these to keep the logging coherent
107
114
if need_to_invalidate_code
108
115
if (b. flags & BINDING_FLAG_ANY_IMPLICIT_EDGES) != 0
109
116
nmethods = ccall (:jl_module_scanned_methods_length , Csize_t, (Any,), gr. mod)
110
117
for i = 1 : nmethods
111
118
method = ccall (:jl_module_scanned_methods_getindex , Any, (Any, Csize_t), gr. mod, i):: Method
112
- invalidate_method_for_globalref! (gr, method, invalidated_bpart, new_max_world)
119
+ invalidated_any |= invalidate_method_for_globalref! (gr, method, invalidated_bpart, new_max_world)
113
120
end
114
121
end
115
122
if isdefined (b, :backedges )
116
123
for edge in b. backedges
117
124
if isa (edge, CodeInstance)
118
125
ccall (:jl_invalidate_code_instance , Cvoid, (Any, UInt), edge, new_max_world)
126
+ invalidated_any = true
119
127
elseif isa (edge, Core. Binding)
120
128
isdefined (edge, :partitions ) || continue
121
129
latest_bpart = edge. partitions
@@ -124,9 +132,9 @@ function invalidate_code_for_globalref!(b::Core.Binding, invalidated_bpart::Core
124
132
if is_some_binding_imported (binding_kind (latest_bpart))
125
133
partition_restriction (latest_bpart) === b || continue
126
134
end
127
- invalidate_code_for_globalref! (edge, latest_bpart , latest_bpart, new_max_world )
135
+ push! (queued_bindings, (edge , latest_bpart, latest_bpart) )
128
136
else
129
- invalidate_method_for_globalref! (gr, edge:: Method , invalidated_bpart, new_max_world)
137
+ invalidated_any |= invalidate_method_for_globalref! (gr, edge:: Method , invalidated_bpart, new_max_world)
130
138
end
131
139
end
132
140
end
@@ -148,11 +156,16 @@ function invalidate_code_for_globalref!(b::Core.Binding, invalidated_bpart::Core
148
156
ccall (:jl_maybe_reresolve_implicit , Any, (Any, Csize_t), user_binding, new_max_world) :
149
157
latest_bpart
150
158
if need_to_invalidate_code || new_bpart != = latest_bpart
151
- invalidate_code_for_globalref! ( convert (Core. Binding, user_binding), latest_bpart, new_bpart, new_max_world )
159
+ push! (queued_bindings, ( convert (Core. Binding, user_binding), latest_bpart, new_bpart) )
152
160
end
153
161
end
154
162
end
155
163
end
164
+ invalidated_any && ccall (:jl_maybe_log_binding_invalidation , Cvoid, (Any,), invalidated_bpart)
165
+ for (edge, invalidated_bpart, new_bpart) in queued_bindings
166
+ invalidated_any |= invalidate_code_for_globalref! (edge, invalidated_bpart, new_bpart, new_max_world)
167
+ end
168
+ return invalidated_any
156
169
end
157
170
invalidate_code_for_globalref! (gr:: GlobalRef , invalidated_bpart:: Core.BindingPartition , new_bpart:: Core.BindingPartition , new_max_world:: UInt ) =
158
171
invalidate_code_for_globalref! (convert (Core. Binding, gr), invalidated_bpart, new_bpart, new_max_world)
0 commit comments