Skip to content

Commit d3d0dec

Browse files
authored
Merge pull request #18415 from JuliaLang/jn/18404
fix jl_method_lookup_by_type disabling the wrong cache
2 parents f141c16 + 9402af3 commit d3d0dec

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

base/inference.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ end
14221422
# create a specialized LambdaInfo from a method
14231423
function specialize_method(method::Method, types::ANY, sp::SimpleVector, cached)
14241424
if cached
1425-
return ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any), method, types, sp)
1425+
return ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any, Cint), method, types, sp, true)
14261426
else
14271427
return ccall(:jl_get_specialized, Ref{LambdaInfo}, (Any, Any, Any), method, types, sp)
14281428
end

src/dump.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ static jl_value_t *jl_deserialize_value_(jl_serializer_state *s, jl_value_t *vta
15911591
if (external) {
15921592
jl_datatype_t *ftype = jl_first_argument_datatype((jl_value_t*)li->specTypes);
15931593
jl_methtable_t *mt = ftype->name->mt;
1594-
li = jl_method_lookup_by_type(mt, li->specTypes, 1, 0, 0);
1594+
li = jl_method_lookup_by_type(mt, li->specTypes, 0, 0, 0);
15951595
assert(li);
15961596
backref_list.items[pos] = li;
15971597
// if it can be inferred but isn't, encourage codegen to infer it
@@ -2456,7 +2456,7 @@ static void jl_recache_types(void)
24562456
jl_datatype_t *ftype = jl_first_argument_datatype((jl_value_t*)argtypes);
24572457
jl_methtable_t *mt = ftype->name->mt;
24582458
jl_set_typeof(li, (void*)(intptr_t)0x30); // invalidate the old value to help catch errors
2459-
li = jl_method_lookup_by_type(mt, argtypes, 1, 0, 0);
2459+
li = jl_method_lookup_by_type(mt, argtypes, 0, 0, 0);
24602460
assert(li);
24612461
// if it can be inferred but isn't, encourage codegen to infer it
24622462
if (inferred && !li->inferred) {

src/gf.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ static int8_t jl_cachearg_offset(jl_methtable_t *mt)
117117
/// ----- Insertion logic for special entries ----- ///
118118

119119
// get or create the LambdaInfo for a specialization
120-
JL_DLLEXPORT jl_lambda_info_t *jl_specializations_get_linfo(jl_method_t *m, jl_tupletype_t *type, jl_svec_t *sparams)
120+
JL_DLLEXPORT jl_lambda_info_t *jl_specializations_get_linfo(jl_method_t *m, jl_tupletype_t *type, jl_svec_t *sparams, int allow_exec)
121121
{
122122
JL_LOCK(&m->writelock);
123123
jl_typemap_entry_t *sf = jl_typemap_assoc_by_type(m->specializations, type, NULL, 1, /*subtype*/0, /*offs*/0);
124124
if (sf && jl_is_lambda_info(sf->func.value) && ((jl_lambda_info_t*)sf->func.value)->code != jl_nothing) {
125125
JL_UNLOCK(&m->writelock);
126126
return (jl_lambda_info_t*)sf->func.value;
127127
}
128-
jl_lambda_info_t *li = jl_get_specialized(m, type, sparams, 1);
128+
jl_lambda_info_t *li = jl_get_specialized(m, type, sparams, allow_exec);
129129
JL_GC_PUSH1(&li);
130130
// TODO: fuse lookup and insert steps
131131
jl_typemap_insert(&m->specializations, (jl_value_t*)m, type, jl_emptysvec, NULL, jl_emptysvec, (jl_value_t*)li, 0, &tfunc_cache, NULL);
@@ -758,7 +758,7 @@ static jl_lambda_info_t *cache_method(jl_methtable_t *mt, union jl_typemap_t *ca
758758
}
759759

760760
// here we infer types and specialize the method
761-
newmeth = jl_specializations_get_linfo(definition, type, sparams);
761+
newmeth = jl_specializations_get_linfo(definition, type, sparams, allow_exec);
762762

763763
if (cache_with_orig) {
764764
// if there is a need to cache with one of the original signatures,
@@ -827,7 +827,7 @@ static jl_lambda_info_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype_t *
827827
sig = join_tsig(tt, entry->sig);
828828
jl_lambda_info_t *nf;
829829
if (!cache) {
830-
nf = jl_get_specialized(m, sig, env, allow_exec);
830+
nf = jl_specializations_get_linfo(m, sig, env, allow_exec);
831831
}
832832
else {
833833
nf = cache_method(mt, &mt->cache, (jl_value_t*)mt, sig, tt, entry, env, allow_exec);
@@ -1593,7 +1593,7 @@ static void _compile_all_deq(jl_array_t *found)
15931593
if (m->isstaged)
15941594
linfo = templ;
15951595
else
1596-
linfo = jl_specializations_get_linfo(m, ml->sig, jl_emptysvec);
1596+
linfo = jl_specializations_get_linfo(m, ml->sig, jl_emptysvec, 1);
15971597

15981598
if (linfo->jlcall_api == 2)
15991599
continue;

0 commit comments

Comments
 (0)