@@ -304,7 +304,7 @@ JL_DLLEXPORT jl_module_t *jl_base_relative_to(jl_module_t *m)
304
304
return jl_top_module ;
305
305
}
306
306
307
- static void expr_attributes (jl_value_t * v , int * has_intrinsics , int * has_defs , int * has_opaque )
307
+ static void expr_attributes (jl_value_t * v , int * has_intrinsics , int * has_defs , int * has_opaque , int * has_forcedcompile )
308
308
{
309
309
if (!jl_is_expr (v ))
310
310
return ;
@@ -339,6 +339,12 @@ static void expr_attributes(jl_value_t *v, int *has_intrinsics, int *has_defs, i
339
339
* has_opaque = 1 ;
340
340
return ;
341
341
}
342
+ else if (head == meta_sym && jl_expr_nargs (e ) == 2 &&
343
+ jl_exprarg (e , 0 ) == (jl_value_t * )compile_sym &&
344
+ jl_exprarg (e , 1 ) == (jl_value_t * )force_sym ) {
345
+ * has_forcedcompile = 1 ;
346
+ return ;
347
+ }
342
348
else if (head == call_sym && jl_expr_nargs (e ) > 0 ) {
343
349
jl_value_t * called = NULL ;
344
350
jl_value_t * f = jl_exprarg (e , 0 );
@@ -368,7 +374,7 @@ static void expr_attributes(jl_value_t *v, int *has_intrinsics, int *has_defs, i
368
374
for (i = 0 ; i < jl_array_len (e -> args ); i ++ ) {
369
375
jl_value_t * a = jl_exprarg (e , i );
370
376
if (jl_is_expr (a ))
371
- expr_attributes (a , has_intrinsics , has_defs , has_opaque );
377
+ expr_attributes (a , has_intrinsics , has_defs , has_opaque , has_forcedcompile );
372
378
}
373
379
}
374
380
@@ -377,19 +383,17 @@ int jl_code_requires_compiler(jl_code_info_t *src)
377
383
jl_array_t * body = src -> code ;
378
384
assert (jl_typeis (body , jl_array_any_type ));
379
385
size_t i ;
380
- int has_intrinsics = 0 , has_defs = 0 , has_opaque = 0 ;
381
- if (jl_has_meta (body , compile_sym ))
382
- return 1 ;
386
+ int has_intrinsics = 0 , has_defs = 0 , has_opaque = 0 , has_forcedcompile = 0 ;
383
387
for (i = 0 ; i < jl_array_len (body ); i ++ ) {
384
388
jl_value_t * stmt = jl_array_ptr_ref (body ,i );
385
- expr_attributes (stmt , & has_intrinsics , & has_defs , & has_opaque );
386
- if (has_intrinsics )
389
+ expr_attributes (stmt , & has_intrinsics , & has_defs , & has_opaque , & has_forcedcompile );
390
+ if (has_intrinsics || has_forcedcompile )
387
391
return 1 ;
388
392
}
389
393
return 0 ;
390
394
}
391
395
392
- static void body_attributes (jl_array_t * body , int * has_intrinsics , int * has_defs , int * has_loops , int * has_opaque , int * has_compile )
396
+ static void body_attributes (jl_array_t * body , int * has_intrinsics , int * has_defs , int * has_loops , int * has_opaque , int * has_forcedcompile )
393
397
{
394
398
size_t i ;
395
399
* has_loops = 0 ;
@@ -405,9 +409,8 @@ static void body_attributes(jl_array_t *body, int *has_intrinsics, int *has_defs
405
409
* has_loops = 1 ;
406
410
}
407
411
}
408
- expr_attributes (stmt , has_intrinsics , has_defs , has_opaque );
412
+ expr_attributes (stmt , has_intrinsics , has_defs , has_opaque , has_forcedcompile );
409
413
}
410
- * has_compile = jl_has_meta (body , compile_sym );
411
414
}
412
415
413
416
static jl_module_t * call_require (jl_module_t * mod , jl_sym_t * var ) JL_GLOBALLY_ROOTED
@@ -851,20 +854,20 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *JL_NONNULL m, jl_value_t *e, int
851
854
return (jl_value_t * )ex ;
852
855
}
853
856
854
- int has_intrinsics = 0 , has_defs = 0 , has_loops = 0 , has_opaque = 0 , has_compile = 0 ;
857
+ int has_intrinsics = 0 , has_defs = 0 , has_loops = 0 , has_opaque = 0 , has_forcedcompile = 0 ;
855
858
assert (head == thunk_sym );
856
859
thk = (jl_code_info_t * )jl_exprarg (ex , 0 );
857
860
assert (jl_is_code_info (thk ));
858
861
assert (jl_typeis (thk -> code , jl_array_any_type ));
859
- body_attributes ((jl_array_t * )thk -> code , & has_intrinsics , & has_defs , & has_loops , & has_opaque , & has_compile );
862
+ body_attributes ((jl_array_t * )thk -> code , & has_intrinsics , & has_defs , & has_loops , & has_opaque , & has_forcedcompile );
860
863
861
864
jl_value_t * result ;
862
- if (has_intrinsics || (! has_defs && fast && has_loops &&
863
- jl_options . compile_enabled != JL_OPTIONS_COMPILE_OFF &&
864
- jl_options .compile_enabled != JL_OPTIONS_COMPILE_MIN &&
865
- jl_get_module_compile ( m ) != JL_OPTIONS_COMPILE_OFF &&
866
- jl_get_module_compile (m ) != JL_OPTIONS_COMPILE_MIN ) ||
867
- has_compile ) {
865
+ if (has_intrinsics || has_forcedcompile ||
866
+ (! has_defs && fast && has_loops &&
867
+ jl_options .compile_enabled != JL_OPTIONS_COMPILE_OFF &&
868
+ jl_options . compile_enabled != JL_OPTIONS_COMPILE_MIN &&
869
+ jl_get_module_compile (m ) != JL_OPTIONS_COMPILE_OFF &&
870
+ jl_get_module_compile ( m ) != JL_OPTIONS_COMPILE_MIN ) ) {
868
871
// use codegen
869
872
mfunc = method_instance_for_thunk (thk , m );
870
873
jl_resolve_globals_in_ir ((jl_array_t * )thk -> code , m , NULL , 0 );
0 commit comments