Skip to content

Commit

Permalink
run generators in a correct & useful world
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Sep 23, 2016
1 parent ee623e4 commit e2dda30
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)));

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e2dda30

Please sign in to comment.