Skip to content

Commit

Permalink
update with JuliaLang/julia#42465
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jan 12, 2022
1 parent dd0ec5b commit ff0cf70
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/EscapeAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,8 @@ function escape_builtin!(::typeof(setfield!), astate::AnalysisState, pc::Int, ar
return true
end

const Arrayish = Union{Array,Core.ImmutableArray}

function escape_builtin!(::typeof(arrayref), astate::AnalysisState, pc::Int, args::Vector{Any})
length(args) 4 || return false
# check potential escapes from this arrayref call
Expand All @@ -1074,7 +1076,7 @@ function escape_builtin!(::typeof(arrayref), astate::AnalysisState, pc::Int, arg
argtypes = Any[argextype(args[i], astate.ir) for i in 2:length(args)]
boundcheckt = argtypes[1]
aryt = argtypes[2]
if !array_builtin_common_typecheck(boundcheckt, aryt, argtypes, 3)
if !array_builtin_common_typecheck(Arrayish, boundcheckt, aryt, argtypes, 3)
add_thrown_escapes!(astate, pc, args, 2)
end
# we don't track precise index information about this array and thus don't know what values
Expand Down Expand Up @@ -1138,7 +1140,7 @@ function escape_builtin!(::typeof(arrayset), astate::AnalysisState, pc::Int, arg
boundcheckt = argtypes[1]
aryt = argtypes[2]
valt = argtypes[3]
if !(array_builtin_common_typecheck(boundcheckt, aryt, argtypes, 4) &&
if !(array_builtin_common_typecheck(Array, boundcheckt, aryt, argtypes, 4) &&
arrayset_typecheck(aryt, valt))
add_thrown_escapes!(astate, pc, args, 2)
end
Expand Down Expand Up @@ -1321,22 +1323,20 @@ end
# return true
# end

if isdefined(Core, :arrayfreeze) && isdefined(Core, :arraythaw) && isdefined(Core, :mutating_arrayfreeze)
import Core: ImmutableArray, arrayfreeze, mutating_arrayfreeze, arraythaw

escape_builtin!(::typeof(Core.arrayfreeze), astate::AnalysisState, pc::Int, args::Vector{Any}) =
escape_builtin!(::typeof(arrayfreeze), astate::AnalysisState, pc::Int, args::Vector{Any}) =
escape_immutable_array!(Array, astate, pc, args)
escape_builtin!(::typeof(Core.mutating_arrayfreeze), astate::AnalysisState, pc::Int, args::Vector{Any}) =
escape_builtin!(::typeof(mutating_arrayfreeze), astate::AnalysisState, pc::Int, args::Vector{Any}) =
escape_immutable_array!(Array, astate, pc, args)
escape_builtin!(::typeof(Core.arraythaw), astate::AnalysisState, pc::Int, args::Vector{Any}) =
escape_immutable_array!(Core.ImmutableArray, astate, pc, args)
escape_builtin!(::typeof(arraythaw), astate::AnalysisState, pc::Int, args::Vector{Any}) =
escape_immutable_array!(ImmutableArray, astate, pc, args)
function escape_immutable_array!(@nospecialize(arytype), astate::AnalysisState, pc::Int, args::Vector{Any})
length(args) == 2 || return false
argextype(args[2], astate.ir) ₜ arytype || return false
return true
end

end # if isdefined(Core, :arrayfreeze) && isdefined(Core, :arraythaw) && isdefined(Core, :mutating_arrayfreeze)

# NOTE define fancy package utilities when developing EA as an external package
if _TOP_MOD !== Core.Compiler
include(@__MODULE__, "utils.jl")
Expand Down

0 comments on commit ff0cf70

Please sign in to comment.