Skip to content

Commit

Permalink
allow single non-concrete method match in static call graph
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Aug 16, 2024
1 parent b3f7858 commit e77fe22
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5628,9 +5628,16 @@ static jl_cgval_t emit_call(jl_codectx_t &ctx, jl_expr_t *ex, jl_value_t *rt, bo
jl_method_match_t *match = (jl_method_match_t *)jl_array_ptr_ref(matches, k);
jl_method_instance_t *mi = jl_method_match_to_mi(match, latest_world, min_valid, max_valid, 0);
if (!mi) {
new_invokes.len = len;
failed_dispatch = 1;
break;
if (jl_array_nrows(matches) == 1) {
// if the method match is not compileable, but there is only one, fall back to
// unspecialized implementation
mi = jl_get_unspecialized(match->method);
}
else {
new_invokes.len = len;
failed_dispatch = 1;
break;
}
}
arraylist_push(&new_invokes, mi);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ 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_t *def JL_PROPAGATES_ROOT)
JL_DLLEXPORT 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) {
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
XX(jl_next_from_addrinfo) \
XX(jl_normalize_to_compilable_sig) \
XX(jl_method_match_to_mi) \
XX(jl_get_unspecialized) \
XX(jl_no_exc_handler) \
XX(jl_object_id) \
XX(jl_object_id_) \
Expand Down
2 changes: 1 addition & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ JL_DLLEXPORT jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t
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_debuginfo_t *edges);
jl_method_instance_t *jl_get_unspecialized(jl_method_t *def JL_PROPAGATES_ROOT);
JL_DLLEXPORT jl_method_instance_t *jl_get_unspecialized(jl_method_t *def JL_PROPAGATES_ROOT);
JL_DLLEXPORT void jl_read_codeinst_invoke(jl_code_instance_t *ci, uint8_t *specsigflags, jl_callptr_t *invoke, void **specptr, int waitcompile) JL_NOTSAFEPOINT;
JL_DLLEXPORT jl_method_instance_t *jl_method_match_to_mi(jl_method_match_t *match, size_t world, size_t min_valid, size_t max_valid, int mt_cache);

Expand Down

0 comments on commit e77fe22

Please sign in to comment.