compiler: resolve Janet-env fallback symbols; validate full suite under compile
analyze-form now mirrors resolve-sym's full resolution order: jolt var (current ns / clojure.core), then the runtime/Janet env, then a pending forward-ref cell. Previously a name that resolves only via the Janet-env fallback (int?, type, …) interned an empty var and miscompiled; now it emits the runtime binding directly, matching the interpreter. suite-worker honors JOLT_COMPILE=1 to run the whole clojure-test-suite through the compile path. Under compilation it now passes 3932 / errors 124 — at parity with the interpreter baseline (3913 / 125) across 4600+ assertions, confirming the hybrid compile path doesn't diverge from the interpreter.
This commit is contained in:
parent
6297a65617
commit
918e2798db
2 changed files with 26 additions and 16 deletions
|
|
@ -338,21 +338,26 @@
|
||||||
{:op :local :name name}
|
{:op :local :name name}
|
||||||
(if (and (not (special-form? name)) (get core-renames name))
|
(if (and (not (special-form? name)) (get core-renames name))
|
||||||
{:op :core-symbol :name name :janet-name (get core-renames name)}
|
{:op :core-symbol :name name :janet-name (get core-renames name)}
|
||||||
# A global reference: resolve the Jolt var cell now and compile a
|
# A global reference. Resolution mirrors the interpreter's resolve-sym
|
||||||
# deref through it, so redefinition is visible to compiled callers
|
# so compiled and interpreted code agree:
|
||||||
# (Janet early-binds plain symbols). Resolution mirrors the
|
# 1. a jolt var in the current ns (which also holds refers) or
|
||||||
# interpreter's resolve-var — current ns (which also holds refers),
|
# clojure.core -> deref through the cell, so redefinition is
|
||||||
# then clojure.core — so unqualified core fns resolve to their real
|
# visible to compiled callers (Janet early-binds plain symbols);
|
||||||
# var rather than a fresh empty one. Only a genuinely-undefined name
|
# 2. otherwise a binding in the runtime/Janet env (resolve-sym's own
|
||||||
# interns a pending cell in the current ns (forward refs; the getter
|
# fallback — this is how int?, type, etc. resolve) -> emit it
|
||||||
# derefs at call time, so a later def fills it in). No ctx -> plain
|
# directly;
|
||||||
# symbol.
|
# 3. otherwise a forward reference -> intern a pending cell whose
|
||||||
|
# getter derefs at call time, once a later def fills it in.
|
||||||
|
# No ctx -> plain symbol.
|
||||||
(if ctx
|
(if ctx
|
||||||
(let [cur-ns (ctx-find-ns ctx (ctx-current-ns ctx))
|
(let [cur-ns (ctx-find-ns ctx (ctx-current-ns ctx))
|
||||||
cell (or (ns-find cur-ns name)
|
cell (or (ns-find cur-ns name)
|
||||||
(ns-find (ctx-find-ns ctx "clojure.core") name)
|
(ns-find (ctx-find-ns ctx "clojure.core") name))]
|
||||||
(ns-intern cur-ns name))]
|
(cond
|
||||||
{:op :var :name name :var cell})
|
cell {:op :var :name name :var cell}
|
||||||
|
(get jolt-runtime-env (symbol name))
|
||||||
|
{:op :core-symbol :name name :janet-name name}
|
||||||
|
{:op :var :name name :var (ns-intern cur-ns name)}))
|
||||||
{:op :symbol :name name})))))
|
{:op :symbol :name name})))))
|
||||||
|
|
||||||
(array? form)
|
(array? form)
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,13 @@
|
||||||
(def path (get (dyn :args) 1))
|
(def path (get (dyn :args) 1))
|
||||||
|
|
||||||
(when path
|
(when path
|
||||||
(def ctx (init))
|
# JOLT_COMPILE=1 runs the suite through the compile path (hybrid: hot forms
|
||||||
(each f (parse-forms (slurp "test/support/clojure_test.clj")) (eval-form ctx @{} f))
|
# compile, unsupported forms fall back to the interpreter) so the whole battery
|
||||||
|
# validates compile-mode correctness against the same baseline.
|
||||||
|
(def compile? (= "1" (os/getenv "JOLT_COMPILE")))
|
||||||
|
(def ctx (init (if compile? {:compile? true} {})))
|
||||||
|
(defn run-form [f] (if compile? (eval-one ctx f) (eval-form ctx @{} f)))
|
||||||
|
(each f (parse-forms (slurp "test/support/clojure_test.clj")) (run-form f))
|
||||||
|
|
||||||
# Pre-load the suite's own clojure.core-test.number-range helper ns if present
|
# Pre-load the suite's own clojure.core-test.number-range helper ns if present
|
||||||
# (35 files require it for r/max-int, r/max-double, … — its :default branches are
|
# (35 files require it for r/max-int, r/max-double, … — its :default branches are
|
||||||
|
|
@ -29,10 +34,10 @@
|
||||||
(let [dir (string/slice path 0 (- (length path) (length (last (string/split "/" path)))))
|
(let [dir (string/slice path 0 (- (length path) (length (last (string/split "/" path)))))
|
||||||
nr (string dir "number_range.cljc")]
|
nr (string dir "number_range.cljc")]
|
||||||
(when (os/stat nr)
|
(when (os/stat nr)
|
||||||
(each f (parse-forms (slurp nr)) (protect (eval-form ctx @{} f)))))
|
(each f (parse-forms (slurp nr)) (protect (run-form f)))))
|
||||||
|
|
||||||
(eval-string ctx "(clojure.test/reset-report!)")
|
(eval-string ctx "(clojure.test/reset-report!)")
|
||||||
(each form (parse-forms (slurp path)) (protect (eval-form ctx @{} form)))
|
(each form (parse-forms (slurp path)) (protect (run-form form)))
|
||||||
(protect (eval-string ctx "(clojure.test/run-registered)"))
|
(protect (eval-string ctx "(clojure.test/run-registered)"))
|
||||||
(def p (eval-string ctx "(clojure.test/n-pass)"))
|
(def p (eval-string ctx "(clojure.test/n-pass)"))
|
||||||
(def f (eval-string ctx "(clojure.test/n-fail)"))
|
(def f (eval-string ctx "(clojure.test/n-fail)"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue