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

[release-0.6] help #24383 inference and load time regression #24399

Merged
merged 1 commit into from
Nov 14, 2017
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
5 changes: 4 additions & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,10 @@ function _methods_by_ftype(t::ANY, lim::Int, world::UInt, min::Array{UInt,1}, ma
end
end
if 1 < nu <= 64
return _methods_by_ftype(Any[tp...], t, length(tp), lim, [], world, min, max)
ms = _methods_by_ftype(Any[tp...], t, length(tp), lim, [], world, min, max)
if all(m->isleaftype(m[1]), ms)
return ms
end
end
# XXX: the following can return incorrect answers that the above branch would have corrected
return ccall(:jl_matching_methods, Any, (Any, Cint, Cint, UInt, Ptr{UInt}, Ptr{UInt}), t, lim, 0, world, min, max)
Expand Down
5 changes: 3 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,8 @@ static jl_datatype_t *jl_recache_type(jl_datatype_t *dt, size_t start, jl_value_
t = dt;
}
assert(t->uid != 0);
if (t == dt && v == NULL)
return t;
// delete / replace any other usages of this type in the backref list
// with the newly constructed object
size_t i = start;
Expand Down Expand Up @@ -3087,8 +3089,7 @@ static void jl_recache_types(void)
if (jl_is_datatype(o)) {
dt = (jl_datatype_t*)o;
v = dt->instance;
assert(dt->uid == -1);
t = jl_recache_type(dt, i + 2, NULL);
t = dt->uid == -1 ? jl_recache_type(dt, i + 2, NULL) : dt;
}
else {
dt = (jl_datatype_t*)jl_typeof(o);
Expand Down
4 changes: 3 additions & 1 deletion src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,9 @@ static int subtype_unionall(jl_value_t *t, jl_unionall_t *u, jl_stenv_t *e, int8
jl_value_t *oldval = e->envout[e->envidx];
// if we try to assign different variable values (due to checking
// multiple union members), consider the value unknown.
if (!oldval || !jl_is_typevar(oldval) || !jl_is_long(val))
if (oldval && !jl_egal(oldval, val))
e->envout[e->envidx] = (jl_value_t*)u->var;
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commit should probably be put on master first

e->envout[e->envidx] = val;
// TODO: substitute the value (if any) of this variable into previous envout entries
}
Expand Down
15 changes: 15 additions & 0 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -959,3 +959,18 @@ for i in 1:3
ir = sprint(io->code_llvm(io, f22290, Tuple{}))
@test contains(ir, "julia_f22290")
end

# approximate static parameters due to unions
let T1 = Array{Float64}, T2 = Array{_1,2} where _1
inference_test_copy(a::T) where {T<:Array} = ccall(:jl_array_copy, Ref{T}, (Any,), a)
rt = Base.return_types(inference_test_copy, (Union{T1,T2},))[1]
@test rt >: T1 && rt >: T2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be testing for equality to something. I know you only want to test for strongly valid properties, but as written, I can't verify that this test is testing for the reported issue. And it could also break again later without noticing that this test was later rendered ineffectual.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brokenness before was that rt >: T1 && rt >: T2 did not hold. So if it broke again the test would fail.


el(x::T) where {T} = eltype(T)
rt = Base.return_types(el, (Union{T1,Array{Float32,2}},))[1]
@test rt >: Union{Type{Float64}, Type{Float32}}

g(x::Ref{T}) where {T} = T
rt = Base.return_types(g, (Union{Ref{Array{Float64}}, Ref{Array{Float32}}},))[1]
@test rt >: Union{Type{Array{Float64}}, Type{Array{Float32}}}
end
5 changes: 5 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1149,3 +1149,8 @@ end
Int64,Float64,Int64,Float64,Int64,Float64,Int64,Float64,Int64,Float64,Int64,Float64,
Int64,Float64,Int64,Float64,Int64,Float64,Int64,Float64,Int64,Float64,Int64,Float64,
Int64,Float64,Int64,Float64,Int64,Float64,Int64,Float64} <: (Tuple{Vararg{T}} where T<:Number))

# PR #24399
let (t, e) = intersection_env(Tuple{Union{Int,Int8}}, Tuple{T} where T)
@test e[1] isa TypeVar
end