Skip to content

Commit 505907b

Browse files
authored
Add lowering and interpreter support for :latestworld (#56523)
Split out from #56509 to facilitate adjusting downstream packages.
1 parent 45c5c9b commit 505907b

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

base/boot.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ macro nospecialize(x)
271271
end
272272
Expr(@nospecialize args...) = _expr(args...)
273273

274+
macro latestworld() Expr(:latestworld) end
275+
274276
_is_internal(__module__) = __module__ === Core
275277
# can be used in place of `@assume_effects :total` (supposed to be used for bootstrapping)
276278
macro _total_meta()

src/ast.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ JL_DLLEXPORT jl_sym_t *jl_release_sym;
119119
JL_DLLEXPORT jl_sym_t *jl_acquire_release_sym;
120120
JL_DLLEXPORT jl_sym_t *jl_sequentially_consistent_sym;
121121
JL_DLLEXPORT jl_sym_t *jl_uninferred_sym;
122+
JL_DLLEXPORT jl_sym_t *jl_latestworld_sym;
122123

123124
static const uint8_t flisp_system_image[] = {
124125
#include <julia_flisp.boot.inc>
@@ -461,6 +462,7 @@ void jl_init_common_symbols(void)
461462
jl_acquire_release_sym = jl_symbol("acquire_release");
462463
jl_sequentially_consistent_sym = jl_symbol("sequentially_consistent");
463464
jl_uninferred_sym = jl_symbol("uninferred");
465+
jl_latestworld_sym = jl_symbol("latestworld");
464466
}
465467

466468
JL_DLLEXPORT void jl_lisp_prompt(void)

src/interpreter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,9 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip,
643643
jl_eval_const_decl(s->module, jl_exprarg(stmt, 0), val);
644644
s->locals[jl_source_nslots(s->src) + s->ip] = jl_nothing;
645645
}
646+
else if (head == jl_latestworld_sym) {
647+
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
648+
}
646649
else if (jl_is_toplevel_only_expr(stmt)) {
647650
jl_toplevel_eval(s->module, stmt);
648651
}

src/julia-syntax.scm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4512,6 +4512,7 @@ f(x) = yt(x)
45124512
((struct_type) "\"struct\" expression")
45134513
((method) "method definition")
45144514
((set_binding_type!) (string "type declaration for global \"" (deparse (cadr e)) "\""))
4515+
((latestworld) "World age increment")
45154516
(else (string "\"" h "\" expression"))))
45164517
(if (not (null? (cadr lam)))
45174518
(error (string (head-to-text (car e)) " not at top level"))))
@@ -4979,8 +4980,13 @@ f(x) = yt(x)
49794980
(if tail (emit-return tail val))
49804981
val))
49814982

4983+
((latestworld-if-toplevel)
4984+
(if (null? (cadr lam))
4985+
(emit `(latestworld)))
4986+
'(null))
4987+
49824988
;; other top level expressions
4983-
((import using export public)
4989+
((import using export public latestworld)
49844990
(check-top-level e)
49854991
(emit e)
49864992
(let ((have-ret? (and (pair? code) (pair? (car code)) (eq? (caar code) 'return))))

src/julia_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,7 @@ extern JL_DLLEXPORT jl_sym_t *jl_release_sym;
18561856
extern JL_DLLEXPORT jl_sym_t *jl_acquire_release_sym;
18571857
extern JL_DLLEXPORT jl_sym_t *jl_sequentially_consistent_sym;
18581858
extern JL_DLLEXPORT jl_sym_t *jl_uninferred_sym;
1859+
extern JL_DLLEXPORT jl_sym_t *jl_latestworld_sym;
18591860

18601861
JL_DLLEXPORT enum jl_memory_order jl_get_atomic_order(jl_sym_t *order, char loading, char storing);
18611862
JL_DLLEXPORT enum jl_memory_order jl_get_atomic_order_checked(jl_sym_t *order, char loading, char storing);

src/toplevel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ int jl_is_toplevel_only_expr(jl_value_t *e) JL_NOTSAFEPOINT
607607
((jl_expr_t*)e)->head == jl_const_sym ||
608608
((jl_expr_t*)e)->head == jl_toplevel_sym ||
609609
((jl_expr_t*)e)->head == jl_error_sym ||
610-
((jl_expr_t*)e)->head == jl_incomplete_sym);
610+
((jl_expr_t*)e)->head == jl_incomplete_sym ||
611+
((jl_expr_t*)e)->head == jl_latestworld_sym);
611612
}
612613

613614
int jl_needs_lowering(jl_value_t *e) JL_NOTSAFEPOINT

0 commit comments

Comments
 (0)