Skip to content

Commit f716b40

Browse files
authored
Merge pull request #32776 from JuliaLang/jn/typemap-unsorting
TypeMap: Cease trying to guarantee sorting
2 parents f32811d + 39c81e8 commit f716b40

17 files changed

+550
-383
lines changed

base/baseext.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# hook up VecElement constructor to Base.convert
66
VecElement{T}(arg) where {T} = VecElement{T}(convert(T, arg))
7-
convert(::Type{T}, arg) where {T<:VecElement} = T(arg)
87
convert(::Type{T}, arg::T) where {T<:VecElement} = arg
8+
convert(::Type{T}, arg) where {T<:VecElement} = T(arg)
99

1010
# ## dims-type-converting Array constructors for convenience
1111
# type and dimensionality specified, accepting dims as series of Integers

base/compiler/ssair/inlining.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ function compute_invoke_data(@nospecialize(atypes), params::Params)
11301130
invoke_entry = ccall(:jl_gf_invoke_lookup, Any, (Any, UInt),
11311131
invoke_types, params.world) # XXX: min_valid, max_valid
11321132
invoke_entry === nothing && return nothing
1133-
invoke_data = InvokeData(invoke_entry, invoke_types, min_valid[1], max_valid[1])
1133+
invoke_data = InvokeData(invoke_entry::Core.TypeMapEntry, invoke_types, min_valid[1], max_valid[1])
11341134
atype0 = atypes[2]
11351135
atypes = atypes[4:end]
11361136
pushfirst!(atypes, atype0)

base/missing.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ function promote_rule(T::Type{>:Missing}, S::Type)
6464
return Union{R, Missing}
6565
end
6666

67-
convert(T::Type{>:Union{Missing, Nothing}}, x) = convert(nonmissingtype_checked(nonnothingtype_checked(T)), x)
68-
convert(T::Type{>:Missing}, x) = convert(nonmissingtype_checked(T), x)
67+
convert(::Type{T}, x::T) where {T>:Missing} = x
68+
convert(::Type{T}, x::T) where {T>:Union{Missing, Nothing}} = x
69+
convert(::Type{T}, x) where {T>:Missing} = convert(nonmissingtype_checked(T), x)
70+
convert(::Type{T}, x) where {T>:Union{Missing, Nothing}} = convert(nonmissingtype_checked(nonnothingtype_checked(T)), x)
6971

7072

7173
# Comparison operators

