Skip to content

Commit

Permalink
optimize ... when delegating an arglist. ref #3440
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 3, 2013
1 parent 620141b commit 0d39ee4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,9 @@ static void max_arg_depth(jl_value_t *expr, int32_t *max, int32_t *sp,
else if (jl_is_function(fv)) {
jl_function_t *ff = (jl_function_t*)fv;
if (ff->fptr == jl_f_tuplelen ||
ff->fptr == jl_f_tupleref) {
ff->fptr == jl_f_tupleref ||
(ff->fptr == jl_f_apply && alen==3 &&
expr_type(jl_exprarg(e,1),ctx) == (jl_value_t*)jl_function_type)) {
esc = false;
}
}
Expand Down Expand Up @@ -1206,6 +1208,22 @@ static Value *emit_known_call(jl_value_t *ff, jl_value_t **args, size_t nargs,
}
}
}
else if (f->fptr == &jl_f_apply && nargs==2 && ctx->vaStack &&
symbol_eq(args[2], ctx->vaName)) {
Value *theF = emit_expr(args[1],ctx);
Value *theFptr = builder.CreateBitCast(emit_nthptr(theF,1),jl_fptr_llvmt);
Value *nva = emit_n_varargs(ctx);
#ifdef _P64
nva = builder.CreateTrunc(nva, T_int32);
#endif
Value *r =
builder.CreateCall3(theFptr, theF,
builder.CreateGEP(ctx->argArray,
ConstantInt::get(T_size, ctx->nReqArgs)),
nva);
JL_GC_POP();
return r;
}
else if (f->fptr == &jl_f_tupleref && nargs==2) {
jl_value_t *tty = expr_type(args[1], ctx); rt1 = tty;
jl_value_t *ity = expr_type(args[2], ctx); rt2 = ity;
Expand Down

0 comments on commit 0d39ee4

Please sign in to comment.