Merge branch 'loops/sx-vm-extensions' into architecture

# Conflicts:
#	lib/erlang/runtime.sx
This commit is contained in:
2026-06-20 07:37:43 +00:00
18 changed files with 453 additions and 25 deletions

View File

@@ -757,4 +757,10 @@
"format-arguments" args))))
(cl-restart-case
(fn () (cl-signal-obj obj cl-handler-stack))
(list "continue" (list) (fn () nil))))))
(list "continue" (list) (fn () nil))))))
;; ── JIT interpret-only boundary ───────────────────────────────────────────
;; The Common-Lisp evaluator implements block/return-from, catch/throw, and
;; the condition system via non-local control (host continuations); under JIT
;; a compiled frame can't transfer control through a CEK continuation. Exclude
;; the cl-/clos- namespaces from JIT. See Sx_types.jit_excluded_prefixes.
(jit-exclude! "cl-*" "clos-*")

View File

@@ -783,11 +783,7 @@
(rest-clauses
(if (> (len flat-args) 2) (slice flat-args 2) (list))))
(if
(or
(and
(= (type-of test) "keyword")
(= (keyword-name test) "else"))
(= test true))
(or (and (= (type-of test) "keyword") (= (keyword-name test) "else")) (and (= (type-of test) "symbol") (or (= (symbol-name test) "else") (= (symbol-name test) ":else"))) (= test true))
(compile-expr em body scope tail?)
(do
(compile-expr em test scope false)
@@ -828,11 +824,7 @@
(rest-clauses
(if (> (len clauses) 2) (slice clauses 2) (list))))
(if
(or
(and
(= (type-of test) "keyword")
(= (keyword-name test) "else"))
(= test true))
(or (and (= (type-of test) "keyword") (= (keyword-name test) "else")) (and (= (type-of test) "symbol") (or (= (symbol-name test) "else") (= (symbol-name test) ":else"))) (= test true))
(do (emit-op em 5) (compile-expr em body scope tail?))
(do
(emit-op em 6)
@@ -1172,11 +1164,7 @@
(test (first clause))
(body (rest clause)))
(if
(or
(and
(= (type-of test) "keyword")
(= (keyword-name test) "else"))
(= test true))
(or (and (= (type-of test) "keyword") (= (keyword-name test) "else")) (and (= (type-of test) "symbol") (or (= (symbol-name test) "else") (= (symbol-name test) ":else"))) (= test true))
(compile-begin em body scope tail?)
(do
(compile-expr em test scope false)

View File

@@ -1624,4 +1624,6 @@
(er-mk-atom "ok")))
;; Register everything at load time.
(jit-exclude! "er-*" "erlang-*")
(er-register-builtin-bifs!)

View File

@@ -148,3 +148,9 @@
(fn (acc i) (str acc (char-at buf i)))
""
(range off (string-length buf)))))))
;; ── JIT interpret-only boundary ───────────────────────────────────────────
;; The Haskell evaluator (hk-eval and the lazy-thunk forcer) recurses deeply
;; over the AST/graph; under JIT the recursive eval can miscompile into a
;; non-terminating loop. Exclude the hk- namespace from JIT.
(jit-exclude! "hk-*")

View File

@@ -6994,3 +6994,9 @@
(set! js-global-this js-global)
(dict-set! js-global "globalThis" js-global)
;; ── JIT interpret-only boundary ───────────────────────────────────────────
;; The JS evaluator (transpile.sx) uses call/cc for control flow (exceptions,
;; early return); a JIT-compiled frame can't escape through a CEK continuation.
;; Exclude the js- namespace from JIT. See Sx_types.jit_excluded_prefixes.
(jit-exclude! "js-*")

View File

@@ -2792,3 +2792,10 @@
{:cut false}
(fn () (begin (dict-set! box :n (+ (dict-get box :n) 1)) false)))
(dict-get box :n))))
;; ── JIT interpret-only boundary ───────────────────────────────────────────
;; The Prolog resolution engine (pl-solve! and friends) recurses deeply over
;; goals/clauses with backtracking; under JIT it miscompiles into a
;; non-terminating loop (the suite never completes). Exclude the whole pl-
;; namespace from JIT. See Sx_types.jit_excluded_prefixes.
(jit-exclude! "pl-*")

View File

@@ -647,3 +647,11 @@
(raise (get outcome :value)))
(:else outcome))))))))))
env)))
;; ── JIT interpret-only boundary ───────────────────────────────────────────
;; The Scheme evaluator uses call/cc, dynamic-wind, guard/raise and applies
;; user procedures (which may be continuations or JIT-returned closures); a
;; JIT-compiled frame cannot transfer control through a CEK continuation.
;; Exclude the whole scheme-/scm- namespace from JIT (robust vs a name list,
;; which misses functions in extra files). See Sx_types.jit_excluded_prefixes.
(jit-exclude! "scheme-*" "scm-*")

View File

@@ -1475,3 +1475,22 @@
(get ast :temps)))
(smalltalk-eval-ast ast frame)))))))
(begin (dict-set! cell :active false) result)))))
;; ── JIT interpret-only boundary ──────────────────────────────────────────
;; The Smalltalk evaluator implements non-local return (^expr), block escape,
;; and exception unwinding via first-class continuations (call/cc). A stack
;; bytecode VM cannot transfer control through a CEK continuation, so any of
;; these dispatch-core functions, if JIT-compiled, would be an un-escapable
;; VM frame on the stack between a `call/cc` capture and its `(k v)` invocation
;; — failing at runtime and (before this guard) re-running with duplicated
;; side effects. Declaring them interpret-only keeps them on the CEK while the
;; pure leaf helpers (parsing, ident/ivar lookup, formatting, predicates,
;; arithmetic) still JIT. See Sx_types.jit_excluded / `jit-exclude!`.
(jit-exclude!
"smalltalk-eval" "smalltalk-eval-program" "smalltalk-load"
"smalltalk-eval-ast" "st-eval-seq" "st-eval-send" "st-eval-send-dispatch"
"st-eval-cascade" "st-try-intrinsify" "st-send" "st-invoke" "st-dnu"
"st-super-send" "st-primitive-send" "st-num-send" "st-bool-send"
"st-string-send" "st-array-send" "st-nil-send" "st-class-side-send"
"st-block-apply" "st-block-dispatch" "st-block-while" "st-block-ensure"
"st-block-if-curtailed" "st-block-on-do" "st-block-value-selector?")

View File

@@ -360,3 +360,10 @@
{:type "number" :value 2}))
(list st-test-pass st-test-fail)
;; The SUnit suite-runner `pharo-test-class` (defined in tests/pharo.sx and
;; tests/ansi.sx) drives the interpret-only Smalltalk evaluator through
;; smalltalk-eval-program in a loop and accumulates results via st-test
;; (a side-effecting accumulator). Under JIT it can fail mid-loop and re-run
;; via CEK, double-counting already-emitted rows. Keep it interpret-only.
(jit-exclude! "pharo-test-class")