@@ -170,31 +170,29 @@ using Core.Compiler:
170170 AbstractInterpreter, InferenceResult, InferenceParams, InferenceState, OptimizationParams
171171
172172struct GPUInterpreter <: AbstractInterpreter
173+ job:: CompilerJob
174+
173175 global_cache:: CodeCache
174176 method_table:: Union{Nothing,Core.MethodTable}
175177
176178 # Cache of inference results for this particular interpreter
177179 local_cache:: Vector{InferenceResult}
178- # The world age we're working inside of
179- world:: UInt
180180
181181 # Parameters for inference and optimization
182182 inf_params:: InferenceParams
183183 opt_params:: OptimizationParams
184184
185- function GPUInterpreter (cache:: CodeCache , mt:: Union{Nothing,Core.MethodTable} , world :: UInt )
186- @assert world <= Base. get_world_counter ()
185+ function GPUInterpreter (job :: CompilerJob , cache:: CodeCache , mt:: Union{Nothing,Core.MethodTable} )
186+ @assert job . source . world <= Base. get_world_counter ()
187187
188188 return new (
189+ job,
189190 cache,
190191 mt,
191192
192193 # Initially empty cache
193194 Vector {InferenceResult} (),
194195
195- # world age counter
196- world,
197-
198196 # parameters for inference and optimization
199197 InferenceParams (unoptimize_throw_blocks= false ),
200198 VERSION >= v " 1.8.0-DEV.486" ? OptimizationParams () :
205203
206204Core. Compiler. InferenceParams (interp:: GPUInterpreter ) = interp. inf_params
207205Core. Compiler. OptimizationParams (interp:: GPUInterpreter ) = interp. opt_params
208- Core. Compiler. get_world_counter (interp:: GPUInterpreter ) = interp. world
206+ Core. Compiler. get_world_counter (interp:: GPUInterpreter ) = interp. job . source . world
209207Core. Compiler. get_inference_cache (interp:: GPUInterpreter ) = interp. local_cache
210- Core. Compiler. code_cache (interp:: GPUInterpreter ) = WorldView (interp. global_cache, interp. world)
208+ Core. Compiler. code_cache (interp:: GPUInterpreter ) =
209+ WorldView (interp. global_cache, Core. Compiler. get_world_counter (interp))
211210
212211# No need to do any locking since we're not putting our results into the runtime cache
213212Core. Compiler. lock_mi_inference (interp:: GPUInterpreter , mi:: MethodInstance ) = nothing
@@ -221,11 +220,11 @@ function InferenceState(result::InferenceResult, cached::Symbol, interp::GPUInte
221220 src = retrieve_code_info (result. linfo)
222221 src === nothing && return nothing
223222 validate_code_in_debug_mode (result. linfo, src, " lowered" )
224- validate_globalrefs (result. linfo, src)
223+ validate_globalrefs (interp, result. linfo, src)
225224 return InferenceState (result, src, cached, interp)
226225end
227226
228- function validate_globalrefs (mi, src)
227+ function validate_globalrefs (interp, mi, src)
229228 function validate (x)
230229 if x isa Expr
231230 return Expr (x. head, validate .(x. args))
@@ -234,10 +233,10 @@ function validate_globalrefs(mi, src)
234233 # XXX : when does this happen? do we miss any cases by bailing out early?
235234 # why doesn't calling `Base.resolve(x, force=true)` work?
236235 if ! Base. isdefined (x. mod, x. name)
237- error ( " using undefined global: $(x. mod) .$(x. name) " )
236+ throw ( KernelError (interp . job, " using undefined global: $(x. mod) .$(x. name) " ) )
238237 end
239238 if ! Base. isconst (x. mod, x. name)
240- error ( " using mutable global: $(x. mod) .$(x. name) " )
239+ throw ( KernelError (interp . job, " using mutable global: $(x. mod) .$(x. name) " ) )
241240 end
242241 # XXX : can we use KernelError? and make the validation conditional? both are
243242 # complicated by the fact that we don't have the CompilerJob here,
@@ -270,14 +269,14 @@ if isdefined(Base.Experimental, Symbol("@overlay"))
270269using Core. Compiler: OverlayMethodTable
271270if v " 1.8-beta2" <= VERSION < v " 1.9-" || VERSION >= v " 1.9.0-DEV.120"
272271Core. Compiler. method_table (interp:: GPUInterpreter ) =
273- OverlayMethodTable (interp . world , interp. method_table)
272+ OverlayMethodTable (Core . Compiler . get_world_counter (interp) , interp. method_table)
274273else
275274Core. Compiler. method_table (interp:: GPUInterpreter , sv:: InferenceState ) =
276- OverlayMethodTable (interp . world , interp. method_table)
275+ OverlayMethodTable (Core . Compiler . get_world_counter (interp) , interp. method_table)
277276end
278277else
279278Core. Compiler. method_table (interp:: GPUInterpreter , sv:: InferenceState ) =
280- WorldOverlayMethodTable (interp . world )
279+ WorldOverlayMethodTable (Core . Compiler . get_world_counter (interp) )
281280end
282281
283282
0 commit comments