From 1fa5bd5f4d4f6a29713d9241864513390a6116ff Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 14 Jun 2016 20:53:36 -0400 Subject: [PATCH] fix cases where we need to codegen functions whose IR was deleted ref #16921 --- src/gf.c | 7 ++++++- src/julia_internal.h | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gf.c b/src/gf.c index a89fa88b573340..50199b12bb50f5 100644 --- a/src/gf.c +++ b/src/gf.c @@ -164,7 +164,7 @@ jl_lambda_info_t *jl_get_unspecialized(jl_lambda_info_t *method) return method->unspecialized_ducttape; if (method->sparam_syms != jl_emptysvec) { if (def->needs_sparam_vals_ducttape == 2) { - jl_array_t *code = (jl_array_t*)method->code; + jl_array_t *code = (jl_array_t*)def->lambda_template->code; JL_GC_PUSH1(&code); if (!jl_typeis(code, jl_array_any_type)) code = jl_uncompress_ast(def->lambda_template, code); @@ -1094,6 +1094,11 @@ jl_lambda_info_t *jl_get_specialization1(jl_tupletype_t *types) if (sf->functionObjectsDecls.functionObject == NULL) { if (sf->fptr != NULL) goto not_found; + if (sf->code == jl_nothing) { + jl_type_infer(sf, 0); + if (sf->code == jl_nothing) + goto not_found; + } jl_compile_linfo(sf); } JL_GC_POP(); diff --git a/src/julia_internal.h b/src/julia_internal.h index e22529569e70af..038a5a3041d5ac 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -69,6 +69,7 @@ STATIC_INLINE jl_value_t *newstruct(jl_datatype_t *type) return jv; } +void jl_type_infer(jl_lambda_info_t *li, int force); void jl_generate_fptr(jl_lambda_info_t *li); void jl_compile_linfo(jl_lambda_info_t *li); @@ -85,6 +86,13 @@ STATIC_INLINE jl_value_t *jl_call_method_internal(jl_lambda_info_t *meth, jl_val mfptr = jl_get_unspecialized(meth); } if (mfptr->fptr == NULL) { + if (__unlikely(mfptr->code == jl_nothing)) { + jl_type_infer(mfptr, 0); + if (mfptr->functionObjectsDecls.functionObject == NULL && + mfptr->code == jl_nothing) { + mfptr = jl_get_unspecialized(meth); + } + } jl_compile_linfo(mfptr); jl_generate_fptr(mfptr); } @@ -204,7 +212,6 @@ jl_value_t *jl_interpret_toplevel_expr(jl_value_t *e); jl_value_t *jl_static_eval(jl_value_t *ex, void *ctx_, jl_module_t *mod, jl_lambda_info_t *li, int sparams, int allow_alloc); int jl_is_toplevel_only_expr(jl_value_t *e); -void jl_type_infer(jl_lambda_info_t *li, int force); jl_value_t *jl_call_scm_on_ast(char *funcname, jl_value_t *expr); jl_lambda_info_t *jl_method_lookup_by_type(jl_methtable_t *mt, jl_tupletype_t *types,