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

Ignore line number node when counting expressions for inlining #13553

Merged
merged 1 commit into from
Oct 14, 2015
Merged
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: 11 additions & 3 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,7 @@ end
function occurs_more(e::ANY, pred, n)
if isa(e,Expr)
e = e::Expr
e.head === :line && return 0
c = 0
for a = e.args
c += occurs_more(a, pred, n)
Expand Down Expand Up @@ -2620,10 +2621,17 @@ function inline_worthy(body::Expr, cost::Integer=1000) # precondition: 0 < cost;
return false
end
symlim = 1000 + 5_000_000 ÷ cost
if length(body.args) < (symlim + 500) ÷ 1000
nargs = 0
for arg in body.args
if (!isa(arg, LineNumberNode) &&
!(isa(arg, Expr) && (arg::Expr).head === :line))
nargs += 1
end
end
if nargs < (symlim + 500) ÷ 1000
symlim *= 16
symlim ÷= 1000
if occurs_more(body, e->true, symlim) < symlim
if occurs_more(body, e->(!isa(e, LineNumberNode)), symlim) < symlim
return true
end
end
Expand Down Expand Up @@ -2661,7 +2669,7 @@ end
const corenumtype = Union{Int32,Int64,Float32,Float64}

function inlining_pass(e::Expr, sv, ast)
if e.head == :method
if e.head === :method
# avoid running the inlining pass on function definitions
return (e,())
end
Expand Down