Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix jl_method_lookup_by_type disabling the wrong cache #18415

Merged
merged 1 commit into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ end
# create a specialized LambdaInfo from a method
function specialize_method(method::Method, types::ANY, sp::SimpleVector, cached)
if cached
return ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any), method, types, sp)
return ccall(:jl_specializations_get_linfo, Ref{LambdaInfo}, (Any, Any, Any, Cint), method, types, sp, true)
else
return ccall(:jl_get_specialized, Ref{LambdaInfo}, (Any, Any, Any), method, types, sp)
end
Expand Down
4 changes: 2 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ static jl_value_t *jl_deserialize_value_(jl_serializer_state *s, jl_value_t *vta
if (external) {
jl_datatype_t *ftype = jl_first_argument_datatype((jl_value_t*)li->specTypes);
jl_methtable_t *mt = ftype->name->mt;
li = jl_method_lookup_by_type(mt, li->specTypes, 1, 0, 0);
li = jl_method_lookup_by_type(mt, li->specTypes, 0, 0, 0);
assert(li);
backref_list.items[pos] = li;
// if it can be inferred but isn't, encourage codegen to infer it
Expand Down Expand Up @@ -2456,7 +2456,7 @@ static void jl_recache_types(void)
jl_datatype_t *ftype = jl_first_argument_datatype((jl_value_t*)argtypes);
jl_methtable_t *mt = ftype->name->mt;
jl_set_typeof(li, (void*)(intptr_t)0x30); // invalidate the old value to help catch errors
li = jl_method_lookup_by_type(mt, argtypes, 1, 0, 0);
li = jl_method_lookup_by_type(mt, argtypes, 0, 0, 0);
assert(li);
// if it can be inferred but isn't, encourage codegen to infer it
if (inferred && !li->inferred) {
Expand Down
10 changes: 5 additions & 5 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ static int8_t jl_cachearg_offset(jl_methtable_t *mt)
/// ----- Insertion logic for special entries ----- ///

// get or create the LambdaInfo for a specialization
JL_DLLEXPORT jl_lambda_info_t *jl_specializations_get_linfo(jl_method_t *m, jl_tupletype_t *type, jl_svec_t *sparams)
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)
{
JL_LOCK(&m->writelock);
jl_typemap_entry_t *sf = jl_typemap_assoc_by_type(m->specializations, type, NULL, 1, /*subtype*/0, /*offs*/0);
if (sf && jl_is_lambda_info(sf->func.value) && ((jl_lambda_info_t*)sf->func.value)->code != jl_nothing) {
JL_UNLOCK(&m->writelock);
return (jl_lambda_info_t*)sf->func.value;
}
jl_lambda_info_t *li = jl_get_specialized(m, type, sparams, 1);
jl_lambda_info_t *li = jl_get_specialized(m, type, sparams, allow_exec);
JL_GC_PUSH1(&li);
// TODO: fuse lookup and insert steps
jl_typemap_insert(&m->specializations, (jl_value_t*)m, type, jl_emptysvec, NULL, jl_emptysvec, (jl_value_t*)li, 0, &tfunc_cache, NULL);
Expand Down Expand Up @@ -758,7 +758,7 @@ static jl_lambda_info_t *cache_method(jl_methtable_t *mt, union jl_typemap_t *ca
}

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

if (cache_with_orig) {
// if there is a need to cache with one of the original signatures,
Expand Down Expand Up @@ -827,7 +827,7 @@ static jl_lambda_info_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype_t *
sig = join_tsig(tt, entry->sig);
jl_lambda_info_t *nf;
if (!cache) {
nf = jl_get_specialized(m, sig, env, allow_exec);
nf = jl_specializations_get_linfo(m, sig, env, allow_exec);
}
else {
nf = cache_method(mt, &mt->cache, (jl_value_t*)mt, sig, tt, entry, env, allow_exec);
Expand Down Expand Up @@ -1593,7 +1593,7 @@ static void _compile_all_deq(jl_array_t *found)
if (m->isstaged)
linfo = templ;
else
linfo = jl_specializations_get_linfo(m, ml->sig, jl_emptysvec);
linfo = jl_specializations_get_linfo(m, ml->sig, jl_emptysvec, 1);

if (linfo->jlcall_api == 2)
continue;
Expand Down