Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@
XX(jl_new_method_table) \
XX(jl_new_method_uninit) \
XX(jl_new_module) \
XX(jl_new_opaque_closure_from_code_info) \
XX(jl_new_opaque_closure_from_code_info_in_world) \
XX(jl_new_primitivetype) \
XX(jl_new_struct) \
XX(jl_new_structt) \
Expand Down
18 changes: 11 additions & 7 deletions src/opaque_closure.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ JL_DLLEXPORT int jl_is_valid_oc_argtype(jl_tupletype_t *argt, jl_method_t *sourc
}

static jl_opaque_closure_t *new_opaque_closure(jl_tupletype_t *argt, jl_value_t *rt_lb, jl_value_t *rt_ub,
jl_value_t *source_, jl_value_t *captures, int do_compile)
jl_value_t *source_, jl_value_t *captures, int do_compile, size_t world)
{
if (!jl_is_tuple_type((jl_value_t*)argt)) {
jl_error("OpaqueClosure argument tuple must be a tuple type");
Expand Down Expand Up @@ -61,7 +61,6 @@ static jl_opaque_closure_t *new_opaque_closure(jl_tupletype_t *argt, jl_value_t
}
}
jl_task_t *ct = jl_current_task;
size_t world = ct->world_age;
jl_code_instance_t *ci = NULL;
if (do_compile) {
ci = jl_compile_method_internal(mi, world);
Expand Down Expand Up @@ -140,13 +139,13 @@ jl_opaque_closure_t *jl_new_opaque_closure(jl_tupletype_t *argt, jl_value_t *rt_
{
jl_value_t *captures = jl_f_tuple(NULL, env, nenv);
JL_GC_PUSH1(&captures);
jl_opaque_closure_t *oc = new_opaque_closure(argt, rt_lb, rt_ub, source_, captures, do_compile);
jl_opaque_closure_t *oc = new_opaque_closure(argt, rt_lb, rt_ub, source_, captures, do_compile, jl_current_task->world_age);
JL_GC_POP();
return oc;
}

JL_DLLEXPORT jl_opaque_closure_t *jl_new_opaque_closure_from_code_info(jl_tupletype_t *argt, jl_value_t *rt_lb, jl_value_t *rt_ub,
jl_module_t *mod, jl_code_info_t *ci, int lineno, jl_value_t *file, int nargs, int isva, jl_value_t *env, int do_compile, int isinferred)
JL_DLLEXPORT jl_opaque_closure_t *jl_new_opaque_closure_from_code_info_in_world(jl_tupletype_t *argt, jl_value_t *rt_lb, jl_value_t *rt_ub,
jl_module_t *mod, jl_code_info_t *ci, int lineno, jl_value_t *file, int nargs, int isva, jl_value_t *env, int do_compile, int isinferred, size_t world)
{
jl_value_t *root = NULL, *sigtype = NULL;
jl_code_instance_t *inst = NULL;
Expand All @@ -156,7 +155,6 @@ JL_DLLEXPORT jl_opaque_closure_t *jl_new_opaque_closure_from_code_info(jl_tuplet
root = jl_new_struct(jl_linenumbernode_type, root, file);
jl_method_t *meth = jl_make_opaque_closure_method(mod, jl_nothing, nargs, root, ci, isva, isinferred);
root = (jl_value_t*)meth;
size_t world = jl_current_task->world_age;
// these are only legal in the current world since they are not in any tables
jl_atomic_store_release(&meth->primary_world, world);

Expand All @@ -172,11 +170,17 @@ JL_DLLEXPORT jl_opaque_closure_t *jl_new_opaque_closure_from_code_info(jl_tuplet
jl_mi_cache_insert(mi, inst);
}

jl_opaque_closure_t *oc = new_opaque_closure(argt, rt_lb, rt_ub, root, env, do_compile);
jl_opaque_closure_t *oc = new_opaque_closure(argt, rt_lb, rt_ub, root, env, do_compile, world);
JL_GC_POP();
return oc;
}

JL_DLLEXPORT jl_opaque_closure_t *jl_new_opaque_closure_from_code_info(jl_tupletype_t *argt, jl_value_t *rt_lb, jl_value_t *rt_ub,
jl_module_t *mod, jl_code_info_t *ci, int lineno, jl_value_t *file, int nargs, int isva, jl_value_t *env, int do_compile, int isinferred)
{
return jl_new_opaque_closure_from_code_info_in_world(argt, rt_lb, rt_ub, mod, ci, lineno, file, nargs, isva, env, do_compile, isinferred, jl_current_task->world_age);
}

JL_CALLABLE(jl_new_opaque_closure_jlcall)
{
if (nargs < 5)
Expand Down