Skip to content

Commit

Permalink
delete false pretense of support of max_world on a Method
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Apr 11, 2017
1 parent 7b16106 commit a529199
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 27 deletions.
2 changes: 1 addition & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2391,7 +2391,7 @@ function finalize_backedges(frame::InferenceState)
end

function code_for_method(method::Method, atypes::ANY, sparams::SimpleVector, world::UInt, preexisting::Bool=false)
if world < min_world(method) || world > max_world(method)
if world < min_world(method)
return nothing
end
if method.isstaged && !isleaftype(atypes)
Expand Down
2 changes: 1 addition & 1 deletion base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end

function kwarg_decl(m::Method, kwtype::DataType)
sig = rewrap_unionall(Tuple{kwtype, Core.AnyVector, unwrap_unionall(m.sig).parameters...}, m.sig)
kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, max_world(m))
kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, typemax(UInt))
if kwli !== nothing
kwli = kwli::Method
src = uncompressed_ast(kwli, kwli.source)
Expand Down
2 changes: 1 addition & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,6 @@ has_bottom_parameter(t::TypeVar) = has_bottom_parameter(t.ub)
has_bottom_parameter(::Any) = false

min_world(m::Method) = reinterpret(UInt, m.min_world)
max_world(m::Method) = reinterpret(UInt, m.max_world)
max_world(m::Method) = typemax(UInt)
min_world(m::Core.MethodInstance) = reinterpret(UInt, m.min_world)
max_world(m::Core.MethodInstance) = reinterpret(UInt, m.max_world)
3 changes: 0 additions & 3 deletions base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,6 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs::Vector=Any[])
if ex.world < min_world(method)
print(buf, " (method too new to be called from this world context.)")
end
if ex.world > max_world(method)
print(buf, " (method deleted before this world age.)")
end
# TODO: indicate if it's in the wrong world
push!(lines, (buf, right_matches))
end
Expand Down
7 changes: 0 additions & 7 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,6 @@ static void jl_serialize_value_(jl_serializer_state *s, jl_value_t *v, int as_li
write_int32(s->s, m->line);
if (s->mode != MODE_MODULE) {
write_int32(s->s, m->min_world);
write_int32(s->s, m->max_world);
}
else {
assert(m->max_world == ~(size_t)0 && "method replacement cannot be handled by incremental serializer");
}
if (external_mt)
jl_serialize_value(s, jl_nothing);
Expand Down Expand Up @@ -1667,11 +1663,9 @@ static jl_value_t *jl_deserialize_value_method(jl_serializer_state *s, jl_value_
m->line = read_int32(s->s);
if (s->mode != MODE_MODULE) {
m->min_world = read_int32(s->s);
m->max_world = read_int32(s->s);
}
else {
m->min_world = jl_world_counter;
m->max_world = ~(size_t)0;
}
m->ambig = jl_deserialize_value(s, (jl_value_t**)&m->ambig);
jl_gc_wb(m, m->ambig);
Expand Down Expand Up @@ -2204,7 +2198,6 @@ static jl_value_t *read_verify_mod_list(ios_t *s)
"Requiring \"%s\" did not define a corresponding module.", name);
}
if (!jl_is_module(m)) {
ios_close(s);
return jl_get_exceptionf(jl_errorexception_type,
"Invalid module path (%s does not name a module).", name);
}
Expand Down
11 changes: 5 additions & 6 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int8_t jl_cachearg_offset(jl_methtable_t *mt)
// get or create the MethodInstance for a specialization
JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m, jl_value_t *type, jl_svec_t *sparams, size_t world)
{
assert(world >= m->min_world && world <= m->max_world && "typemap lookup is corrupted");
assert(world >= m->min_world && "typemap lookup is corrupted");
JL_LOCK(&m->writelock);
jl_typemap_entry_t *sf =
jl_typemap_assoc_by_type(m->specializations, (jl_tupletype_t*)type, NULL, 1, /*subtype*/0, /*offs*/0, world);
Expand All @@ -163,8 +163,7 @@ JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m,
li->min_world = world;
}
if (world == jl_world_counter) {
assert(m->max_world == ~(size_t)0 && "method validity shouldn't be scheduled to terminate at a fixed future age");
li->max_world = m->max_world;
li->max_world = ~(size_t)0;
}
else {
li->max_world = world;
Expand Down Expand Up @@ -350,7 +349,7 @@ JL_DLLEXPORT jl_method_instance_t* jl_set_method_inferred(
}
else {
JL_LOCK(&li->def->writelock);
assert(min_world >= li->def->min_world && max_world <= li->def->max_world);
assert(min_world >= li->def->min_world);
int isinferred = jl_is_rettype_inferred(li);
if (!isinferred && li->min_world >= min_world && li->max_world <= max_world) {
// expand the current (uninferred) entry to cover the full inferred range
Expand Down Expand Up @@ -917,7 +916,7 @@ static jl_method_instance_t *cache_method(jl_methtable_t *mt, union jl_typemap_t
}

size_t min_valid = definition->min_world;
size_t max_valid = definition->max_world;
size_t max_valid = ~(size_t)0;
int cache_with_orig = 0;
jl_svec_t* guardsigs = jl_emptysvec;
jl_tupletype_t *origtype = type; // backup the prior value of `type`
Expand Down Expand Up @@ -1375,7 +1374,7 @@ JL_DLLEXPORT void jl_method_table_insert(jl_methtable_t *mt, jl_method_t *method
JL_LOCK(&mt->writelock);
jl_typemap_entry_t *newentry = jl_typemap_insert(&mt->defs, (jl_value_t*)mt,
(jl_tupletype_t*)type, simpletype, jl_emptysvec, (jl_value_t*)method, 0, &method_defs,
method->min_world, method->max_world, &oldvalue);
method->min_world, ~(size_t)0, &oldvalue);
if (oldvalue) {
method->ambig = ((jl_method_t*)oldvalue)->ambig;
method_overwrite(newentry, (jl_method_t*)oldvalue);
Expand Down
8 changes: 3 additions & 5 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1882,14 +1882,13 @@ void jl_init_types(void)
jl_method_type =
jl_new_datatype(jl_symbol("Method"),
jl_any_type, jl_emptysvec,
jl_svec(20,
jl_svec(19,
jl_symbol("name"),
jl_symbol("module"),
jl_symbol("file"),
jl_symbol("line"),
jl_symbol("sig"),
jl_symbol("min_world"),
jl_symbol("max_world"),
jl_symbol("ambig"),
jl_symbol("specializations"),
jl_symbol("sparam_syms"),
Expand All @@ -1903,14 +1902,13 @@ void jl_init_types(void)
jl_symbol("isva"),
jl_symbol("isstaged"),
jl_symbol("pure")),
jl_svec(20,
jl_svec(19,
jl_sym_type,
jl_module_type,
jl_sym_type,
jl_int32_type,
jl_type_type,
jl_long_type,
jl_long_type,
jl_any_type, // Union{Array, Void}
jl_any_type, // TypeMap
jl_simplevector_type,
Expand All @@ -1924,7 +1922,7 @@ void jl_init_types(void)
jl_bool_type,
jl_bool_type,
jl_bool_type),
0, 1, 10);
0, 1, 9);

jl_method_instance_type =
jl_new_datatype(jl_symbol("MethodInstance"),
Expand Down
1 change: 0 additions & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ typedef struct _jl_method_t {
// method's type signature. redundant with TypeMapEntry->specTypes
jl_value_t *sig;
size_t min_world;
size_t max_world;

// list of potentially-ambiguous methods (nothing = none, Vector{Any} of Methods otherwise)
jl_value_t *ambig;
Expand Down
3 changes: 1 addition & 2 deletions src/method.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ jl_method_instance_t *jl_get_specialized(jl_method_t *m, jl_value_t *types, jl_s
new_linfo->specTypes = types;
new_linfo->sparam_vals = sp;
new_linfo->min_world = m->min_world;
new_linfo->max_world = m->max_world;
new_linfo->max_world = ~(size_t)0;
return new_linfo;
}

Expand Down Expand Up @@ -435,7 +435,6 @@ JL_DLLEXPORT jl_method_t *jl_new_method_uninit(void)
m->nargs = 0;
m->traced = 0;
m->min_world = 1;
m->max_world = ~(size_t)0;
JL_MUTEX_INIT(&m->writelock);
return m;
}
Expand Down

0 comments on commit a529199

Please sign in to comment.