Skip to content

Commit

Permalink
max_world_mask is now unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Mar 20, 2020
1 parent 48ed9ec commit e0a036e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4683,7 +4683,7 @@ Function *jl_cfunction_object(jl_function_t *ff, jl_value_t *declrt, jl_tupletyp
else {
cache_l2 = jl_eqtable_get(jl_cfunction_list, ft, NULL);
if (cache_l2) {
struct jl_typemap_assoc search = {(jl_value_t*)argt, 1, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)argt, 1, NULL, 0, ~(size_t)0};
cache_l3 = jl_typemap_assoc_by_type(cache_l2, &search, /*offs*/0, /*subtype*/0);
if (cache_l3) {
jl_svec_t *sf = (jl_svec_t*)cache_l3->func.value;
Expand Down
3 changes: 2 additions & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -3097,7 +3097,7 @@ static jl_method_t *jl_lookup_method(jl_methtable_t *mt, jl_datatype_t *sig, siz
{
if (world < jl_main_module->primary_world)
world = jl_main_module->primary_world;
struct jl_typemap_assoc search = {(jl_value_t*)sig, world, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)sig, world, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *entry = jl_typemap_assoc_by_type(mt->defs, &search, /*offs*/0, /*subtype*/0);
return (jl_method_t*)entry->func.value;
}
Expand Down Expand Up @@ -3225,6 +3225,7 @@ static jl_value_t *_jl_restore_incremental(ios_t *f, jl_array_t *mod_array)
};
jl_array_t *restored = (jl_array_t*)jl_deserialize_value(&s, (jl_value_t**)&restored);
serializer_worklist = restored;
assert(jl_isa((jl_value_t*)restored, jl_array_any_type));

// get list of external generic functions
jl_value_t *external_methods = jl_deserialize_value(&s, &external_methods);
Expand Down
22 changes: 11 additions & 11 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static int8_t jl_cachearg_offset(jl_methtable_t *mt)
JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m JL_PROPAGATES_ROOT, jl_value_t *type, jl_svec_t *sparams)
{
JL_LOCK(&m->writelock);
struct jl_typemap_assoc search = {type, 1, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {type, 1, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *sf = jl_typemap_assoc_by_type(m->specializations, &search, /*offs*/0, /*subtype*/0);
if (sf && jl_is_method_instance(sf->func.value)) {
JL_UNLOCK(&m->writelock);
Expand All @@ -109,7 +109,7 @@ JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m J

JL_DLLEXPORT jl_value_t *jl_specializations_lookup(jl_method_t *m, jl_value_t *type)
{
struct jl_typemap_assoc search = {type, 1, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {type, 1, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *sf = jl_typemap_assoc_by_type(m->specializations, &search, /*offs*/0, /*subtype*/0);
if (!sf)
return jl_nothing;
Expand All @@ -118,7 +118,7 @@ JL_DLLEXPORT jl_value_t *jl_specializations_lookup(jl_method_t *m, jl_value_t *t

JL_DLLEXPORT jl_value_t *jl_methtable_lookup(jl_methtable_t *mt, jl_value_t *type, size_t world)
{
struct jl_typemap_assoc search = {type, world, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {type, world, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *sf = jl_typemap_assoc_by_type(mt->defs, &search, /*offs*/0, /*subtype*/0);
if (!sf)
return jl_nothing;
Expand Down Expand Up @@ -860,7 +860,7 @@ static jl_method_instance_t *cache_method(
// short-circuit (now that we hold the lock) if this entry is already present
int8_t offs = mt ? jl_cachearg_offset(mt) : 1;
{ // scope block
struct jl_typemap_assoc search = {(jl_value_t*)tt, world, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)tt, world, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *entry = jl_typemap_assoc_by_type(*cache, &search, offs, /*subtype*/1);
if (entry && entry->func.value)
return entry->func.linfo;
Expand Down Expand Up @@ -994,7 +994,7 @@ static jl_method_instance_t *cache_method(
// short-circuit if this exact entry is already present
// to avoid adding a new duplicate copy of it
if (cachett != tt && simplett == NULL) {
struct jl_typemap_assoc search = {(jl_value_t*)cachett, min_valid, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)cachett, min_valid, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *entry = jl_typemap_assoc_by_type(*cache, &search, offs, /*subtype*/1);
if (entry && (jl_value_t*)entry->simplesig == jl_nothing) {
if (jl_egal((jl_value_t*)guardsigs, (jl_value_t*)entry->guardsigs)) {
Expand Down Expand Up @@ -1093,7 +1093,7 @@ static jl_typemap_entry_t *jl_typemap_morespecific_by_type(jl_typemap_entry_t *f
static jl_method_instance_t *jl_mt_assoc_by_type(jl_methtable_t *mt, jl_datatype_t *tt, int mt_cache, size_t world)
{
// caller must hold the mt->writelock
struct jl_typemap_assoc search = {(jl_value_t*)tt, world, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)tt, world, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *entry = jl_typemap_assoc_by_type(mt->cache, &search, jl_cachearg_offset(mt), /*subtype*/1);
if (entry && entry->func.value)
return entry->func.linfo;
Expand Down Expand Up @@ -1217,7 +1217,7 @@ static int check_ambiguous_visitor(jl_typemap_entry_t *oldentry, struct typemap_
// TODO: we might like to use `subtype = exact1 && exact2` here, but check_disabled_ambiguous_visitor
// won't be able to handle that, so we might end up making some unnecessary mambig entries here
// but I don't have any examples of such
struct jl_typemap_assoc search = {(jl_value_t*)isect, world, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)isect, world, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *l = jl_typemap_assoc_by_type(closure->defs, &search, /*offs*/0, /*subtype*/0);
//assert((!subtype || l != after) && "bad typemap lookup result"); // should find `before` first
if (l != NULL && l != before && l != after) {
Expand Down Expand Up @@ -1617,7 +1617,7 @@ JL_DLLEXPORT void jl_method_table_insert(jl_methtable_t *mt, jl_method_t *method
JL_GC_PUSH1(&oldvalue);
JL_LOCK(&mt->writelock);
// first delete the existing entry (we'll disable it later)
struct jl_typemap_assoc search = {(jl_value_t*)type, method->primary_world, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)type, method->primary_world, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *oldentry = jl_typemap_assoc_by_type(mt->defs, &search, /*offs*/0, /*subtype*/0);
if (oldentry) {
oldentry->max_world = method->primary_world - 1;
Expand Down Expand Up @@ -2330,7 +2330,7 @@ JL_DLLEXPORT jl_value_t *jl_gf_invoke_lookup(jl_value_t *types JL_PROPAGATES_ROO
return jl_nothing;

// XXX: return min/max world
struct jl_typemap_assoc search = {(jl_value_t*)types, world, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)types, world, NULL, 0, ~(size_t)0};
jl_typemap_entry_t *entry = jl_typemap_assoc_by_type(mt->defs, &search, /*offs*/0, /*subtype*/1);
if (entry == NULL)
return jl_nothing;
Expand Down Expand Up @@ -2415,7 +2415,7 @@ JL_DLLEXPORT jl_value_t *jl_get_invoke_lambda(jl_typemap_entry_t *entry, jl_valu

jl_method_t *method = entry->func.method;
jl_typemap_entry_t *tm = NULL;
struct jl_typemap_assoc search = {(jl_value_t*)tt, 1, 0, NULL, 0, ~(size_t)0};
struct jl_typemap_assoc search = {(jl_value_t*)tt, 1, NULL, 0, ~(size_t)0};
if (method->invokes != NULL) {
tm = jl_typemap_assoc_by_type(method->invokes, &search, /*offs*/1, /*subtype*/1);
if (tm) {
Expand Down Expand Up @@ -2717,7 +2717,7 @@ static jl_value_t *ml_matches(jl_typemap_t *defs, int offs,
env.world = world;
env.min_valid = *min_valid;
env.max_valid = *max_valid;
struct jl_typemap_assoc search = {(jl_value_t*)type, world, 0, jl_emptysvec, env.min_valid, env.max_valid};
struct jl_typemap_assoc search = {(jl_value_t*)type, world, jl_emptysvec, env.min_valid, env.max_valid};
JL_GC_PUSH5(&env.t, &env.matc, &env.match.env, &search.env, &env.match.ti);
htable_new(&env.visited, 0);
if (((jl_datatype_t*)unw)->isdispatchtuple) {
Expand Down
1 change: 0 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ struct jl_typemap_assoc {
// inputs
jl_value_t *const types;
size_t const world;
size_t const max_world_mask;
// outputs
jl_svec_t *env; // subtype env (initialize to null to perform intersection without an environment)
size_t min_valid;
Expand Down
6 changes: 2 additions & 4 deletions src/typemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ int jl_typemap_intersection_visitor(jl_typemap_t *map, int offs,
//TODO: fast-path for leaf-type tuples?
//if (ttypes->isdispatchtuple) {
// register jl_typemap_intersection_visitor_fptr fptr = closure->fptr;
// struct jl_typemap_assoc search = {(jl_value_t*)closure->type, world, 1, closure->env, 0, ~(size_t)0};
// struct jl_typemap_assoc search = {(jl_value_t*)closure->type, world, closure->env, 0, ~(size_t)0};
// jl_typemap_entry_t *ml = jl_typemap_assoc_by_type(map, search, offs, /*subtype*/1);
// if (ml) {
// closure->env = search->env;
Expand Down Expand Up @@ -483,8 +483,6 @@ static jl_typemap_entry_t *jl_typemap_entry_assoc_by_type(
// ignore method table entries that have been replaced in the current world
if (search->min_valid <= ml->max_world)
search->min_valid = ml->max_world + 1;
if (search->world <= (ml->max_world | search->max_world_mask))
return ml;
}
else {
// intersect the env valid range with method's valid range
Expand All @@ -509,7 +507,7 @@ static jl_typemap_entry_t *jl_typemap_entry_lookup_by_type(
jl_typemap_entry_t *ml, struct jl_typemap_assoc *search)
{
for (; ml != (void*)jl_nothing; ml = ml->next) {
if (search->world < ml->min_world || search->world > (ml->max_world | search->max_world_mask))
if (search->world < ml->min_world || search->world > ml->max_world)
continue;
// unroll the first few cases here, to the extent that is possible to do fast and easily
jl_value_t *types = search->types;
Expand Down

0 comments on commit e0a036e

Please sign in to comment.