Skip to content

Commit

Permalink
improve various inferrabilities, fix some errors (#40463)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Apr 14, 2021
1 parent 8ecb306 commit 5e93c29
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 24 deletions.
11 changes: 6 additions & 5 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ function compileable_specialization(et::Union{EdgeTracker, Nothing}, match::Meth
end

function compileable_specialization(et::Union{EdgeTracker, Nothing}, result::InferenceResult)
mi = specialize_method(result.linfo.def, result.linfo.specTypes,
mi = specialize_method(result.linfo.def::Method, result.linfo.specTypes,
result.linfo.sparam_vals, false, true)
mi !== nothing && et !== nothing && push!(et, mi::MethodInstance)
return mi
Expand Down Expand Up @@ -746,8 +746,10 @@ function resolve_todo(todo::InliningTodo, state::InliningState)
end
end

if isconst && state.et !== nothing
push!(state.et, todo.mi)
et = state.et

if isconst && et !== nothing
push!(et, todo.mi)
return ConstantCase(src)
end

Expand All @@ -756,14 +758,13 @@ function resolve_todo(todo::InliningTodo, state::InliningState)
end

if src === nothing
return compileable_specialization(state.et, spec.match)
return compileable_specialization(et, spec.match)
end

if isa(src, IRCode)
src = copy(src)
end

et = state.et
et !== nothing && push!(et, todo.mi)
return InliningTodo(todo.mi, src)
end
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function verify_ir(ir::IRCode, print::Bool=true)
end
elseif isexpr(terminator, :enter)
@label enter_check
if length(block.succs) != 2 || (block.succs != [terminator.args[1], idx+1] && block.succs != [idx+1, terminator.args[1]])
if length(block.succs) != 2 || (block.succs != Int[terminator.args[1], idx+1] && block.succs != Int[idx+1, terminator.args[1]])
@verify_error "Block $idx successors ($(block.succs)), does not match :enter terminator"
error("")
end
Expand Down
12 changes: 7 additions & 5 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ function firstcaller(bt::Vector, funcsyms)
end
found = lkup.func in funcsyms
# look for constructor type name
if !found && lkup.linfo isa Core.MethodInstance
if !found
li = lkup.linfo
ft = ccall(:jl_first_argument_datatype, Any, (Any,), li.def.sig)
if isa(ft, DataType) && ft.name === Type.body.name
ft = unwrap_unionall(ft.parameters[1])
found = (isa(ft, DataType) && ft.name.name in funcsyms)
if li isa Core.MethodInstance
ft = ccall(:jl_first_argument_datatype, Any, (Any,), (li.def::Method).sig)
if isa(ft, DataType) && ft.name === Type.body.name
ft = unwrap_unionall(ft.parameters[1])
found = (isa(ft, DataType) && ft.name.name in funcsyms)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ See also: [`first`](@ref), [`last`](@ref).
@boundscheck if i === nothing
throw(ArgumentError("Collection is empty, must contain exactly 1 element"))
end
(ret, state) = i
(ret, state) = i::NTuple{2,Any}
@boundscheck if iterate(x, state) !== nothing
throw(ArgumentError("Collection has multiple elements, must contain exactly 1 element"))
end
Expand Down
8 changes: 5 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ function pathof(m::Module)
pkgid === nothing && return nothing
origin = get(Base.pkgorigins, pkgid, nothing)
origin === nothing && return nothing
origin.path === nothing && return nothing
return fixup_stdlib_path(origin.path)
path = origin.path
path === nothing && return nothing
return fixup_stdlib_path(path)
end

"""
Expand Down Expand Up @@ -563,7 +564,8 @@ function explicit_manifest_entry_path(manifest_file::String, pkg::PkgId, entry::
hash === nothing && return nothing
hash = SHA1(hash)
# Keep the 4 since it used to be the default
for slug in (version_slug(pkg.uuid, hash, 4), version_slug(pkg.uuid, hash))
uuid = pkg.uuid::UUID # checked within `explicit_manifest_uuid_path`
for slug in (version_slug(uuid, hash, 4), version_slug(uuid, hash))
for depot in DEPOT_PATH
path = abspath(depot, "packages", pkg.name, slug)
ispath(path) && return path
Expand Down
2 changes: 1 addition & 1 deletion base/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ isempty(s::AbstractString) = iszero(ncodeunits(s)::Int)

function getindex(s::AbstractString, i::Integer)
@boundscheck checkbounds(s, i)
@inbounds return isvalid(s, i) ? iterate(s, i)[1] : string_index_err(s, i)
@inbounds return isvalid(s, i) ? (iterate(s, i)::NTuple{2,Any})[1] : string_index_err(s, i)
end

getindex(s::AbstractString, i::Colon) = s
Expand Down
4 changes: 2 additions & 2 deletions base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ function hex2bytes!(dest::AbstractArray{UInt8}, itr)

next = iterate(itr)
@inbounds for i in eachindex(dest)
x,state = next
y,state = iterate(itr, state)
x,state = next::NTuple{2,Any}
y,state = iterate(itr, state)::NTuple{2,Any}
next = iterate(itr, state)
dest[i] = number_from_hex(x) << 4 + number_from_hex(y)
end
Expand Down
2 changes: 1 addition & 1 deletion base/toml_parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ function Base.showerror(io::IO, err::ParserError)
printstyled(io, " error: "; color=Base.error_color())
println(io, format_error_message_for_err_type(err))
# In this case we want the arrow to point one character
pos = err.pos
pos = err.pos::Int
err.type == ErrUnexpectedEofExpectedValue && (pos += 1)
str1, err1 = point_to_line(err.str, pos, pos, io)
@static if VERSION <= v"1.6.0-DEV.121"
Expand Down
2 changes: 1 addition & 1 deletion base/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function tryparse(::Type{VersionNumber}, v::AbstractString)
m = match(VERSION_REGEX, v)
m === nothing && return nothing
major, minor, patch, minus, prerl, plus, build = m.captures
major = parse(VInt, major)
major = parse(VInt, major::AbstractString)
minor = minor !== nothing ? parse(VInt, minor) : VInt(0)
patch = patch !== nothing ? parse(VInt, patch) : VInt(0)
if prerl !== nothing && !isempty(prerl) && prerl[1] == '-'
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function check_worker_state(w::Worker)
end
end

exec_conn_func(id::Int) = exec_conn_func(worker_from_id(id))
exec_conn_func(id::Int) = exec_conn_func(worker_from_id(id)::Worker)
function exec_conn_func(w::Worker)
try
f = notnothing(w.conn_func)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Distributed/src/remotecall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function send_del_client(rr)
if rr.where == myid()
del_client(rr)
elseif id_in_procs(rr.where) # process only if a valid worker
w = worker_from_id(rr.where)
w = worker_from_id(rr.where)::Worker
push!(w.del_msgs, (remoteref_id(rr), myid()))
w.gcflag = true
notify(any_gc_flag)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LibGit2/src/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ function last_error()
return (err_class, err_msg)
end

function GitError(code::Integer)
err_code = Code(code)
GitError(err_code::Integer) = GitError(Code(err_code))
function GitError(err_code::Code)
err_class, err_msg = last_error()
return GitError(err_class, err_code, err_msg)
end
Expand Down

2 comments on commit 5e93c29

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

Please sign in to comment.