Skip to content

Commit 7d7b2dd

Browse files
committed
Allow replacement of jl_typeinf_func
Fixes #31429
1 parent b076d04 commit 7d7b2dd

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/gf.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -521,20 +521,22 @@ size_t jl_typeinf_world = 0;
521521
JL_DLLEXPORT void jl_set_typeinf_func(jl_value_t *f)
522522
{
523523
jl_typeinf_func = (jl_function_t*)f;
524-
jl_typeinf_world = jl_get_tls_world_age();
525-
++jl_world_counter; // make type-inference the only thing in this world
526-
// give type inference a chance to see all of these
527-
// TODO: also reinfer if max_world != ~(size_t)0
528-
jl_array_t *unspec = jl_alloc_vec_any(0);
529-
JL_GC_PUSH1(&unspec);
530-
jl_foreach_reachable_mtable(reset_mt_caches, (void*)unspec);
531-
size_t i, l;
532-
for (i = 0, l = jl_array_len(unspec); i < l; i++) {
533-
jl_method_instance_t *li = (jl_method_instance_t*)jl_array_ptr_ref(unspec, i);
534-
if (!jl_is_rettype_inferred(li))
535-
jl_type_infer(&li, jl_world_counter, 1);
524+
if (jl_typeinf_world == 0) {
525+
jl_typeinf_world = jl_get_tls_world_age();
526+
++jl_world_counter; // make type-inference the only thing in this world
527+
// give type inference a chance to see all of these
528+
// TODO: also reinfer if max_world != ~(size_t)0
529+
jl_array_t *unspec = jl_alloc_vec_any(0);
530+
JL_GC_PUSH1(&unspec);
531+
jl_foreach_reachable_mtable(reset_mt_caches, (void*)unspec);
532+
size_t i, l;
533+
for (i = 0, l = jl_array_len(unspec); i < l; i++) {
534+
jl_method_instance_t *li = (jl_method_instance_t*)jl_array_ptr_ref(unspec, i);
535+
if (!jl_is_rettype_inferred(li))
536+
jl_type_infer(&li, jl_world_counter, 1);
537+
}
538+
JL_GC_POP();
536539
}
537-
JL_GC_POP();
538540
}
539541

540542
static int very_general_type(jl_value_t *t)

0 commit comments

Comments
 (0)