Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------------

The vendored Shen kernel sources (klambda/) and the official kernel test
suite (tests/) are from the ShenOSKernel 41.2 distribution and are:
suite (tests/) are from the ShenOSKernel 42 distribution and are:

Copyright (c) 2010-2022, Mark Tarver
All rights reserved.
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ primitives on a host runtime and (b) translating the kernel's `.kl` files into
that host. This port does both by **compiling KLambda to Lua source** that
LuaJIT then trace-compiles to machine code.

It targets **Shen 41.2** (the KLambda is vendored under `klambda/`; see
[`klambda/PROVENANCE.md`](klambda/PROVENANCE.md)) and passes the official 41.2
It targets **Shen 42** (the KLambda is vendored under `klambda/`; see
[`klambda/PROVENANCE.md`](klambda/PROVENANCE.md)) and passes the official 42
kernel test suite (134/134). Earlier versions were certified against the Shen
22.4 kernel test suite.

Expand Down Expand Up @@ -155,7 +155,7 @@ configuration.
## Requirements

* **LuaJIT 2.1** (Lua 5.1 semantics). On Debian/Ubuntu: `apt-get install luajit`.
* Nothing else — the **Shen 41.2 KLambda sources** (`klambda/`) are vendored in this
* Nothing else — the **Shen 42 KLambda sources** (`klambda/`) are vendored in this
repository for a self-contained clone-and-run experience. You can still point
`SHEN_KL_DIR` at an external checkout if you are working against a different
ShenOSKernel tree.
Expand Down Expand Up @@ -250,7 +250,7 @@ bin/shen -q prog.shen # -q sets *hush*: silences load echo AND (output

#### Batch and golden-suite runners: `--hush-load`, not `-q`

On the 41.2 kernel the `*hush*` global gates **`pr` itself**, so `-q` silences
On the 42 kernel the `*hush*` global gates **`pr` itself**, so `-q` silences
*all* standard output — including the program's own `(output ...)`. That makes
`-q` useless for a runner that diffs a suite's printed results against a golden
file (issue #46): the file comes back empty.
Expand Down Expand Up @@ -295,8 +295,8 @@ luarocks make --local shen-scm-1.rockspec # or: install the development tree
luarocks tree whose interpreter is LuaJIT, e.g.
`luarocks --lua-dir=$(brew --prefix luajit) --lua-version=5.1 install shen`.)

Rock versions map to kernels: **0.9.0** bundles kernel **41.1**, **0.10.0+**
bundles **41.2** (check with `shen -e '(version)'`). **0.10.1** is the current
Rock versions map to kernels: **0.9.0** bundles kernel **41.1**, while
**0.10.0+** bundles **42** (check with `shen -e '(version)'`). **0.10.1** is the current
release (0.10.0 + the warm-FASL `(load)` echo fix, #40). If luarocks hands you
0.9.0, ask for the newer rock explicitly (`luarocks install shen 0.10.1-1`)
or build from a checkout with the `scm` rockspec above.
Expand Down Expand Up @@ -364,22 +364,22 @@ browser. One `rules.shen`, two runtimes, no client/server drift. See its

## Certification / Testing

The port loads and initialises the full 41.2 kernel plus the standard library
The port loads and initialises the full 42 kernel plus the standard library
(loaded at boot from the S-lineage Shen sources under `lib/StLib/`) and the
extensions, and **passes the official 41.2 kernel test suite, 134/134**:
extensions, and **passes the official 42 kernel test suite, 134/134**:

```sh
luajit run-kernel-tests.lua # => "passed ... 134 / failed ... 0 / pass rate ... 100%"
lua run-kernel-tests.lua # same result on PUC Lua 5.1 / 5.4 / 5.5 (slower)
```

The official test suite is vendored in `tests/` (BSD-licensed, from the
ShenOSKernel 41.2 distribution), so certification is verifiable from a bare
ShenOSKernel 42 distribution), so certification is verifiable from a bare
clone. `SHEN_TESTS_DIR` points the driver at a different suite location.
Port-specific specs live in `test/` (engine, interop, REPL, tail-call
lowering).

