Move the engine core into core/, a project of its own (pplus-core)
What programs mean (the languages, translators, Mojo checker and
interpreter, prover, fuzzer, machine model, catalog problems and the Mojo
corpus with godbolt's stored answers) was mixed into the site's tree, so a
change to the prover and a change to a button went through the same gate
and the same docs. This moves all of it under core/, laid out as its own
repository, ready to be extracted with its history and pinned here as a
git submodule.
- core/: src/{engines,services,sync,mojo,exercises,curriculum,common},
mojo/, syntax/mojo.xml, its tests (with Workspace and workForProblem in
place of the site's Session), scripts (corpus pipeline, play, the
exercise and probe starters, engines export/diff), and its docs
(engines, trust, mojo-corpus, exercises, coverage). Its own pixi.toml,
package.json, README, AGENTS.md and CI workflow.
- core/tests/boundary.test.mjs: library modules use no DOM, import no
page widget, and import nothing outside src/.
- core/scripts/cli.mjs: pixi run cli check|run|prove|fuzz|translate.
- core/scripts/dafny.py: Dafny 4.11.0 pinned by version and SHA-256 per
platform, fetched into .tools/ (pixi run dafny-fetch, pixi run dafny).
- The site imports core only as #core/<path>.js: an import map in
index.html, "imports" in package.json for node, core's declarations for
tsc. The site's TypeScript builds core first (npm run build).
- assemble.sh, the Quarto engine copy, the render cache key, check-pages,
quarto-export and quarto-css read core/dist and core/mojo; quarto-css
copies core's syntax/mojo.xml into the extension.
- Site tests that covered engines moved to core; the rest keep Session.
- README, AGENTS.md, docs/app.md, docs/deploy.md and the CI workflow
describe the split (checkout with submodules; core's tests and corpus
status run against the pinned commit).
Gate: site 110 pass; core 307 pass; corpus status --strict passes.
Manual check: the assembled site opens Bridge (count-base-proved),
Developer and Hardware (count-base) with the editor, the stepper and the
board, and no module errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
This commit is contained in:
1567 files changed
+3670
-981
No files matched your search
@@ -0,0 +1,67 @@
|
||||
// The assembly census (scripts/asm-census.mjs) as a ratchet: every function the
|
||||
// real compiler produced for the user's own code assembles on the model machine,
|
||||
// the library functions that assemble never get fewer, and the instructions
|
||||
// outside the model's set are only the 256-bit AVX2 ones the model says it
|
||||
// does not have. A new corpus item that brings a new instruction fails here,
|
||||
// which is the point.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { census } from '../scripts/asm-census.mjs';
|
||||
import { parseAsm, runAsmProgram } from '../dist/services/asm.js';
|
||||
import { intelLine } from '../dist/mojo/att.js';
|
||||
|
||||
const LIBRARY_AT_LEAST = 438; // raise as the machine learns more
|
||||
const OUTSIDE = new Set(['vextracti128', 'vinserti128', 'vpblendvb', 'vperm2i128', 'vpalignr']); // ymm: 256-bit AVX2
|
||||
|
||||
test('every user function in the corpus listings assembles on the model machine', () => {
|
||||
const c = census();
|
||||
assert.deepEqual(c.userFailures, []);
|
||||
assert.equal(c.userOk, c.user);
|
||||
assert.ok(c.user >= 7, `only ${c.user} user functions in the corpus`);
|
||||
});
|
||||
|
||||
test('the library functions that assemble do not get fewer, and what is outside the set is only AVX2', () => {
|
||||
const c = census();
|
||||
assert.ok(c.libOk >= LIBRARY_AT_LEAST, `${c.libOk} library functions assemble, fewer than ${LIBRARY_AT_LEAST}`);
|
||||
const unexpected = c.missing.map(([op]) => op).filter((op) => !OUTSIDE.has(op));
|
||||
assert.deepEqual(unexpected, [], 'instructions the corpus uses that the model neither has nor lists as outside it');
|
||||
});
|
||||
|
||||
test('the AT&T translator strips the size suffix from the BMI and atomic mnemonics and keeps lock', () => {
|
||||
const map = new Map();
|
||||
assert.equal(intelLine('andnq %rax, %r9, %rax', map), 'andn rax, r9, rax');
|
||||
assert.equal(intelLine('mulxq %rcx, %rdx, %rdx', map), 'mulx rdx, rdx, rcx');
|
||||
assert.equal(intelLine('lock xaddq %rax, (%rcx)', map), 'lock xadd qword ptr [rcx], rax');
|
||||
assert.equal(intelLine('shlxq %rcx, %rbx, %r11', map), 'shlx r11, rbx, rcx');
|
||||
assert.equal(intelLine('vpcmpeqb %xmm1, %xmm0, %xmm3', map), 'vpcmpeqb xmm3, xmm0, xmm1');
|
||||
});
|
||||
|
||||
test('the instructions compiled Mojo uses compute what the manual says', () => {
|
||||
const run = (src, setup = '') => { const p = parseAsm(src); assert.ok(p.ok, p.diagnostics.map((d) => d.message).join('; ')); return runAsmProgram(p, { setup, machine: 'teaching', maxSteps: 200 }); };
|
||||
const st = run([
|
||||
'mov rdx, 6', 'mov rcx, 7', 'mulx r8, r9, rcx',
|
||||
'mov rax, 0xff00', 'mov rbx, 0x0ff0', 'andn r10, rax, rbx',
|
||||
'mov rcx, 3', 'shlx r11, rbx, rcx', 'sarx r12, rax, rcx', 'bzhi r13, rbx, rcx',
|
||||
'mov rsi, 12', 'blsr rdi, rsi', 'blsi r14, rsi', 'blsmsk r15, rsi', 'rorx rbx, rsi, 1',
|
||||
'mov rax, 1', 'mov qword ptr [0x1000], 10', 'lock xadd qword ptr [0x1000], rax',
|
||||
'mov rax, 11', 'mov rcx, 99', 'lock cmpxchg qword ptr [0x1000], rcx',
|
||||
'bts rdx, 4', 'mov eax, 0x12345678', 'bswap eax',
|
||||
].join('\n'), 'memory 0x1000 "........"');
|
||||
const s = st.states[st.count];
|
||||
assert.equal(st.error, null);
|
||||
assert.equal(s.regs.r9, 42n); assert.equal(s.regs.r8, 0n);
|
||||
assert.equal(s.regs.r10, 0xf0n); assert.equal(s.regs.r11, 0x7f80n); assert.equal(s.regs.r12, 0x1fe0n); assert.equal(s.regs.r13, 0n);
|
||||
assert.equal(s.regs.rdi, 8n); assert.equal(s.regs.r14, 4n); assert.equal(s.regs.r15, 7n); assert.equal(s.regs.rbx, 6n);
|
||||
assert.equal(s.regs.rdx, 22n); assert.equal(s.regs.rax, 0x78563412n); assert.equal(s.flags.ZF, true);
|
||||
assert.equal(s.mem.find((m) => m.addr === 0x1000).bytes[0], 99, 'cmpxchg stored the new value');
|
||||
// vectors: a broadcast compare finds every A in GATTACAGATTACA
|
||||
const v = run(['vmovdqu xmm1, xmmword ptr [0x1000]', 'mov eax, 0x41', 'vmovd xmm4, eax', 'vpbroadcastb xmm4, xmm4', 'vpcmpeqb xmm3, xmm1, xmm4', 'vpmovmskb r8d, xmm3', 'vpextrb eax, xmm1, 1', 'vpshufd xmm5, xmm1, 0x1b'].join('\n'), 'memory 0x1000 "GATTACAGATTACA.."');
|
||||
const vs = v.states[v.count];
|
||||
assert.equal(vs.regs.r8, 0b10100101010010n); assert.equal(vs.regs.rax, 0x41n);
|
||||
// ud2 stops the run and says why
|
||||
const u = run('mov rax, 1\nud2');
|
||||
assert.match(u.error.message, /invalid-opcode/);
|
||||
// a stub for the standard library stops the run and names the function
|
||||
const stub = run('call std_io_io_print\nstd_io_io_print:\n ud2 ; std_io_io_print: standard library, not on the model machine');
|
||||
assert.match(stub.error.message, /std_io_io_print: standard library, not on the model machine/);
|
||||
});
|
||||
Reference in new issue
Block a user