Skip to content

Commit

Permalink
turn off inline_partialmatch optimization due to isa error with Tuples
Browse files Browse the repository at this point in the history
of TypeVars
  • Loading branch information
vtjnash committed Jun 9, 2014
1 parent baa1cb4 commit f8bfa2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,7 @@ function without_linenums(a::Array{Any,1})
l
end


const _pure_builtins = {tuple, tupleref, tuplelen, fieldtype, apply_type, is, isa, typeof, typeassert} # known affect-free calls (also effect-free)
const _pure_builtins_volatile = {getfield, arrayref} # known effect-free calls (might not be affect-free)

Expand Down Expand Up @@ -2047,7 +2048,7 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast)
sp = tuple(sp..., linfo.sparams...)
spvals = { sp[i] for i in 2:2:length(sp) }
for i=1:length(spvals)
if isa(spvals[i],TypeVar)
if isa(spvals[i], TypeVar)
return NF
end
if isa(spvals[i],Symbol)
Expand All @@ -2059,6 +2060,9 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast)
nm = length(methargs)
if !(atypes <: methargs)
incompletematch = true
if !inline_incompletematch_allowed
return NF
end
else
incompletematch = false
end
Expand Down Expand Up @@ -2220,7 +2224,7 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast)
argexprs2 = t.args
icall = LabelNode(label_counter(body.args)+1)
partmatch = Expr(:gotoifnot, false, icall.label)
thrw = Expr(:call, :throw, Expr(:call, Main.Base.MethodError, f, t))
thrw = Expr(:call, :throw, Expr(:call, Main.Base.MethodError, (f, :inline), t))
thrw.typ = None
end

Expand Down Expand Up @@ -2426,6 +2430,9 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast)
end
return (expr, stmts)
end
# The inlining incomplete matches optimization currently
# doesn't work on Tuples of TypeVars
const inline_incompletematch_allowed = false

inline_worthy(body, cost::Real) = true
function inline_worthy(body::Expr, cost::Real=1.0) # precondition: 0<cost
Expand Down
4 changes: 3 additions & 1 deletion src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,9 @@ DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v)
n += jl_static_show(out, ((jl_typector_t*)v)->body);
}
else if (jl_is_typevar(v)) {
n += JL_PRINTF(out, "%s", ((jl_tvar_t*)v)->name->name);
n += jl_static_show(out, ((jl_tvar_t*)v)->lb);
n += JL_PRINTF(out, "<:%s<:", ((jl_tvar_t*)v)->name->name);
n += jl_static_show(out, ((jl_tvar_t*)v)->ub);
}
else if (jl_is_module(v)) {
jl_module_t *m = (jl_module_t*)v;
Expand Down

0 comments on commit f8bfa2f

Please sign in to comment.