Skip to content

Commit

Permalink
remove the ability for codegen to compute specialized call sites
Browse files Browse the repository at this point in the history
fix #16201
  • Loading branch information
vtjnash committed Jun 2, 2016
1 parent d64eebc commit f3f418a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 43 deletions.
39 changes: 0 additions & 39 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2760,45 +2760,6 @@ static jl_cgval_t emit_call(jl_expr_t *ex, jl_codectx_t *ctx)
}
}

if (ctx->linfo->inferred) {
aty = (jl_value_t*)call_arg_types(args, arglen, ctx);
// attempt compile-time specialization for inferred types
if (aty != NULL) {
aty = (jl_value_t*)jl_apply_tuple_type((jl_svec_t*)aty);
/*if (trace) {
jl_printf(JL_STDOUT, "call %s%s\n",
jl_sprint(args[0]),
jl_sprint((jl_value_t*)aty));
}*/
jl_lambda_info_t *li = jl_get_specialization1((jl_tupletype_t*)aty);
if (li != NULL && !li->inInference) {
jl_compile_linfo(li);
assert(li->functionObjectsDecls.functionObject != NULL);
theFptr = (Value*)li->functionObjectsDecls.functionObject;
jl_cgval_t fval;
if (f != NULL) {
// TODO jb/functions: avoid making too many roots here
if (!jl_is_globalref(args[0]) && !jl_is_symbol(args[0]) &&
!jl_is_leaf_type(f)) {
if (ctx->linfo->def)
jl_add_linfo_root(ctx->linfo, f);
else // for toplevel thunks, just write the value back to the AST to root it
jl_array_ptr_set(ex->args, 0, f);
}
fval = mark_julia_const((jl_value_t*)f);
}
else {
fval = emit_expr(args[0], ctx);
}
if (ctx->linfo->def) // root this li in case it gets deleted from the cache in `f`
jl_add_linfo_root(ctx->linfo, (jl_value_t*)li);
result = emit_call_function_object(li, fval, theFptr, args, nargs, expr, ctx);
JL_GC_POP();
return result;
}
}
}

// emit function and arguments
nargs++; // add function to nargs count
jl_cgval_t *anArg = (jl_cgval_t*)alloca(sizeof(jl_cgval_t) * nargs);
Expand Down
12 changes: 8 additions & 4 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# issue 9770
@noinline x9770() = false
function f9770(x)
if x9770()
return if x9770()
g9770(:a, :foo)
else
x
end
end
function g9770(x,y)
if isa(y, Symbol)
return if isa(y, Symbol)
f9770(x)
else
g9770(:a, :foo)
Expand Down Expand Up @@ -58,7 +58,7 @@ function g3182(t::DataType)
# subtype of Type, but we cannot infer the T in Type{T} just
# by knowing (at compile time) that the argument is a DataType.
# however the ::Type{T} method should still match at run time.
f3182(t)
return f3182(t)
end
@test g3182(Complex) == 0

Expand Down Expand Up @@ -107,7 +107,7 @@ barTuple2() = fooTuple{tuple(:y)}()
# issue #12476
function f12476(a)
(k, v) = a
v
return v
end
@inferred f12476(1.0 => 1)

Expand Down Expand Up @@ -143,14 +143,17 @@ f12826{I<:Integer}(v::Vector{I}) = v[1]


# non-terminating inference, issue #14009
# non-terminating codegen, issue #16201
type A14009{T}; end
A14009{T}(a::T) = A14009{T}()
f14009(a) = rand(Bool) ? f14009(A14009(a)) : a
code_typed(f14009, (Int,))
code_llvm(DevNull, f14009, (Int,))

type B14009{T}; end
g14009(a) = g14009(B14009{a})
code_typed(g14009, (Type{Int},))
code_llvm(DevNull, f14009, (Int,))


# issue #9232
Expand All @@ -164,6 +167,7 @@ result_type9232{T1<:Number,T2<:Number}(::Type{T1}, ::Type{T2}) = arithtype9232(T
function g10878(x; kw...); end
invoke_g10878() = invoke(g10878, Tuple{Any}, 1)
@code_typed invoke_g10878()
code_llvm(DevNull, invoke_g10878, ())


# issue #10930
Expand Down

0 comments on commit f3f418a

Please sign in to comment.