16 new opcodes (160-175) bypass the CALL_PRIM hashtable lookup for the most frequently called primitives: Arithmetic: OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_INC, OP_DEC, OP_NEG Comparison: OP_EQ, OP_LT, OP_GT, OP_NOT Collection: OP_LEN, OP_FIRST, OP_REST, OP_NTH, OP_CONS The compiler (compiler.sx) recognizes these names at compile time and emits the inline opcode instead of CALL_PRIM. The opcode is self- contained — no constant pool index, no argc byte. Each primitive is a single byte in the bytecode stream. Implementation in all three VMs: - OCaml (sx_vm.ml): direct pattern match, no allocation - SX spec (vm.sx): delegates to existing primitives - JS (transpiled): same as SX spec 66 new tests in spec/tests/vm-inline.sx covering arithmetic, comparison, collection ops, composition, and edge cases. Tests: 1314 JS (full), 1114 OCaml, 32 Playwright Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.7 KiB
3.7 KiB