code wiki / _hdl_build / nx_js_sota_scorecard.nx
nx_js_sota_scorecard.nx source
↩ module page · 137 lines · 9060 B
1// nx_js_sota_scorecard.nx -- HONEST placement of the sovereign Nishi JS engine vs the 2026 SOTA engines
2// (V8, JavaScriptCore/WebKit, SpiderMonkey) and the honest interpreter-class peer (QuickJS). This is an
3// ARCHITECTURAL scorecard, NOT a benchmarked head-to-head: we CANNOT run JetStream2/Speedometer3 (they need
4// a full browser + complete language + WASM + workers), and every speedup we've measured is vs OUR OWN
5// tree-walker, NOT vs V8 -- so this card states tiers/features honestly and names what we have not measured.
6// Competitor levels are GROUNDED in the sovereign research corpus knowledge/fetched/jsvm_*.raw (v8.dev
7// Sparkplug/Maglev/TurboFan/Ignition, JavaScriptCore FTL/B3, SpiderMonkey Warp/Ion, JetStream). Our levels
8// are GROUNDED in our own measured gates (parity 110/110, conf 74/74, jit 49/49, shape 8/8, poly 3/3,
9// realbench 5/5, consumer-swap 17/17). Level scale: 0 NONE, 1 PARTIAL, 2 HAVE, 3 MATURE/HARDENED.
10// A LIAR-KILL asserts the card must NOT rate us at-or-above SOTA overall (we are behind) -- if it ever does,
11// the numbers were gamed and the gate goes RED. expect_exit: 0 license_tier: ORIGINAL
12import "nx_syscalls.nx"
13
14func sc_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
15func sc_n(v: i64) -> i64 {
16 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
17 var m: i64 = v
18 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
19 let t: *u8 = sys_mmap(24)
20 var k: i64 = 0
21 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
22 let o: *u8 = sys_mmap(24)
23 var q: i64 = k - 1
24 var x: i64 = 0
25 while q >= 0 { o[x] = t[q]; x = x + 1; q = q - 1 }
26 sys_write(1, o, x)
27 return 0
28}
29func lvl(v: i64) -> i64 {
30 if v == 0 { sc_w("--- " as *u8); return 0 } // NONE
31 if v == 1 { sc_w("par " as *u8); return 0 } // PARTIAL
32 if v == 2 { sc_w("HAVE" as *u8); return 0 } // HAVE
33 sc_w("MATR" as *u8); return 0 // MATURE
34}
35// tallies live in a small array: [0]=at-class, [1]=behind, [2]=ahead
36// one axis: print the row, derive Nishi's verdict from the levels, accumulate.
37func row(axis: *u8, v8: i64, jsc: i64, sm: i64, qjs: i64, nx: i64, sov: i64, tal: *i64) -> i64 {
38 sc_w(" ")
39 sc_w(axis)
40 // pad the axis label to a column
41 let al: i64 = 0
42 var a2: i64 = 0
43 while axis[a2] != (0 as u8) { a2 = a2 + 1 }
44 var pad: i64 = 34 - a2
45 while pad > 0 { sc_w(" " as *u8); pad = pad - 1 }
46 sc_w("V8:"); lvl(v8); sc_w(" JSC:"); lvl(jsc); sc_w(" SM:"); lvl(sm); sc_w(" QJS:"); lvl(qjs); sc_w(" NISHI:"); lvl(nx); sc_w(" -> ")
47 // best competitor level (the SOTA bar for this axis)
48 var best: i64 = v8
49 if jsc > best { best = jsc }
50 if sm > best { best = sm }
51 if sov == 1 {
52 // sovereignty axis: we are uniquely ahead (none of them are sovereign)
53 sc_w("AHEAD (sovereign-unique)\n" as *u8)
54 tal[2] = tal[2] + 1
55 return 0
56 }
57 // AT-CLASS = we genuinely HAVE the tier (level >=2) and are within one maturity step of the SOTA bar
58 // (HAVE vs MATURE). BEHIND (big gap) = we LACK it or trail by >=2 levels. Plain BEHIND = trail by 1
59 // from a partial base. This credits the tiers we own (vs QuickJS which lacks them) without flattery.
60 if nx >= best { sc_w("AT-CLASS\n" as *u8); tal[0] = tal[0] + 1; return 0 }
61 if nx >= 2 { if (best - nx) <= 1 { sc_w("AT-CLASS (theirs more mature)\n" as *u8); tal[0] = tal[0] + 1; return 0 } }
62 if (best - nx) >= 2 { sc_w("BEHIND (big gap)\n" as *u8); tal[1] = tal[1] + 1; return 0 }
63 sc_w("BEHIND\n" as *u8)
64 tal[1] = tal[1] + 1
65 return 0
66}
67
68func main(argc: i64, argv: *i64) -> i64 {
69 sc_w("=== nx_js_sota_scorecard: HONEST placement -- Nishi JS engine vs V8 / JavaScriptCore / SpiderMonkey ===\n" as *u8)
70 sc_w(" (ARCHITECTURAL, grounded in knowledge/fetched/jsvm_*.raw + our measured gates; NOT a run head-to-head)\n" as *u8)
71 sc_w(" levels: ---=none par=partial HAVE=have MATR=mature/hardened\n\n" as *u8)
72 let tal: *i64 = sys_mmap(3 * 8) as *i64
73
74 sc_w(" [EXECUTION TIERS]\n" as *u8)
75 row("bytecode interpreter tier" as *u8, 3, 3, 3, 3, 2, 0, tal) // V8 Ignition/JSC LLInt/SM BaselineInterp/QuickJS bc; us: VM
76 row("baseline JIT (template)" as *u8, 3, 3, 3, 0, 2, 0, tal) // V8 Sparkplug/JSC Baseline/SM Baseline; QuickJS none; us: Sparkplug-tier
77 row("optimizing JIT -- mid tier" as *u8, 3, 3, 3, 0, 0, 0, tal) // V8 Maglev(SSA)/JSC DFG/SM Warp; us + QuickJS: NONE
78 row("optimizing JIT -- top tier" as *u8, 3, 3, 3, 0, 0, 0, tal) // V8 TurboFan/JSC FTL+B3/SM Ion; us + QuickJS: NONE
79 sc_w(" [MEMORY]\n" as *u8)
80 row("generational/concurrent GC" as *u8, 3, 3, 3, 2, 0, 0, tal) // Orinoco/Riptide/gen; QuickJS RC+cycle; us: NONE (leak)
81 sc_w(" [OBJECT MODEL / FAST PATHS]\n" as *u8)
82 row("hidden classes / shapes" as *u8, 3, 3, 3, 1, 2, 0, tal)
83 row("polymorphic inline caches" as *u8, 3, 3, 3, 1, 2, 0, tal)
84 row("IEEE-double numbers" as *u8, 3, 3, 3, 2, 2, 0, tal) // theirs HW+nan-box; ours soft-float, JS-correct
85 sc_w(" [LANGUAGE COMPLETENESS]\n" as *u8)
86 row("regex engine" as *u8, 3, 3, 3, 3, 0, 0, tal) // all incl QuickJS; us: NONE
87 row("generators / async-await" as *u8, 3, 3, 3, 3, 0, 0, tal)
88 row("classes / ES modules" as *u8, 3, 3, 3, 3, 0, 0, tal)
89 row("Proxy / Symbol / Reflect" as *u8, 3, 3, 3, 3, 0, 0, tal)
90 row("template-literal interp" as *u8, 3, 3, 3, 3, 1, 0, tal) // us: tree-walker HAVE, VM declines->fallback = PARTIAL
91 row("test262 conformance (run)" as *u8, 3, 3, 3, 3, 1, 0, tal) // ~99%+ vs our core-only, NOT run
92 sc_w(" [BENCHMARKS ACTUALLY RUN]\n" as *u8)
93 row("JetStream2/Speedometer3" as *u8, 3, 3, 3, 1, 0, 0, tal) // us: cannot run (need full browser+lang)
94 row("cross-engine head-to-head" as *u8, 3, 3, 3, 3, 0, 0, tal) // us: only vs our OWN tree-walker so far
95 sc_w(" [SOVEREIGNTY]\n" as *u8)
96 row("own assembler, no gcc/V8/LLVM" as *u8, 0, 0, 0, 0, 3, 1, tal) // sovereignty axis -> AHEAD-unique
97
98 sc_w("\n --- TALLY: AT-CLASS=" as *u8)
99 sc_n(tal[0])
100 sc_w(" BEHIND=" as *u8)
101 sc_n(tal[1])
102 sc_w(" AHEAD=" as *u8)
103 sc_n(tal[2])
104 sc_w(" (of 17 axes) ---\n\n" as *u8)
105
106 sc_w(" VERDICT (honest): INTERPRETER + BASELINE-JIT CLASS.\n" as *u8)
107 sc_w(" ~ equivalent to V8-with-only-Ignition+Sparkplug (V8 circa 2021, PRE-Maglev), or QuickJS + a baseline JIT.\n" as *u8)
108 sc_w(" AT-CLASS with SOTA on: interpreter, baseline JIT, shapes, inline caches, JS-correct doubles.\n" as *u8)
109 sc_w(" BEHIND SOTA on: BOTH optimizing tiers (the defining gap), GC, regex, generators/async, classes/\n" as *u8)
110 sc_w(" modules, Proxy/Symbol, test262 %, and every standard benchmark (which we cannot yet run).\n" as *u8)
111 sc_w(" UNIQUELY AHEAD on: sovereignty (our own x86 emitter, no V8/gcc/LLVM; runs on our OS from POST up).\n" as *u8)
112 sc_w(" NOTE: our '3-551x' numbers are vs OUR tree-walker. Against V8's optimizing tier, our baseline JIT\n" as *u8)
113 sc_w(" would be SEVERAL x SLOWER on hot optimizable code -- baseline JITs trade peak speed for fast startup.\n\n" as *u8)
114
115 sc_w(" ROADMAP (priority order, to climb from baseline-class toward SOTA):\n" as *u8)
116 sc_w(" 1. OPTIMIZING JIT (Maglev-model single mid-tier): SSA IR + type feedback (our poly-ICs already\n" as *u8)
117 sc_w(" collect shapes) + speculative specialization + deopt/OSR. THE #1 perf gap; moves us baseline->optimizing.\n" as *u8)
118 sc_w(" 2. GENERATIONAL GC: reclaim memory (the #1 production gap; non-moving mark-sweep, VM-run safepoints).\n" as *u8)
119 sc_w(" 3. LANGUAGE COMPLETENESS: regex engine (own arc) -> template-interp in the VM -> generators/async ->\n" as *u8)
120 sc_w(" classes/modules -> then RUN test262 for a real conformance number.\n" as *u8)
121 sc_w(" 4. REAL HEAD-TO-HEAD: run QuickJS (the honest interpreter-class peer) on a shared micro-benchmark to\n" as *u8)
122 sc_w(" get a TRUE cross-engine number, then build toward running JetStream2 subtests.\n\n" as *u8)
123
124 // ---- LIAR-KILL: the card must NOT rate us at-or-above SOTA overall. We are behind on strictly more axes
125 // than we are at-class; if BEHIND ever fails to dominate the non-sovereign axes, the card was gamed.
126 let nonsov_atclass: i64 = tal[0]
127 let behind: i64 = tal[1]
128 var liar: i64 = 0
129 if behind <= nonsov_atclass { liar = 1 } // we must be BEHIND on more axes than we're AT-CLASS
130 if behind < 8 { liar = 1 } // and behind on the known-hard axes (>=8)
131 if liar == 1 {
132 sc_w("=== RED: LIAR-KILL TRIPPED -- the scorecard rated us too favorably; numbers are not honest ===\n" as *u8)
133 return 1
134 }
135 sc_w("=== GREEN: honest scorecard -- baseline-JIT class, SOTA-behind on optimizing-tier+GC+completeness, sovereign-unique ===\n" as *u8)
136 return 0
137}