@@ -13,7 +13,7 @@ mutable struct OptimizationState
1313 min_valid:: UInt
1414 max_valid:: UInt
1515 params:: Params
16- sp :: SimpleVector # static parameters
16+ sptypes :: Vector{Any} # static parameters
1717 slottypes:: Vector{Any}
1818 const_api:: Bool
1919 function OptimizationState (frame:: InferenceState )
@@ -27,7 +27,7 @@ mutable struct OptimizationState
2727 s_edges:: Vector{Any} ,
2828 src, frame. mod, frame. nargs,
2929 frame. min_valid, frame. max_valid,
30- frame. params, frame. sp , frame. slottypes, false )
30+ frame. params, frame. sptypes , frame. slottypes, false )
3131 end
3232 function OptimizationState (linfo:: MethodInstance , src:: CodeInfo ,
3333 params:: Params )
@@ -54,7 +54,7 @@ mutable struct OptimizationState
5454 s_edges:: Vector{Any} ,
5555 src, inmodule, nargs,
5656 min_world (linfo), max_world (linfo),
57- params, spvals_from_meth_instance (linfo), slottypes, false )
57+ params, sptypes_from_meth_instance (linfo), slottypes, false )
5858 end
5959end
6060
@@ -135,7 +135,7 @@ function isinlineable(m::Method, me::OptimizationState, bonus::Int=0)
135135 end
136136 end
137137 if ! inlineable
138- inlineable = inline_worthy (me. src. code, me. src, me. sp , me. slottypes, me. params, cost_threshold + bonus)
138+ inlineable = inline_worthy (me. src. code, me. src, me. sptypes , me. slottypes, me. params, cost_threshold + bonus)
139139 end
140140 return inlineable
141141end
@@ -148,7 +148,7 @@ function stmt_affects_purity(@nospecialize(stmt), ir)
148148 return false
149149 end
150150 if isa (stmt, GotoIfNot)
151- t = argextype (stmt. cond, ir, ir. spvals )
151+ t = argextype (stmt. cond, ir, ir. sptypes )
152152 return ! (t ⊑ Bool)
153153 end
154154 if isa (stmt, Expr)
@@ -175,7 +175,7 @@ function optimize(opt::OptimizationState, @nospecialize(result))
175175 proven_pure = true
176176 for i in 1 : length (ir. stmts)
177177 stmt = ir. stmts[i]
178- if stmt_affects_purity (stmt, ir) && ! stmt_effect_free (stmt, ir. types[i], ir, ir. spvals )
178+ if stmt_affects_purity (stmt, ir) && ! stmt_effect_free (stmt, ir. types[i], ir, ir. sptypes )
179179 proven_pure = false
180180 break
181181 end
@@ -268,19 +268,19 @@ plus_saturate(x::Int, y::Int) = max(x, y, x+y)
268268# known return type
269269isknowntype (@nospecialize T) = (T == Union{}) || isconcretetype (T)
270270
271- function statement_cost (ex:: Expr , line:: Int , src:: CodeInfo , spvals :: SimpleVector , slottypes:: Vector{Any} , params:: Params )
271+ function statement_cost (ex:: Expr , line:: Int , src:: CodeInfo , sptypes :: Vector{Any} , slottypes:: Vector{Any} , params:: Params )
272272 head = ex. head
273273 if is_meta_expr_head (head)
274274 return 0
275275 elseif head === :call
276276 farg = ex. args[1 ]
277- ftyp = argextype (farg, src, spvals , slottypes)
277+ ftyp = argextype (farg, src, sptypes , slottypes)
278278 if ftyp === IntrinsicFunction && farg isa SSAValue
279279 # if this comes from code that was already inlined into another function,
280280 # Consts have been widened. try to recover in simple cases.
281281 farg = src. code[farg. id]
282282 if isa (farg, GlobalRef) || isa (farg, QuoteNode) || isa (farg, IntrinsicFunction) || isexpr (farg, :static_parameter )
283- ftyp = argextype (farg, src, spvals , slottypes)
283+ ftyp = argextype (farg, src, sptypes , slottypes)
284284 end
285285 end
286286 f = singleton_type (ftyp)
@@ -302,7 +302,7 @@ function statement_cost(ex::Expr, line::Int, src::CodeInfo, spvals::SimpleVector
302302 # return plus_saturate(argcost, isknowntype(extyp) ? 1 : params.inline_nonleaf_penalty)
303303 return 0
304304 elseif f === Main. Core. arrayref && length (ex. args) >= 3
305- atyp = argextype (ex. args[3 ], src, spvals , slottypes)
305+ atyp = argextype (ex. args[3 ], src, sptypes , slottypes)
306306 return isknowntype (atyp) ? 4 : params. inline_nonleaf_penalty
307307 end
308308 fidx = find_tfunc (f)
@@ -325,7 +325,7 @@ function statement_cost(ex::Expr, line::Int, src::CodeInfo, spvals::SimpleVector
325325 elseif head === :return
326326 a = ex. args[1 ]
327327 if a isa Expr
328- return statement_cost (a, - 1 , src, spvals , slottypes, params)
328+ return statement_cost (a, - 1 , src, sptypes , slottypes, params)
329329 end
330330 return 0
331331 elseif head === :(= )
@@ -336,7 +336,7 @@ function statement_cost(ex::Expr, line::Int, src::CodeInfo, spvals::SimpleVector
336336 end
337337 a = ex. args[2 ]
338338 if a isa Expr
339- cost = plus_saturate (cost, statement_cost (a, - 1 , src, spvals , slottypes, params))
339+ cost = plus_saturate (cost, statement_cost (a, - 1 , src, sptypes , slottypes, params))
340340 end
341341 return cost
342342 elseif head === :copyast
@@ -357,13 +357,13 @@ function statement_cost(ex::Expr, line::Int, src::CodeInfo, spvals::SimpleVector
357357 return 0
358358end
359359
360- function inline_worthy (body:: Array{Any,1} , src:: CodeInfo , spvals :: SimpleVector , slottypes:: Vector{Any} ,
360+ function inline_worthy (body:: Array{Any,1} , src:: CodeInfo , sptypes :: Vector{Any} , slottypes:: Vector{Any} ,
361361 params:: Params , cost_threshold:: Integer = params. inline_cost_threshold)
362362 bodycost:: Int = 0
363363 for line = 1 : length (body)
364364 stmt = body[line]
365365 if stmt isa Expr
366- thiscost = statement_cost (stmt, line, src, spvals , slottypes, params):: Int
366+ thiscost = statement_cost (stmt, line, src, sptypes , slottypes, params):: Int
367367 elseif stmt isa GotoNode
368368 # loops are generally always expensive
369369 # but assume that forward jumps are already counted for from
@@ -378,11 +378,11 @@ function inline_worthy(body::Array{Any,1}, src::CodeInfo, spvals::SimpleVector,
378378 return true
379379end
380380
381- function is_known_call (e:: Expr , @nospecialize (func), src, spvals :: SimpleVector , slottypes:: Vector{Any} = empty_slottypes)
381+ function is_known_call (e:: Expr , @nospecialize (func), src, sptypes :: Vector{Any} , slottypes:: Vector{Any} = empty_slottypes)
382382 if e. head != = :call
383383 return false
384384 end
385- f = argextype (e. args[1 ], src, spvals , slottypes)
385+ f = argextype (e. args[1 ], src, sptypes , slottypes)
386386 return isa (f, Const) && f. val === func
387387end
388388
0 commit comments