From 976be82c40d20793b507d7e86f7375729e6e478b Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 2 Dec 2022 16:04:40 -0500 Subject: [PATCH] fix #47662, broken --compile=all on 1.8.x (#47678) --- src/gf.c | 17 +++++++++++++---- src/julia_internal.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gf.c b/src/gf.c index f0dcdbb298528..49078f903b708 100644 --- a/src/gf.c +++ b/src/gf.c @@ -1951,13 +1951,22 @@ JL_DLLEXPORT jl_value_t *jl_matching_methods(jl_tupletype_t *types, jl_value_t * return ml_matches((jl_methtable_t*)mt, types, lim, include_ambiguous, 1, world, 1, min_valid, max_valid, ambig); } -jl_method_instance_t *jl_get_unspecialized(jl_method_instance_t *method JL_PROPAGATES_ROOT) +jl_method_instance_t *jl_get_unspecialized_from_mi(jl_method_instance_t *method JL_PROPAGATES_ROOT) { - // one unspecialized version of a function can be shared among all cached specializations jl_method_t *def = method->def.method; + jl_method_instance_t *mi = jl_get_unspecialized(def); + if (mi == NULL) { + return method; + } + return mi; +} + +jl_method_instance_t *jl_get_unspecialized(jl_method_t *def JL_PROPAGATES_ROOT) +{ + // one unspecialized version of a function can be shared among all cached specializations if (!jl_is_method(def) || def->source == NULL) { // generated functions might instead randomly just never get inferred, sorry - return method; + return NULL; } if (def->unspecialized == NULL) { JL_LOCK(&def->writelock); @@ -2078,7 +2087,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t codeinst = jl_generate_fptr(mi, world); if (!codeinst) { - jl_method_instance_t *unspec = jl_get_unspecialized(mi); + jl_method_instance_t *unspec = jl_get_unspecialized_from_mi(mi); jl_code_instance_t *ucache = jl_get_method_inferred(unspec, (jl_value_t*)jl_any_type, 1, ~(size_t)0); // ask codegen to make the fptr for unspec if (jl_atomic_load_relaxed(&ucache->invoke) == NULL) { diff --git a/src/julia_internal.h b/src/julia_internal.h index 0906782640406..c5516c01315d6 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -526,7 +526,7 @@ void jl_generate_fptr_for_unspecialized(jl_code_instance_t *unspec); JL_DLLEXPORT jl_code_instance_t *jl_get_method_inferred( jl_method_instance_t *mi JL_PROPAGATES_ROOT, jl_value_t *rettype, size_t min_world, size_t max_world); -jl_method_instance_t *jl_get_unspecialized(jl_method_instance_t *method JL_PROPAGATES_ROOT); +jl_method_instance_t *jl_get_unspecialized(jl_method_t *def JL_PROPAGATES_ROOT); JL_DLLEXPORT int jl_compile_hint(jl_tupletype_t *types); jl_code_info_t *jl_code_for_interpreter(jl_method_instance_t *lam JL_PROPAGATES_ROOT);