vm-ext: phase A — extension dispatch fallthrough in sx_vm.ml
Adds Invalid_opcode of int exception and extension_dispatch_ref forward ref (default raises Invalid_opcode op), plus the |op when op >= 200 arm before the catch-all in the bytecode dispatch loop. Partition comment documents 1-199 core / 200-247 extensions / 248-255 reserved. Phase B will install the real registry's dispatch into the ref at module init, replacing this stub. Tests: 4 new foundation cases (Invalid_opcode for 200/224/247, Eval_error for 199 to pin the threshold). +4 pass vs baseline, no regressions.
This commit is contained in:
@@ -237,13 +237,13 @@ Five sub-phases in dependency order. Each is testable in isolation.
|
||||
|
||||
### Phase A — Opcode ID partition + dispatch fallthrough
|
||||
|
||||
- [ ] Define `exception Invalid_opcode of int` in `sx_vm.ml`.
|
||||
- [ ] Add `extension_dispatch_ref : (int -> vm -> frame -> unit) ref`
|
||||
- [x] Define `exception Invalid_opcode of int` in `sx_vm.ml`.
|
||||
- [x] Add `extension_dispatch_ref : (int -> vm -> frame -> unit) ref`
|
||||
whose default handler raises `Invalid_opcode op`. Forward-declared in
|
||||
the same style as the existing `jit_compile_ref`.
|
||||
- [ ] Add `| op when op >= 200 -> !extension_dispatch_ref op vm frame` arm
|
||||
- [x] Add `| op when op >= 200 -> !extension_dispatch_ref op vm frame` arm
|
||||
in the dispatch loop, immediately before the catch-all.
|
||||
- [ ] Document the partition in a comment near the top of the opcode list.
|
||||
- [x] Document the partition in a comment near the top of the opcode list.
|
||||
|
||||
**Tests:**
|
||||
- All existing OCaml VM/CEK tests pass unchanged (zero regression for core).
|
||||
@@ -457,3 +457,18 @@ familiarity.
|
||||
|
||||
Newest first.
|
||||
|
||||
- **2026-05-14** — Phase A done. Added `Invalid_opcode of int` exception,
|
||||
`extension_dispatch_ref` (default raises `Invalid_opcode op`), and the
|
||||
`| op when op >= 200 -> !extension_dispatch_ref op vm frame` arm before the
|
||||
catch-all in `sx_vm.ml`. Partition comment documents 1-199 core / 200-247
|
||||
extensions / 248-255 reserved (current core ceiling is OP_DEC = 175).
|
||||
4 new foundation tests (3 × Invalid_opcode for opcodes 200/224/247, 1 ×
|
||||
Eval_error for opcode 199 to pin the threshold). Foundation 64/64;
|
||||
full OCaml test suite +4 pass vs baseline (4807 vs 4803), 1111 pre-existing
|
||||
failures unchanged. Conformance suites green: erlang 530/530, haskell
|
||||
285/285, datalog 276/276, prolog 590/590, smalltalk 847/847, common-lisp
|
||||
305/305, apl 562/562, js 148/148, forth 632/638 (pre-existing), tcl 3/4
|
||||
(pre-existing), ocaml-on-sx unit 607/607. (Lua 0/16 and ocaml-conformance
|
||||
baseline programs not exercised — pre-existing scoreboard state and
|
||||
multi-hour runtime respectively.)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user