base/reflection.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -1289,16 +1289,16 @@ end
12891289
12901290
Determine whether `t` is a Type for which one or more of its parameters is `Union{}`.
12911291
"""
1292-
function has_bottom_parameter(t::Type)
1293-
ret = false
1292+
function has_bottom_parameter(t::DataType)
12941293
for p in t.parameters
1295-
ret |= (p == Bottom) || has_bottom_parameter(p)
1294+
has_bottom_parameter(p) && return true
12961295
end
1297-
ret
1296+
return false
12981297
end
1298+
has_bottom_parameter(t::typeof(Bottom)) = true
12991299
has_bottom_parameter(t::UnionAll) = has_bottom_parameter(unwrap_unionall(t))
13001300
has_bottom_parameter(t::Union) = has_bottom_parameter(t.a) & has_bottom_parameter(t.b)
1301-
has_bottom_parameter(t::TypeVar) = t.ub == Bottom || has_bottom_parameter(t.ub)
1301+
has_bottom_parameter(t::TypeVar) = has_bottom_parameter(t.ub)
13021302
has_bottom_parameter(::Any) = false
13031303

13041304
min_world(m::Core.CodeInstance) = m.min_world

base/some.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ function nonnothingtype_checked(T::Type)
3030
return R
3131
end
3232

33-
convert(T::Type{>:Nothing}, x) = convert(nonnothingtype_checked(T), x)
33+
convert(::Type{T}, x::T) where {T>:Nothing} = x
34+
convert(::Type{T}, x) where {T>:Nothing} = convert(nonnothingtype_checked(T), x)
3435
convert(::Type{Some{T}}, x::Some{T}) where {T} = x
3536
convert(::Type{Some{T}}, x::Some) where {T} = Some{T}(convert(T, x.value))
3637

doc/src/manual/methods.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ julia> g(2, 3.0)
243243
244244
julia> g(2.0, 3.0)
245245
ERROR: MethodError: g(::Float64, ::Float64) is ambiguous. Candidates:
246-
g(x, y::Float64) in Main at none:1
247246
g(x::Float64, y) in Main at none:1
247+
g(x, y::Float64) in Main at none:1
248248
Possible fix, define
249249
g(::Float64, ::Float64)
250250
```

src/codegen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5069,7 +5069,7 @@ static Function *jl_cfunction_object(jl_value_t *ff, jl_value_t *declrt, jl_tupl
50695069
if (!insert)
50705070
insert = jl_nothing;
50715071
cache_l3 = jl_typemap_insert(&insert, (jl_value_t*)insert, (jl_tupletype_t*)argt,
5072-
NULL, jl_emptysvec, (jl_value_t*)jl_emptysvec, /*offs*/0, &cfunction_cache, 1, ~(size_t)0, NULL);
5072+
NULL, jl_emptysvec, (jl_value_t*)jl_emptysvec, /*offs*/0, &cfunction_cache, 1, ~(size_t)0);
50735073
if (insert != cache_l2)
50745074
jl_cfunction_list = jl_eqtable_put(jl_cfunction_list, ft, insert, NULL);
50755075
}

src/dump.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,14 @@ static void jl_serialize_value_(jl_serializer_state *s, jl_value_t *v, int as_li
810810
jl_serialize_value(s, (jl_value_t*)m->name);
811811
jl_serialize_value(s, (jl_value_t*)m->file);
812812
write_int32(s->s, m->line);
813-
if (external_mt)
813+
if (external_mt) {
814814
jl_serialize_value(s, jl_nothing);
815-
else
815+
jl_serialize_value(s, jl_nothing);
816+
}
817+
else {
816818
jl_serialize_value(s, (jl_value_t*)m->ambig);
819+
jl_serialize_value(s, (jl_value_t*)m->resorted);
820+
}
817821
write_int32(s->s, m->called);
818822
write_int32(s->s, m->nargs);
819823
write_int32(s->s, m->nospecialize);
@@ -1683,6 +1687,8 @@ static jl_value_t *jl_deserialize_value_method(jl_serializer_state *s, jl_value_
16831687
m->deleted_world = ~(size_t)0;
16841688
m->ambig = jl_deserialize_value(s, (jl_value_t**)&m->ambig);
16851689
jl_gc_wb(m, m->ambig);
1690+
m->resorted = jl_deserialize_value(s, (jl_value_t**)&m->resorted);
1691+
jl_gc_wb(m, m->resorted);
16861692
m->called = read_int32(s->s);
16871693
m->nargs = read_int32(s->s);
16881694
m->nospecialize = read_int32(s->s);
@@ -2805,7 +2811,8 @@ JL_DLLEXPORT int jl_save_incremental(const char *fname, jl_array_t *worklist)
28052811
for (i = 0; i < len; i++) {
28062812
jl_module_t *m = (jl_module_t*)jl_array_ptr_ref(mod_array, i);
28072813
assert(jl_is_module(m));
2808-
jl_collect_lambdas_from_mod(lambdas, m);
2814+
if (m->parent == m) // some toplevel modules (really just Base) aren't actually
2815+
jl_collect_lambdas_from_mod(lambdas, m);
28092816
}
28102817
jl_collect_methtable_from_mod(lambdas, jl_type_type_mt);
28112818
jl_collect_missing_backedges_to_mod(jl_type_type_mt);

0 commit comments

Comments
 (0)