@@ -174,25 +174,6 @@ const TOP_TUPLE = GlobalRef(Core, :tuple)
174
174
175
175
_topmod (sv:: OptimizationState ) = _topmod (sv. mod)
176
176
177
- function isinlineable (m:: Method , me:: OptimizationState , params:: OptimizationParams , union_penalties:: Bool , bonus:: Int = 0 )
178
- # compute the cost (size) of inlining this code
179
- cost_threshold = params. inline_cost_threshold
180
- if m. module === _topmod (m. module)
181
- # a few functions get special treatment
182
- name = m. name
183
- sig = m. sig
184
- if ((name === :+ || name === :* || name === :min || name === :max ) &&
185
- isa (sig,DataType) &&
186
- sig === Tuple{sig. parameters[1 ],Any,Any,Any,Vararg{Any}})
187
- return true
188
- elseif (name === :iterate || name === :unsafe_convert ||
189
- name === :cconvert )
190
- cost_threshold *= 4
191
- end
192
- end
193
- return inline_worthy (me. ir:: IRCode , params, union_penalties, cost_threshold + bonus)
194
- end
195
-
196
177
is_stmt_inline (stmt_flag:: UInt8 ) = stmt_flag & IR_FLAG_INLINE ≠ 0
197
178
is_stmt_noinline (stmt_flag:: UInt8 ) = stmt_flag & IR_FLAG_NOINLINE ≠ 0
198
179
is_stmt_throw_block (stmt_flag:: UInt8 ) = stmt_flag & IR_FLAG_THROW_BLOCK ≠ 0
@@ -292,19 +273,27 @@ function finish(interp::AbstractInterpreter, opt::OptimizationState, params::Opt
292
273
if src. inlineable && isdispatchtuple (specTypes)
293
274
# obey @inline declaration if a dispatch barrier would not help
294
275
else
295
- bonus = 0
276
+ # compute the cost (size) of inlining this code
277
+ cost_threshold = default = params. inline_cost_threshold
296
278
if result ⊑ Tuple && ! isconcretetype (widenconst (result))
297
- bonus = params. inline_tupleret_bonus
279
+ cost_threshold + = params. inline_tupleret_bonus
298
280
end
281
+ # if the method is declared as `@inline`, increase the cost threshold 20x
299
282
if src. inlineable
300
- # For functions declared @inline, increase the cost threshold 20x
301
- bonus += params. inline_cost_threshold* 19
283
+ cost_threshold += 19 * default
302
284
end
303
- src. inlineable = isinlineable (def, opt, params, union_penalties, bonus)
285
+ # a few functions get special treatment
286
+ if def. module === _topmod (def. module)
287
+ name = def. name
288
+ if name === :iterate || name === :unsafe_convert || name === :cconvert
289
+ cost_threshold += 4 * default
290
+ end
291
+ end
292
+ src. inlineable = inline_worthy (ir, params, union_penalties, cost_threshold)
304
293
end
305
294
end
306
295
307
- nothing
296
+ return nothing
308
297
end
309
298
310
299
# run the optimization work
0 commit comments