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 20, 2022
1 parent 9847f34 commit 7835a94
Showing 1 changed file with 5 additions and 9 deletions.
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, @nospecialize, @inbounds, @inline, @noinline, @label, @goto,
!, !==, !=, , +, -, , <, , >, &, |, include, error, missing, copy,
Expand Down Expand Up @@ -1258,13 +1258,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 @@ -1314,7 +1316,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 @@ -1475,10 +1477,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 @@ -1491,8 +1489,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

0 comments on commit 7835a94

Please sign in to comment.