@@ -170,31 +170,29 @@ using Core.Compiler:
170
170
AbstractInterpreter, InferenceResult, InferenceParams, InferenceState, OptimizationParams
171
171
172
172
struct GPUInterpreter <: AbstractInterpreter
173
+ job:: CompilerJob
174
+
173
175
global_cache:: CodeCache
174
176
method_table:: Union{Nothing,Core.MethodTable}
175
177
176
178
# Cache of inference results for this particular interpreter
177
179
local_cache:: Vector{InferenceResult}
178
- # The world age we're working inside of
179
- world:: UInt
180
180
181
181
# Parameters for inference and optimization
182
182
inf_params:: InferenceParams
183
183
opt_params:: OptimizationParams
184
184
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 ()
187
187
188
188
return new (
189
+ job,
189
190
cache,
190
191
mt,
191
192
192
193
# Initially empty cache
193
194
Vector {InferenceResult} (),
194
195
195
- # world age counter
196
- world,
197
-
198
196
# parameters for inference and optimization
199
197
InferenceParams (unoptimize_throw_blocks= false ),
200
198
VERSION >= v " 1.8.0-DEV.486" ? OptimizationParams () :
205
203
206
204
Core. Compiler. InferenceParams (interp:: GPUInterpreter ) = interp. inf_params
207
205
Core. 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
209
207
Core. 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))
211
210
212
211
# No need to do any locking since we're not putting our results into the runtime cache
213
212
Core. Compiler. lock_mi_inference (interp:: GPUInterpreter , mi:: MethodInstance ) = nothing
@@ -221,11 +220,11 @@ function InferenceState(result::InferenceResult, cached::Symbol, interp::GPUInte
221
220
src = retrieve_code_info (result. linfo)
222
221
src === nothing && return nothing
223
222
validate_code_in_debug_mode (result. linfo, src, " lowered" )
224
- validate_globalrefs (result. linfo, src)
223
+ validate_globalrefs (interp, result. linfo, src)
225
224
return InferenceState (result, src, cached, interp)
226
225
end
227
226
228
- function validate_globalrefs (mi, src)
227
+ function validate_globalrefs (interp, mi, src)
229
228
function validate (x)
230
229
if x isa Expr
231
230
return Expr (x. head, validate .(x. args))
@@ -234,10 +233,10 @@ function validate_globalrefs(mi, src)
234
233
# XXX : when does this happen? do we miss any cases by bailing out early?
235
234
# why doesn't calling `Base.resolve(x, force=true)` work?
236
235
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) " ) )
238
237
end
239
238
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) " ) )
241
240
end
242
241
# XXX : can we use KernelError? and make the validation conditional? both are
243
242
# complicated by the fact that we don't have the CompilerJob here,
@@ -270,14 +269,14 @@ if isdefined(Base.Experimental, Symbol("@overlay"))
270
269
using Core. Compiler: OverlayMethodTable
271
270
if v " 1.8-beta2" <= VERSION < v " 1.9-" || VERSION >= v " 1.9.0-DEV.120"
272
271
Core. Compiler. method_table (interp:: GPUInterpreter ) =
273
- OverlayMethodTable (interp . world , interp. method_table)
272
+ OverlayMethodTable (Core . Compiler . get_world_counter (interp) , interp. method_table)
274
273
else
275
274
Core. 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)
277
276
end
278
277
else
279
278
Core. Compiler. method_table (interp:: GPUInterpreter , sv:: InferenceState ) =
280
- WorldOverlayMethodTable (interp . world )
279
+ WorldOverlayMethodTable (Core . Compiler . get_world_counter (interp) )
281
280
end
282
281
283
282
0 commit comments