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

update with https://github.com/JuliaLang/julia/pull/42465 #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 5 additions & 9 deletions src/EscapeAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ._TOP_MOD: ==, getindex, setindex!
import Core:
MethodInstance, Const, Argument, SSAValue, PiNode, PhiNode, UpsilonNode, PhiCNode,
ReturnNode, GotoNode, GotoIfNot, SimpleVector, sizeof, ifelse, arrayset, arrayref,
arraysize
arraysize, ImmutableArray, arrayfreeze, mutating_arrayfreeze, arraythaw
import ._TOP_MOD: # Base definitions
@__MODULE__, @eval, @assert, @specialize, @nospecialize, @inbounds, @inline, @noinline,
@label, @goto, !, !==, !=, ≠, +, -, ≤, <, ≥, >, &, |, include, error, missing, copy,
Expand Down Expand Up @@ -1364,13 +1364,15 @@ 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 thrown escapes from this arrayref call
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
ary = args[3]
Expand Down Expand Up @@ -1419,7 +1421,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 @@ -1574,10 +1576,6 @@ end
# return true
# end

if isdefined(Core, :ImmutableArray)

import Core: ImmutableArray, arrayfreeze, mutating_arrayfreeze, arraythaw

escape_builtin!(::typeof(arrayfreeze), astate::AnalysisState, pc::Int, args::Vector{Any}) =
is_safe_immutable_array_op(Array, astate, args)
escape_builtin!(::typeof(mutating_arrayfreeze), astate::AnalysisState, pc::Int, args::Vector{Any}) =
Expand All @@ -1590,8 +1588,6 @@ function is_safe_immutable_array_op(@nospecialize(arytype), astate::AnalysisStat
return true
end

end # if isdefined(Core, :ImmutableArray)

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