From 7835a941a002203cbc15e2b818c2ec7325d85180 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sun, 9 Jan 2022 17:36:49 +0900 Subject: [PATCH] update with https://github.com/JuliaLang/julia/pull/42465 --- src/EscapeAnalysis.jl | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/EscapeAnalysis.jl b/src/EscapeAnalysis.jl index e3c3045..fe9109e 100644 --- a/src/EscapeAnalysis.jl +++ b/src/EscapeAnalysis.jl @@ -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, @@ -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] @@ -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 @@ -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}) = @@ -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")