code wiki / _hdl_build / nx_js_octane_deltablue.nx
nx_js_octane_deltablue.nx source
↩ module page · 44 lines · 3062 B
1// nx_js_octane_deltablue.nx -- run the REAL Octane DeltaBlue benchmark (unmodified Google source, harness
2// stubbed; alert() stubbed to THROW so any solver error fails the run). deltaBlue() = chainTest(100) +
3// projectionTest(100): a full one-way constraint solver -- Object.defineProperty/Object.prototype-installed
4// inheritsFrom inheritance, superConstructor.call, planner satisfy cascades, object-identity equality.
5// "DELTABLUE_OK" = both tests completed with correct dataflow (they alert on any wrong value).
6// V8 pin (node v22, this box, warmed): 4852us. expect_exit: 0 license_tier: ORIGINAL
7import "nx_js_vm.nx"
8const K_MAGIC_262144: i64 = 262144
9const K_MAGIC_4852: i64 = 4852
10func ow(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func on(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var q: i64=k-1; var x: i64=0; while q>=0 { o[x]=t[q]; x=x+1; q=q-1 } sys_write(1,o,x); return 0 }
12func main(argc: i64, argv: *i64) -> i64 {
13 ow("=== nx_js_octane_deltablue: real Octane DeltaBlue (constraint solver) on our sovereign VM/JIT ===\n" as *u8)
14 let fd: i64 = sys_openat_rd("knowledge/octane/deltablue_eng.js\x00" as *u8)
15 if fd < 0 { ow(" RED: cannot open knowledge/octane/deltablue_eng.js\n" as *u8); return 1 }
16 let cap: i64 = K_MAGIC_262144
17 let buf: *u8 = sys_mmap(cap + 8)
18 var total: i64 = 0
19 var done: i64 = 0
20 while done == 0 { let n: i64 = sys_read(fd, ((buf as i64) + total) as *u8, cap - total); if n <= 0 { done = 1 } else { total = total + n } }
21 sys_close(fd)
22 buf[total] = 0 as u8
23 ow(" loaded deltablue_eng.js: " as *u8); on(total); ow(" bytes\n" as *u8)
24 let out: *i64 = sys_mmap(16) as *i64
25 let t0: i64 = sys_now_us()
26 let rc: i64 = compile_run(buf, out)
27 let t1: i64 = sys_now_us()
28 ow(" compile_run rc=" as *u8); on(rc); ow(" result tag=" as *u8); on(out[0])
29 if out[0] == VAL_STR { ow(" '" as *u8); sys_write(1, ev_str_bytes((out[1]) as *i64), ev_str_len((out[1]) as *i64)); ow("'" as *u8) }
30 ow("\n" as *u8)
31 var okr: i64 = 0
32 if rc == 0 { if out[0] == VAL_STR {
33 let rb: *u8 = ev_str_bytes((out[1]) as *i64)
34 let rl: i64 = ev_str_len((out[1]) as *i64)
35 if rl == 12 { okr = 1; var i: i64 = 0; let exp: *u8 = "DELTABLUE_OK" as *u8; while i < 12 { if (rb[i] & 0xff) != (exp[i] & 0xff) { okr = 0; i = 12 } else { i = i + 1 } } }
36 } }
37 if okr == 0 { ow("=== RED: DeltaBlue did not complete (feature gap or solver error) ===\n" as *u8); return 1 }
38 var us: i64 = t1 - t0
39 if us < 1 { us = 1 }
40 let v8: i64 = K_MAGIC_4852
41 ow(" ours(parse+chainTest(100)+projectionTest(100))=" as *u8); on(us); ow("us V8(warm)=" as *u8); on(v8); ow("us\n" as *u8)
42 ow("=== GREEN: real Octane DeltaBlue RAN -- constraint solver self-validated (chain + projection) ===\n" as *u8)
43 return 0
44}