@@ -707,6 +707,24 @@ JL_CALLABLE(jl_f__apply_latest)
707707 return ret ;
708708}
709709
710+ // Like `_apply`, but runs in the specified world.
711+ // If world > jl_world_counter, run in the latest world.
712+ JL_CALLABLE (jl_f__apply_in_world )
713+ {
714+ JL_NARGSV (_apply_in_world , 2 );
715+ jl_ptls_t ptls = jl_get_ptls_states ();
716+ size_t last_age = ptls -> world_age ;
717+ JL_TYPECHK (_apply_in_world , ulong , args [0 ]);
718+ size_t world = jl_unbox_ulong (args [0 ]);
719+ world = world <= jl_world_counter ? world : jl_world_counter ;
720+ if (!ptls -> in_pure_callback ) {
721+ ptls -> world_age = world ;
722+ }
723+ jl_value_t * ret = do_apply (NULL , args + 1 , nargs - 1 , NULL );
724+ ptls -> world_age = last_age ;
725+ return ret ;
726+ }
727+
710728// tuples ---------------------------------------------------------------------
711729
712730JL_CALLABLE (jl_f_tuple )
@@ -1529,6 +1547,7 @@ void jl_init_primitives(void) JL_GC_DISABLED
15291547 jl_builtin_svec = add_builtin_func ("svec" , jl_f_svec );
15301548 add_builtin_func ("_apply_pure" , jl_f__apply_pure );
15311549 add_builtin_func ("_apply_latest" , jl_f__apply_latest );
1550+ add_builtin_func ("_apply_in_world" , jl_f__apply_in_world );
15321551 add_builtin_func ("_typevar" , jl_f__typevar );
15331552 add_builtin_func ("_structtype" , jl_f__structtype );
15341553 add_builtin_func ("_abstracttype" , jl_f__abstracttype );
0 commit comments