diff --git a/src/codegen.cpp b/src/codegen.cpp index fafb2c821e9ba..18a4da81c232e 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1177,16 +1177,12 @@ jl_code_instance_t *jl_compile_linfo(jl_method_instance_t *mi, jl_code_info_t *s jl_ptls_t ptls = jl_get_ptls_states(); jl_code_instance_t *uncached = (jl_code_instance_t*)jl_gc_alloc(ptls, sizeof(jl_code_instance_t), jl_code_instance_type); - uncached->min_world = codeinst->min_world; - uncached->max_world = codeinst->max_world; + *uncached = *codeinst; uncached->functionObjectsDecls.functionObject = NULL; uncached->functionObjectsDecls.specFunctionObject = NULL; - uncached->rettype = codeinst->rettype; uncached->inferred = jl_nothing; - uncached->rettype_const = codeinst->rettype_const; - uncached->invoke = NULL; - if (codeinst->invoke == jl_fptr_const_return) - uncached->invoke = jl_fptr_const_return; + if (uncached->invoke != jl_fptr_const_return) + uncached->invoke = NULL; uncached->specptr.fptr = NULL; codeinst = uncached; } @@ -3204,6 +3200,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, jl_expr_t *ex, jl_value_t *rt) assert(jl_is_method_instance(mi)); jl_code_instance_t *codeinst = jl_compile_linfo(mi, NULL, ctx.world, ctx.params); if (codeinst && codeinst->inferred) { + JL_GC_PUSH1(&codeinst); const jl_llvm_functions_t &decls = codeinst->functionObjectsDecls; if (codeinst->invoke == jl_fptr_const_return) { assert(codeinst->rettype_const); @@ -3219,6 +3216,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, jl_expr_t *ex, jl_value_t *rt) handled = true; } } + JL_GC_POP(); } } if (!handled) {