Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lowering and interpreter support for :latestworld #56523

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ macro nospecialize(x)
end
Expr(@nospecialize args...) = _expr(args...)

macro worldinc() Expr(:worldinc) end

_is_internal(__module__) = __module__ === Core
# can be used in place of `@assume_effects :total` (supposed to be used for bootstrapping)
macro _total_meta()
Expand Down
2 changes: 2 additions & 0 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ JL_DLLEXPORT jl_sym_t *jl_release_sym;
JL_DLLEXPORT jl_sym_t *jl_acquire_release_sym;
JL_DLLEXPORT jl_sym_t *jl_sequentially_consistent_sym;
JL_DLLEXPORT jl_sym_t *jl_uninferred_sym;
JL_DLLEXPORT jl_sym_t *jl_worldinc_sym;

static const uint8_t flisp_system_image[] = {
#include <julia_flisp.boot.inc>
Expand Down Expand Up @@ -461,6 +462,7 @@ void jl_init_common_symbols(void)
jl_acquire_release_sym = jl_symbol("acquire_release");
jl_sequentially_consistent_sym = jl_symbol("sequentially_consistent");
jl_uninferred_sym = jl_symbol("uninferred");
jl_worldinc_sym = jl_symbol("worldinc");
}

JL_DLLEXPORT void jl_lisp_prompt(void)
Expand Down
3 changes: 3 additions & 0 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip,
jl_eval_const_decl(s->module, jl_exprarg(stmt, 0), val);
s->locals[jl_source_nslots(s->src) + s->ip] = jl_nothing;
}
else if (head == jl_worldinc_sym) {
ct->world_age = jl_atomic_load_acquire(&jl_world_counter);
}
else if (jl_is_toplevel_only_expr(stmt)) {
jl_toplevel_eval(s->module, stmt);
}
Expand Down
8 changes: 7 additions & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4512,6 +4512,7 @@ f(x) = yt(x)
((struct_type) "\"struct\" expression")
((method) "method definition")
((set_binding_type!) (string "type declaration for global \"" (deparse (cadr e)) "\""))
((worldinc) "World age increment")
(else (string "\"" h "\" expression"))))
(if (not (null? (cadr lam)))
(error (string (head-to-text (car e)) " not at top level"))))
Expand Down Expand Up @@ -4979,8 +4980,13 @@ f(x) = yt(x)
(if tail (emit-return tail val))
val))

((worldinc-if-toplevel)
(if (null? (cadr lam))
(emit `(worldinc)))
'(null))

;; other top level expressions
((import using export public)
((import using export public worldinc)
(check-top-level e)
(emit e)
(let ((have-ret? (and (pair? code) (pair? (car code)) (eq? (caar code) 'return))))
Expand Down
1 change: 1 addition & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,7 @@ extern JL_DLLEXPORT jl_sym_t *jl_release_sym;
extern JL_DLLEXPORT jl_sym_t *jl_acquire_release_sym;
extern JL_DLLEXPORT jl_sym_t *jl_sequentially_consistent_sym;
extern JL_DLLEXPORT jl_sym_t *jl_uninferred_sym;
extern JL_DLLEXPORT jl_sym_t *jl_worldinc_sym;

JL_DLLEXPORT enum jl_memory_order jl_get_atomic_order(jl_sym_t *order, char loading, char storing);
JL_DLLEXPORT enum jl_memory_order jl_get_atomic_order_checked(jl_sym_t *order, char loading, char storing);
Expand Down
3 changes: 2 additions & 1 deletion src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ int jl_is_toplevel_only_expr(jl_value_t *e) JL_NOTSAFEPOINT
((jl_expr_t*)e)->head == jl_const_sym ||
((jl_expr_t*)e)->head == jl_toplevel_sym ||
((jl_expr_t*)e)->head == jl_error_sym ||
((jl_expr_t*)e)->head == jl_incomplete_sym);
((jl_expr_t*)e)->head == jl_incomplete_sym ||
((jl_expr_t*)e)->head == jl_worldinc_sym);
}

int jl_needs_lowering(jl_value_t *e) JL_NOTSAFEPOINT
Expand Down