See [doc/41.1-STATUS.md](doc/41.1-STATUS.md) for the original 41.1 certification write-up (the 41.2 upgrade re-ran the same suite, 134/134).
See [doc/41.1-STATUS.md](doc/41.1-STATUS.md) for the original certification write-up.

## Benchmarks

Expand All @@ -391,8 +391,8 @@ deterministic metric):
|----------|-----:|
| Kernel boot, cold (compile all `.kl`) | ~0.7 s |
| Kernel boot, warm (bytecode cache) | **~0.03 s** |
| **Full 41.2 test suite, warm** (kernel + fasl caches) | **~2.3 s** |
| Full 41.2 test suite, cold (caches off) | ~5.4 s |
| **Full 42 test suite, warm** (kernel + fasl caches) | **~2.3 s** |
| Full 42 test suite, cold (caches off) | ~5.4 s |
| Reference typecheck (431,741 inferences) | ~0.061 s (8.9× vs legacy engine) |
| Typechecker allocation | ~24 B/inf (−93% vs legacy) |
| Einstein's riddle (Prolog backtracking) | ~0.002 s / solve (22× vs legacy) |
Expand Down
4 changes: 2 additions & 2 deletions bench.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- bench.lua : self-contained benchmark for the 41.2 port
-- bench.lua : self-contained benchmark for the 42 port
-- Runs cold startup, then defines fib through the real Shen pipeline and
-- measures fib(30), fib(32). Also runs Einstein's riddle through the live
-- Prolog engine.
Expand Down Expand Up @@ -68,7 +68,7 @@ local ffi = require("ffi")
ffi.cdef[[
int chdir(const char *path);
]]
if ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests") == 0 then
if ffi.C.chdir("../cl-source/ShenOSKernel-42/tests") == 0 then
-- run the test through Shen's load (which evaluates the file's top forms)
bench("einstein-load", function()
P.F["load"]("einsteins-riddle.shen")
Expand Down
2 changes: 1 addition & 1 deletion bench/alloc_attrib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
local P = require("boot"); local R = require("runtime")
P.load_kernel(false); P.initialise()
local ffi = require("ffi"); ffi.cdef[[int chdir(const char*);]]
ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests")
ffi.C.chdir("../cl-source/ShenOSKernel-42/tests")
local mf=P.F["shen.macros"]
if mf and not P.GLOBALS["*macros*"] then P.GLOBALS["*macros*"]=R.cons(R.cons(R.cons(R.intern("shen.macros"),mf),R.NIL),R.NIL) end
if P.GLOBALS["shen.*tc*"]~=nil and P.GLOBALS["*tc*"]==nil then P.GLOBALS["*tc*"]=P.GLOBALS["shen.*tc*"] end
Expand Down
6 changes: 3 additions & 3 deletions bench/callfreq.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- bench/callfreq.lua — THROWAWAY profiler (Track 0.1).
-- Wraps every F-table entry with a call counter, runs the full 41.2 suite,
-- Wraps every F-table entry with a call counter, runs the full 42 suite,
-- and dumps the most-called functions. Used to find native-override targets.
-- Run from the shen-lua dir: luajit bench/callfreq.lua 2>/tmp/callfreq.txt
package.path = "./?.lua;" .. package.path
Expand All @@ -11,7 +11,7 @@ P.initialise()

local ffi = require("ffi")
ffi.cdef[[int chdir(const char *path);]]
assert(ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests") == 0, "chdir failed")
assert(ffi.C.chdir("../cl-source/ShenOSKernel-42/tests") == 0, "chdir failed")

-- kernel compat seeding (mirror run-kernel-tests.lua)
do
Expand Down Expand Up @@ -50,7 +50,7 @@ P.F["load"]("kerneltests.shen")
local rows = {}
for name, c in pairs(counts) do if c > 0 then rows[#rows+1] = {name, c} end end
table.sort(rows, function(a,b) return a[2] > b[2] end)
io.stderr:write("\n=== CALL FREQUENCY (41.2 suite) ===\n")
io.stderr:write("\n=== CALL FREQUENCY (42 suite) ===\n")
for i = 1, math.min(60, #rows) do
io.stderr:write(string.format("%3d %-32s %12d\n", i, rows[i][1], rows[i][2]))
end
2 changes: 1 addition & 1 deletion bench/evalstats.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- bench/evalstats.lua : measure runtime recompilation over the 41.2 suite.
-- bench/evalstats.lua : measure runtime recompilation over the 42 suite.
-- Counts P.eval calls, compile_top/compile_expr_chunk invocations, duplicate
-- form identities and duplicate generated sources, and total time inside eval.
-- Run from the repo root: luajit bench/evalstats.lua
Expand Down
4 changes: 2 additions & 2 deletions bench/golden_typecheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ ffi.cdef[[int chdir(const char*); char *getcwd(char*, size_t);]]
local cwdbuf = ffi.new("char[4096]")
assert(ffi.C.getcwd(cwdbuf, 4096) ~= nil)
local ROOT = ffi.string(cwdbuf)
assert(ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests") == 0,
"tests dir not found (expected ../cl-source/ShenOSKernel-41.2/tests)")
assert(ffi.C.chdir("../cl-source/ShenOSKernel-42/tests") == 0,
"tests dir not found (expected ../cl-source/ShenOSKernel-42/tests)")

-- same environment fixes typecheck_alloc.lua needs
local mf = P.F["shen.macros"]
Expand Down
2 changes: 1 addition & 1 deletion bench/native_deref_ab.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local P = require("boot"); local R = require("runtime")
P.load_kernel(false); P.initialise()
local ffi=require("ffi"); ffi.cdef[[int chdir(const char*);]]; ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests")
local ffi=require("ffi"); ffi.cdef[[int chdir(const char*);]]; ffi.C.chdir("../cl-source/ShenOSKernel-42/tests")
local mf=P.F["shen.macros"]; if mf and not P.GLOBALS["*macros*"] then P.GLOBALS["*macros*"]=R.cons(R.cons(R.cons(R.intern("shen.macros"),mf),R.NIL),R.NIL) end
if P.GLOBALS["shen.*tc*"]~=nil and P.GLOBALS["*tc*"]==nil then P.GLOBALS["*tc*"]=P.GLOBALS["shen.*tc*"] end
P.F["load"]("interpreter.shen")
Expand Down
2 changes: 1 addition & 1 deletion bench/typecheck_alloc.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local P = require("boot"); local R = require("runtime")
P.load_kernel(false); P.initialise()
local ffi = require("ffi"); ffi.cdef[[int chdir(const char*);]]
ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests")
ffi.C.chdir("../cl-source/ShenOSKernel-42/tests")
local mf=P.F["shen.macros"]
if mf and not P.GLOBALS["*macros*"] then P.GLOBALS["*macros*"]=R.cons(R.cons(R.cons(R.intern("shen.macros"),mf),R.NIL),R.NIL) end
if P.GLOBALS["shen.*tc*"]~=nil and P.GLOBALS["*tc*"]==nil then P.GLOBALS["*tc*"]=P.GLOBALS["shen.*tc*"] end
Expand Down
2 changes: 1 addition & 1 deletion bench/typecheck_time.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local P = require("boot"); local R = require("runtime")
P.load_kernel(false); P.initialise()
local ffi = require("ffi"); ffi.cdef[[int chdir(const char*);]]
ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests")
ffi.C.chdir("../cl-source/ShenOSKernel-42/tests")
local mf=P.F["shen.macros"]
if mf and not P.GLOBALS["*macros*"] then P.GLOBALS["*macros*"]=R.cons(R.cons(R.cons(R.intern("shen.macros"),mf),R.NIL),R.NIL) end
if P.GLOBALS["shen.*tc*"]~=nil and P.GLOBALS["*tc*"]==nil then P.GLOBALS["*tc*"]=P.GLOBALS["shen.*tc*"] end
Expand Down
2 changes: 1 addition & 1 deletion bench/wam_fingerprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package.path = "./?.lua;" .. package.path
local P = require("boot"); local R = require("runtime")
P.load_kernel(false); P.initialise()
local ffi = require("ffi"); ffi.cdef[[int chdir(const char*);]]
ffi.C.chdir("../cl-source/ShenOSKernel-41.2/tests")
ffi.C.chdir("../cl-source/ShenOSKernel-42/tests")
local mf=P.F["shen.macros"]
if mf and not P.GLOBALS["*macros*"] then P.GLOBALS["*macros*"]=R.cons(R.cons(R.cons(R.intern("shen.macros"),mf),R.NIL),R.NIL) end
if P.GLOBALS["shen.*tc*"]~=nil and P.GLOBALS["*tc*"]==nil then P.GLOBALS["*tc*"]=P.GLOBALS["shen.*tc*"] end
Expand Down
2 changes: 1 addition & 1 deletion bin/shen
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ usage: shen [-q] [--hush-load] [-e EXPR | FILE] ...
FILE (load) the file (full Shen syntax), then exit
-e, --eval EXPR evaluate EXPR and print its value
-q, --quiet (set *hush* true) — silence load echo and hushable output
(on the 41.2 kernel *hush* gates pr itself, so -q also
(on the 42 kernel *hush* gates pr itself, so -q also
silences the program's own (output ...) lines)
--hush-load silence only load's chatter — the per-form value/type
echo and "run time"/"typechecked" banners; (output ...)
Expand Down
10 changes: 5 additions & 5 deletions bin/yggdrasil-build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- luajit bin/yggdrasil-build.lua <shaken-dir> <out.lua> [--linked]
--
-- <shaken-dir> is a Yggdrasil stage-1 output directory: a tree-shaken
-- kernel (kernel.kl, ShenOSKernel-41.2 defuns in load order), the user
-- kernel (kernel.kl, ShenOSKernel-42 defuns in load order), the user
-- program as KL (one or more user= files), and yggdrasil.manifest.txt.
-- The builder compiles every KL form ahead of time with the port's own
-- compiler (compiler.lua C.compile_top) and emits ONE runnable Lua
Expand All @@ -27,7 +27,7 @@
-- "lib boot" derived from boot.lua —
-- 1. jit.opt mcode-area tuning (perf only, SHEN_JIT_OPT=off to skip),
-- 2. *stinput*/*stoutput*/*sterror* stream setup + *home-directory*,
-- 3. platform globals (*language* ... *release*) the 41.2 kernel reads,
-- 3. platform globals (*language* ... *release*) the 42 kernel reads,
-- 4. run the compiled kernel chunks (the shaken defuns, in load order),
-- 5. install the native overrides that REPLACE kernel KL functions
-- (P.install_native_prolog + P.install_native_stdlib, after the
Expand Down Expand Up @@ -108,8 +108,8 @@ end
assert(man.kernel, MANIFEST .. ": missing kernel=")
assert(man.init, MANIFEST .. ": missing init=")
assert(#man.user > 0, MANIFEST .. ": no user= entries")
if man["kernel-version"] ~= "41.2" then
io.stderr:write(("yggdrasil-build: warning: manifest kernel-version=%s, this port is certified against 41.2\n")
if man["kernel-version"] ~= "42" then
io.stderr:write(("yggdrasil-build: warning: manifest kernel-version=%s, this port is certified against 42\n")
:format(tostring(man["kernel-version"])))
end

Expand Down Expand Up @@ -159,7 +159,7 @@ end
-- Walk every form collecting names in call (head) position that are neither
-- locally bound, port-provided (P.F / special forms), nor defined by a defun
-- in the shaken output. Any such name found in the port's vendored certified
-- 41.2 kernel (klambda/*.kl) is BACKFILLED into the kernel chunk — with a
-- 42 kernel (klambda/*.kl) is BACKFILLED into the kernel chunk — with a
-- loud warning, because each backfill is a stage-1 shaker bug that should be
-- fixed in yggdrasil.shen. Names found nowhere are warn-only (they may be
-- guarded-dead, like shen.write-string behind shen.char-stoutput?).
Expand Down
Loading
Loading