Skip to content

Commit

Permalink
ml-matches: restore fast-path cache update (#36740)
Browse files Browse the repository at this point in the history
In attempting to add one early-exit path, the cache update had gotten
lost for the other fast path!
  • Loading branch information
vtjnash authored Jul 22, 2020
1 parent 1e6e656 commit dac31d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
else {
size_t j, k, l = jl_array_len(expected);
for (k = 0; k < jl_array_len(matches); k++) {
jl_method_match_t *match = jl_array_ptr_ref(matches, k);
jl_method_match_t *match = (jl_method_match_t*)jl_array_ptr_ref(matches, k);
jl_method_t *m = match->method;
for (j = 0; j < l; j++) {
if (m == (jl_method_t*)jl_array_ptr_ref(expected, j))
Expand Down
17 changes: 8 additions & 9 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2700,13 +2700,13 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, int offs,
// done with many of these values now
env.match.ti = NULL; env.matc = NULL; env.match.env = NULL; search.env = NULL;
size_t i, j, len = jl_array_len(env.t);
jl_method_match_t *minmax = NULL;
int minmax_ambig = 0;
int all_subtypes = 1;
if (len > 1) {
// first try to pre-process the results to find the most specific result that fully covers the input
// (since we can do this in linear time, and the rest is O(n^2)
// - first see if this might even be profitable, given the requested output we need to compute
jl_method_match_t *minmax = NULL;
int minmax_ambig = 0;
int all_subtypes = 1;
for (i = 0; i < len; i++) {
jl_method_match_t *matc = (jl_method_match_t*)jl_array_ptr_ref(env.t, i);
if (matc->fully_covers != FULLY_COVERS) {
Expand Down Expand Up @@ -2771,21 +2771,20 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, int offs,
if (all_subtypes) {
if (minmax_ambig) {
if (!include_ambiguous) {
JL_GC_POP();
return jl_an_empty_vec_any;
len = 0;
env.t = jl_an_empty_vec_any;
}
}
else {
assert(minmax != NULL);
jl_array_ptr_set(env.t, 0, minmax);
jl_array_del_end((jl_array_t*)env.t, len - 1);
JL_GC_POP();
if (lim == 0)
return jl_false;
return env.t;
len = 1;
}
}
}
}
if (len > 1) {
// need to partially domsort the graph now into a list
// (this is an insertion sort attempt)
// if we have a minmax method, we ignore anything less specific
Expand Down

0 comments on commit dac31d3

Please sign in to comment.