Skip to content

Commit

Permalink
fix logic in getfield_nothrow to allow removing more getfields
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and Keno committed Sep 8, 2018
1 parent a572504 commit 42e8920
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,10 @@ function getfield_nothrow(@nospecialize(s00), @nospecialize(name), @nospecialize
sv = s00.val
end
if isa(name, Const)
(isa(sv, Module) && isa(name.val, Symbol)) || return false
(isa(name.val, Symbol) || isa(name.val, Int)) || return false
if !isa(name.val, Symbol)
isa(sv, Module) && return false
isa(name.val, Int) || return false
end
return isdefined(sv, name.val)
end
if bounds_check_disabled && !isa(sv, Module)
Expand Down
4 changes: 4 additions & 0 deletions test/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ end
(src, _) = code_typed(sum27403, Tuple{Vector{Int}})[1]
@test !any(x -> x isa Expr && x.head === :invoke, src.code)
end

# check that type.mutable can be fully eliminated
f_mutable_nothrow(s::String) = Val{typeof(s).mutable}
@test length(code_typed(f_mutable_nothrow, (String,))[1][1].code) == 1

0 comments on commit 42e8920

Please sign in to comment.