@@ -1290,7 +1290,12 @@ function typeinf_ext_toplevel(mi::MethodInstance, world::UInt, source_mode::UInt
1290
1290
end
1291
1291
1292
1292
# This is a bridge for the C code calling `jl_typeinf_func()` on set of Method matches
1293
- function typeinf_ext_toplevel (methods:: Vector{Any} , worlds:: Vector{UInt} , trim:: Bool )
1293
+ # The trim_mode can be any of:
1294
+ const TRIM_NO = 0
1295
+ const TRIM_SAFE = 1
1296
+ const TRIM_UNSAFE = 2
1297
+ const TRIM_UNSAFE_WARN = 3
1298
+ function typeinf_ext_toplevel (methods:: Vector{Any} , worlds:: Vector{UInt} , trim_mode:: Int )
1294
1299
inspected = IdSet {CodeInstance} ()
1295
1300
tocompile = Vector {CodeInstance} ()
1296
1301
codeinfos = []
@@ -1338,7 +1343,7 @@ function typeinf_ext_toplevel(methods::Vector{Any}, worlds::Vector{UInt}, trim::
1338
1343
src = codeinfo_for_const (interp, mi, callee. rettype_const)
1339
1344
elseif haskey (interp. codegen, callee)
1340
1345
src = interp. codegen[callee]
1341
- elseif isa (def, Method) && ccall (:jl_get_module_infer , Cint, (Any,), def. module) == 0 && ! trim
1346
+ elseif isa (def, Method) && ccall (:jl_get_module_infer , Cint, (Any,), def. module) == 0 && trim_mode == TRIM_NO
1342
1347
src = retrieve_code_info (mi, get_inference_world (interp))
1343
1348
else
1344
1349
# TODO : typeinf_code could return something with different edges/ages/owner/abi (needing an update to callee), which we don't handle here
@@ -1353,15 +1358,19 @@ function typeinf_ext_toplevel(methods::Vector{Any}, worlds::Vector{UInt}, trim::
1353
1358
end
1354
1359
push! (codeinfos, callee)
1355
1360
push! (codeinfos, src)
1356
- elseif trim
1357
- println (" warning: failed to get code for " , mi)
1358
1361
end
1359
1362
end
1360
1363
latest = false
1361
1364
end
1365
+ if trim_mode != TRIM_NO && trim_mode != TRIM_UNSAFE
1366
+ verify_typeinf_trim (codeinfos, trim_mode == TRIM_UNSAFE_WARN)
1367
+ end
1362
1368
return codeinfos
1363
1369
end
1364
1370
1371
+ verify_typeinf_trim (io:: IO , codeinfos:: Vector{Any} , onlywarn:: Bool ) = (msg = " --trim verifier not defined" ; onlywarn ? println (io, msg) : error (msg))
1372
+ verify_typeinf_trim (codeinfos:: Vector{Any} , onlywarn:: Bool ) = invokelatest (verify_typeinf_trim, stdout , codeinfos, onlywarn)
1373
+
1365
1374
function return_type (@nospecialize (f), t:: DataType ) # this method has a special tfunc
1366
1375
world = tls_world_age ()
1367
1376
args = Any[_return_type, NativeInterpreter (world), Tuple{Core. Typeof (f), t. parameters... }]
0 commit comments