Skip to content

Commit

Permalink
fix cases where we need to codegen functions whose IR was deleted
Browse files Browse the repository at this point in the history
ref #16921
  • Loading branch information
JeffBezanson committed Jun 15, 2016
1 parent 7f44ee7 commit 1fa5bd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 8 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1fa5bd5

Please sign in to comment.