Delete the Janet host — Chez is the sole substrate

Remove the Janet seed (src/jolt/*.janet: reader, value layer, vars/ns, the
tree-walking interpreter, the Janet backend, the optimizing compiler), the
Janet->Scheme cross-compiler (host/chez/{driver,emit,jolt-chez}.janet),
bin/jolt-chez, the jpm build (project.janet) and the Janet test runner
(run-tests.janet), plus the entire Janet test suite. jolt now builds and runs
on Chez alone: bin/joltc off the checked-in seed, bootstrap.ss to rebuild it.

The portable Clojure stays: jolt-core/**, host/chez/**.ss, and the stdlib +
tooling under src/jolt/clojure + src/jolt/jolt (read by the seed build, no
Janet). The gate is 'make test' (self-host, corpus, unit, cli smoke, certify).
Drop the sci and clojure-test-suite submodules (used only by deleted Janet
integration tests); irregex stays.

Filesystem corpus/unit cases that probed project.janet now probe README.md.

jolt-cf1q.6
This commit is contained in:
Yogthos 2026-06-21 11:29:03 -04:00
parent 5c1fdfc336
commit 58d03d67be
221 changed files with 16 additions and 29925 deletions

View file

@ -1,47 +0,0 @@
# AOT build/deploy demo (jolt-a7ds). Two phases, run as separate processes:
# janet spike/native/aot-demo.janet build # needs cc; compiles + writes manifest
# janet spike/native/aot-demo.janet deploy # run with cc REMOVED from PATH
# Proves the deploy target needs no C toolchain: it only loads the prebuilt .so.
(import ../../src/jolt/api :as api)
(import ../../src/jolt/cgen :as cgen)
(def cp "(defn count-point [cr ci cap] (loop [i 0 zr 0.0 zi 0.0] (if (or (>= i cap) (> (+ (* zr zr) (* zi zi)) 4.0)) i (recur (inc i) (+ (- (* zr zr) (* zi zi)) cr) (+ (* 2.0 (* zr zi)) ci)))))")
(def run "(defn run [n] (let [cap 200 nd (* 1.0 n)] (loop [y 0 acc 0] (if (< y n) (let [ci (- (/ (* 2.0 y) nd) 1.0) row (loop [x 0 a 0] (if (< x n) (let [cr (- (/ (* 2.0 x) nd) 1.5)] (recur (inc x) (+ a (count-point cr ci cap)))) a))] (recur (inc y) (+ acc row))) acc))))")
(def manifest (string (or (os/getenv "TMPDIR") "/tmp") "/jolt-aot-demo.jdn"))
(def dir "spike/native/build/aot")
(defn setup [ctx]
(put (ctx :env) :direct-linking? true)
(api/eval-string ctx "(ns demo)"))
(def phase (get (dyn :args) 1))
(cond
(= phase "build")
(do
(def ctx (api/init-cached {:compile? true}))
(put (ctx :env) :cgen-collect? true)
(setup ctx)
(api/eval-string ctx cp)
(api/eval-string ctx run)
(def build (cgen/aot-build (get (ctx :env) :cgen-collected) {:dir dir}))
(cgen/write-manifest manifest build)
(printf "BUILD: cc-available? %p -> %s (%d fn)" (cgen/toolchain-available?)
(build :sopath) (length (build :entries))))
(= phase "deploy")
(do
(printf "DEPLOY: cc-available? %p (should be false with cc off PATH)"
(cgen/toolchain-available?))
(def ctx (api/init-cached {:compile? true}))
(setup ctx)
(put (ctx :env) :cgen-prebuilt (cgen/load-aot manifest))
(api/eval-string ctx cp)
(api/eval-string ctx run)
(def native? (cfunction? (api/eval-string ctx "count-point")))
(def t0 (os/clock))
(def total (api/eval-string ctx "(run 200)"))
(def ms (* 1000 (- (os/clock) t0)))
(printf "DEPLOY: count-point native? %p total %d (%s) %.1f ms"
native? total (if (= total 3288753) "OK" "MISMATCH") ms))
(eprint "usage: aot-demo.janet build|deploy"))

View file

@ -1,53 +0,0 @@
# Benchmark the native-C mandelbrot vs the spike's other legs (jolt-5vsp lever 1).
# janet spike/native/bench-native.janet 200
(import ./build/mandel :as mandel)
(defn bench [label f n]
(repeat 2 (f (div n 2)))
(def times @[])
(var last-r 0)
(repeat 3
(def t0 (os/clock))
(set last-r (f n))
(array/push times (* 1000.0 (- (os/clock) t0))))
(printf "%-28s n %d result %d mean %.2f ms"
label n last-r (/ (sum times) 3)))
# Leg A: whole run in native C (pure native-codegen ceiling).
(defn run-pure-c [n] (mandel/run-c n))
# Leg B: Janet `while` loop, but count-point is a native C cfunction called n^2
# times — measures the Janet->C boundary-crossing cost (the incremental hybrid).
(defn run-boundary [n]
(def cap 200)
(def nd (* 1.0 n))
(var acc 0)
(var y 0)
(while (< y n)
(def ci (- (/ (* 2.0 y) nd) 1.0))
(var x 0)
(var a 0)
(while (< x n)
(def cr (- (/ (* 2.0 x) nd) 1.5))
(set a (+ a (mandel/count-point-c cr ci cap)))
(++ x))
(set acc (+ acc a))
(++ y))
acc)
# Leg C: C run loop calling a Janet bytecode count-point back via janet_call n^2
# times — the reverse crossing (hot C fn -> cold bytecode helper).
(defn count-point-janet [cr ci cap]
(var i 0) (var zr 0.0) (var zi 0.0)
(while (and (< i cap) (<= (+ (* zr zr) (* zi zi)) 4.0))
(def nzr (+ (- (* zr zr) (* zi zi)) cr))
(def nzi (+ (* 2.0 (* zr zi)) ci))
(set zr nzr) (set zi nzi) (++ i))
i)
(defn run-callback [n] (mandel/run-callback n count-point-janet))
(defn main [& args]
(def n (if (> (length args) 1) (scan-number (get args 1)) 200))
(bench "native-C whole run" run-pure-c n)
(bench "Janet loop -> C count-point" run-boundary n)
(bench "C loop -> janet_call back" run-callback n))

View file

@ -1,15 +0,0 @@
# Dump the analyzed IR (not emitted Janet) for count-point, so the C emitter can
# be written against the real node shapes. jolt-ihdp.
(import ../../src/jolt/api :as api)
(import ../../src/jolt/backend :as backend)
(import ../../src/jolt/reader :as reader)
(def ctx (api/init-cached {:compile? true}))
(put (ctx :env) :direct-linking? true)
(put (ctx :env) :inline? true)
(api/eval-string ctx "(ns mandelbrot)")
(def src "(defn count-point [cr ci cap] (loop [i 0 zr 0.0 zi 0.0] (if (or (>= i cap) (> (+ (* zr zr) (* zi zi)) 4.0)) i (recur (inc i) (+ (- (* zr zr) (* zi zi)) cr) (+ (* 2.0 (* zr zi)) ci)))))")
(def ir (backend/analyze-form ctx (reader/parse-string src)))
(printf "%P" ir)

View file

@ -1,91 +0,0 @@
/* Native-C mandelbrot, exposed as a Janet module — the lever-1 ceiling probe for
* the foundational-runtime epic (jolt-5vsp). Measures:
* (1) mandel/run-c whole run in C (count_point inlined in C). The pure
* native-codegen ceiling: no Janet in the hot loop.
* (2) mandel/count-point-c just count_point exposed as a Janet cfunction, so a
* Janet `while` loop can call it n^2 times. Measures the
* Janet->C boundary-crossing cost the incremental
* hybrid (hot fn in C, caller still bytecode) pays this.
* Build: jpm --local build (project.janet declares the native module). */
#include <janet.h>
/* Pure C. cr/ci/cap are doubles; cap compared as int iteration count. */
static long count_point(double cr, double ci, long cap) {
long i = 0;
double zr = 0.0, zi = 0.0;
while (i < cap && (zr*zr + zi*zi) <= 4.0) {
double nzr = zr*zr - zi*zi + cr;
double nzi = 2.0*zr*zi + ci;
zr = nzr; zi = nzi;
i++;
}
return i;
}
static long run_c(long n) {
long cap = 200;
double nd = (double)n;
long acc = 0;
for (long y = 0; y < n; y++) {
double ci = (2.0*y)/nd - 1.0;
long a = 0;
for (long x = 0; x < n; x++) {
double cr = (2.0*x)/nd - 1.5;
a += count_point(cr, ci, cap);
}
acc += a;
}
return acc;
}
static Janet cfun_run_c(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
long n = (long)janet_getinteger(argv, 0);
return janet_wrap_number((double)run_c(n));
}
/* count_point exposed for the Janet-loop-calls-C boundary test. */
static Janet cfun_count_point_c(int32_t argc, Janet *argv) {
janet_fixarity(argc, 3);
double cr = janet_getnumber(argv, 0);
double ci = janet_getnumber(argv, 1);
long cap = (long)janet_getinteger(argv, 2);
return janet_wrap_number((double)count_point(cr, ci, cap));
}
/* run loop in C, but count_point is a Janet function called back via janet_call
* n^2 times the reverse crossing: a C-compiled hot fn invoking a cold bytecode
* helper. Measures janet_call overhead (the cost the hybrid pays when native code
* calls back into the bytecode world). */
static Janet cfun_run_callback(int32_t argc, Janet *argv) {
janet_fixarity(argc, 2);
long n = (long)janet_getinteger(argv, 0);
JanetFunction *cp = janet_getfunction(argv, 1);
long cap = 200;
double nd = (double)n;
long acc = 0;
for (long y = 0; y < n; y++) {
double ci = (2.0*y)/nd - 1.0;
long a = 0;
for (long x = 0; x < n; x++) {
double cr = (2.0*x)/nd - 1.5;
Janet args[3] = { janet_wrap_number(cr), janet_wrap_number(ci),
janet_wrap_number((double)cap) };
Janet r = janet_call(cp, 3, args);
a += (long)janet_unwrap_number(r);
}
acc += a;
}
return janet_wrap_number((double)acc);
}
static const JanetReg cfuns[] = {
{"run-c", cfun_run_c, "(mandel/run-c n) whole mandelbrot run in native C."},
{"count-point-c", cfun_count_point_c, "(mandel/count-point-c cr ci cap) one point, native C."},
{"run-callback", cfun_run_callback, "(mandel/run-callback n count-point-fn) C loop calling a Janet fn back via janet_call."},
{NULL, NULL, NULL}
};
JANET_MODULE_ENTRY(JanetTable *env) {
janet_cfuns(env, "mandel", cfuns);
}

View file

@ -1,6 +0,0 @@
(declare-project
:name "mandel-native-spike")
(declare-native
:name "mandel"
:source ["mandel.c"])