code wiki / _hdl_build / nx_jsvm_sota_research_fetch.nx

nx_jsvm_sota_research_fetch.nx source

↩ module page · 104 lines · 6749 B

1// nx_jsvm_sota_research_fetch.nx -- SOVEREIGN research round: JS-ENGINE STATE OF THE ART, July 2026 2// (operator 2026-07-07: "we want to get to state of the art on everything and not just classic ... 3// july 7th state of the art use the nishi researcher"). Grounds the nx_js_sota_bench ladder in REAL 4// sources instead of memory-toss: what makes V8/JSC/SpiderMonkey fast in 2026 (tiered JITs -- 5// Ignition->Sparkplug->Maglev->TurboFan; hidden classes/shapes; INLINE CACHES; generational GC) 6// and where the interpreter-class ceiling sits (QuickJS bench page = concrete reference numbers). 7// Mirrors nx_codec_research_fetch: own TLS (nx_https_fetch_follow) + Mozilla CA, idempotent 8// have-skip, nx_cc->nxasm. Wikipedia = orientation; v8.dev/bellard.org = canonical engine pages. 9// Saves knowledge/fetched/jsvm_*.raw so the corpus COMPOUNDS (run knowledge/research_ingest.sh after). 10// expect_exit: 0 license_tier: ORIGINAL 11import "nx_syscalls.nx" 12import "nx_x509_trust_store.nx" 13import "nx_trust_store_load_from_certdata.nx" 14import "nx_https_fetch_follow.nx" 15const K_MAGIC_4194304: i64 = 4194304 16const K_MAGIC_8388608: i64 = 8388608 17 18func jf_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 19func jf_putn(v: i64) -> i64 { 20 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 21 var m: i64 = v 22 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 23 let d: *u8 = sys_mmap(24) 24 var k: i64 = 0 25 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 26 let o: *u8 = sys_mmap(24) 27 var q: i64 = k - 1 28 var x: i64 = 0 29 while q >= 0 { o[x] = d[q]; x = x + 1; q = q - 1 } 30 sys_write(1, o, x) 31 return 0 32} 33func have_file(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 34func fetch_save(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 { 35 if have_file(opath) == 1 { jf_puts(opath); jf_puts(" [have-skip]\n" as *u8); return 1 } 36 let status: *i64 = sys_mmap(8) as *i64 37 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status) 38 jf_puts(url) 39 jf_puts(" status=" as *u8) 40 jf_putn(status[0]) 41 jf_puts(" bytes=" as *u8) 42 jf_putn(n) 43 if n <= 0 { jf_puts(" FETCH-FAIL\n" as *u8); return 0 } 44 var gz: i64 = 0 45 if n >= 2 { if out[0] == 0x1f as u8 { if out[1] == 0x8b as u8 { gz = 1 } } } 46 if gz == 1 { jf_puts(" [GZIP-skip]\n" as *u8); return 0 } 47 let fd: i64 = sys_openat_wr(opath, 0x1a4) 48 if fd < 0 { jf_puts(" SAVE-FAIL\n" as *u8); return 0 } 49 sys_write(fd, out, n) 50 sys_close(fd) 51 jf_puts(" SAVED\n" as *u8) 52 return 1 53} 54 55func main() -> i64 { 56 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 57 if r <= 0 { jf_puts("JSVM-SOTA: certdata load failed\n" as *u8); return 1 } 58 let store: *TrustStore = r as *TrustStore 59 jf_puts("CA roots=" as *u8) 60 jf_putn(trust_store_count(store)) 61 jf_puts("\n" as *u8) 62 let cap: i64 = K_MAGIC_8388608 63 let out: *u8 = sys_mmap(cap) 64 var ok: i64 = 0 65 66 jf_puts("== THE 2026 PERFORMANCE PILLARS (what separates SOTA from an interpreter) ==\n" as *u8) 67 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Inline_caching" as *u8, "knowledge/fetched/jsvm_inline_caching.raw" as *u8, store, out, cap) 68 ok = ok + fetch_save("https://v8.dev/docs/hidden-classes" as *u8, "knowledge/fetched/jsvm_hidden_classes.raw" as *u8, store, out, cap) 69 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Just-in-time_compilation" as *u8, "knowledge/fetched/jsvm_jit.raw" as *u8, store, out, cap) 70 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Tracing_garbage_collection" as *u8, "knowledge/fetched/jsvm_gc_tracing.raw" as *u8, store, out, cap) 71 72 jf_puts("== V8's TIER LADDER (Ignition -> Sparkplug -> Maglev -> TurboFan) ==\n" as *u8) 73 ok = ok + fetch_save("https://v8.dev/blog/sparkplug" as *u8, "knowledge/fetched/jsvm_sparkplug.raw" as *u8, store, out, cap) 74 ok = ok + fetch_save("https://v8.dev/blog/maglev" as *u8, "knowledge/fetched/jsvm_maglev.raw" as *u8, store, out, cap) 75 ok = ok + fetch_save("https://v8.dev/blog/ignition-interpreter" as *u8, "knowledge/fetched/jsvm_ignition.raw" as *u8, store, out, cap) 76 ok = ok + fetch_save("https://v8.dev/blog/turbofan-jit" as *u8, "knowledge/fetched/jsvm_turbofan.raw" as *u8, store, out, cap) 77 78 jf_puts("== 2025/26 OPTIMIZING-TIER SOTA (what to build for P6 -- the #1 gap vs V8) ==\n" as *u8) 79 ok = ok + fetch_save("https://v8.dev/blog/leaving-the-sea-of-nodes" as *u8, "knowledge/fetched/jsvm_seaofnodes_2025.raw" as *u8, store, out, cap) 80 ok = ok + fetch_save("https://v8.dev/docs/turboshaft" as *u8, "knowledge/fetched/jsvm_turboshaft.raw" as *u8, store, out, cap) 81 ok = ok + fetch_save("https://peps.python.org/pep-0744/" as *u8, "knowledge/fetched/jsvm_copypatch_cpython.raw" as *u8, store, out, cap) 82 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Register_allocation" as *u8, "knowledge/fetched/jsvm_regalloc.raw" as *u8, store, out, cap) 83 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Static_single-assignment_form" as *u8, "knowledge/fetched/jsvm_ssa.raw" as *u8, store, out, cap) 84 85 jf_puts("== THE OTHER 2026 ENGINES (architecture cross-check) ==\n" as *u8) 86 ok = ok + fetch_save("https://en.wikipedia.org/wiki/SpiderMonkey" as *u8, "knowledge/fetched/jsvm_spidermonkey.raw" as *u8, store, out, cap) 87 ok = ok + fetch_save("https://en.wikipedia.org/wiki/JavaScriptCore" as *u8, "knowledge/fetched/jsvm_jsc.raw" as *u8, store, out, cap) 88 ok = ok + fetch_save("https://en.wikipedia.org/wiki/JavaScript_engine" as *u8, "knowledge/fetched/jsvm_engines.raw" as *u8, store, out, cap) 89 90 jf_puts("== INTERPRETER-CLASS REFERENCE NUMBERS (QuickJS = the honest ceiling w/o a JIT) ==\n" as *u8) 91 ok = ok + fetch_save("https://bellard.org/quickjs/bench.html" as *u8, "knowledge/fetched/jsvm_quickjs_bench.raw" as *u8, store, out, cap) 92 ok = ok + fetch_save("https://bellard.org/quickjs/" as *u8, "knowledge/fetched/jsvm_quickjs_home.raw" as *u8, store, out, cap) 93 94 jf_puts("== THE BENCHMARKS THE FIELD SCORES ON (2026) ==\n" as *u8) 95 ok = ok + fetch_save("https://browserbench.org/JetStream/" as *u8, "knowledge/fetched/jsvm_jetstream.raw" as *u8, store, out, cap) 96 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Browser_speed_test" as *u8, "knowledge/fetched/jsvm_browser_bench.raw" as *u8, store, out, cap) 97 98 jf_puts("JSVM-SOTA research round: ok=" as *u8) 99 jf_putn(ok) 100 jf_puts("/15\n" as *u8) 101 if ok >= 10 { jf_puts("=== GREEN: SOTA corpus banked (>=10/15) ===\n" as *u8); return 0 } 102 jf_puts("=== RED: too few sources banked ===\n" as *u8) 103 return 1 104}