From 3ff36560e1b00a42ac76066e836df77caf5578cc Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 26 Feb 2015 14:29:14 -0500 Subject: [PATCH] only limit argument lists that are growing by recursion seems to basically work, however triggers an LLVM assertion --- base/inference.jl | 11 ++++++++++- src/codegen.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/base/inference.jl b/base/inference.jl index be9337540df01..08aa033c1f697 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -736,8 +736,17 @@ function abstract_call_gf(f, fargs, argtypes, e) # limit argument type tuple based on size of definition signature. # for example, given function f(T, Any...), limit to 3 arguments # instead of the default (MAX_TUPLETYPE_LEN) + sp = inference_stack + limit = false + # look at the stack to detect recursive calls with growing argument lists + while sp !== EmptyCallStack() + if linfo.ast === sp.ast && length(argtypes) > length(sp.types) + limit = true; break + end + sp = sp.prev + end ls = length(sig) - if ls > lsig+1 && !(isdefined(Main.Base,:promote_typeof) && f === Main.Base.promote_typeof) + if limit && ls > lsig+1 && !(isdefined(Main.Base,:promote_typeof) && f === Main.Base.promote_typeof) fst = sig[lsig+1] allsame = true # allow specializing on longer arglists if all the trailing diff --git a/src/codegen.cpp b/src/codegen.cpp index 07371cbcb9614..de74e1068fcfe 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -637,10 +637,10 @@ static Function *to_function(jl_lambda_info_t *li, bool cstyle) // print out the function's LLVM code //jl_printf(JL_STDERR, "%s:%d\n", // ((jl_sym_t*)li->file)->name, li->line); - //if (verifyFunction(*f,PrintMessageAction)) { - // f->dump(); - // abort(); - //} + if (verifyFunction(*f,PrintMessageAction)) { + f->dump(); + abort(); + } if (old != NULL) { builder.SetInsertPoint(old); builder.SetCurrentDebugLocation(olddl); @@ -698,7 +698,7 @@ extern "C" void jl_generate_fptr(jl_function_t *f) #endif Function *llvmf = (Function*)li->functionObject; - + llvmf->dump(); #ifdef USE_MCJIT li->fptr = (jl_fptr_t)(intptr_t)jl_ExecutionEngine->getFunctionAddress(llvmf->getName()); #else