From e2dda30c667194e721be3fba063d509ac25fd2a8 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 23 Sep 2016 13:49:23 -0400 Subject: [PATCH] run generators in a correct & useful world --- src/alloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/alloc.c b/src/alloc.c index 17220adb90f1b..604c38b9c713f 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -493,11 +493,14 @@ JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo) int last_in = ptls->in_pure_callback; jl_module_t *last_m = ptls->current_module; jl_module_t *task_last_m = ptls->current_task->current_module; + size_t last_age = jl_get_ptls_states()->world_age; assert(jl_svec_len(linfo->def->sparam_syms) == jl_svec_len(sparam_vals)); JL_TRY { ptls->in_pure_callback = 1; // need to eval macros in the right module ptls->current_task->current_module = ptls->current_module = linfo->def->module; + // and the right world + ptls->world_age = generator->def->min_world; ex = jl_exprn(lambda_sym, 2); @@ -518,7 +521,6 @@ JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo) // invoke code generator assert(jl_nparams(tt) == jl_array_len(argnames) || (linfo->def->isva && (jl_nparams(tt) >= jl_array_len(argnames) - 1))); - // TODO: set world to that of the generator while calling func jl_array_ptr_set(body->args, 1, jl_call_staged(sparam_vals, generator, jl_svec_data(tt->parameters), jl_nparams(tt))); @@ -548,6 +550,7 @@ JL_DLLEXPORT jl_code_info_t *jl_code_for_staged(jl_method_instance_t *linfo) jl_lineno = last_lineno; ptls->current_module = last_m; ptls->current_task->current_module = task_last_m; + ptls->world_age = last_age; } JL_CATCH { ptls->in_pure_callback = last_in;