code wiki / _hdl_build / nx_js_probes_nojit.nx
nx_js_probes_nojit.nx source
↩ module page · 23 lines · 1234 B
1// run jsprobes.js on the VM with the JIT DISABLED (interpreter only) -- to isolate JIT bugs from VM-core
2// bugs. expect_exit: 0 license_tier: ORIGINAL
3import "nx_js_vm.nx"
4const K_MAGIC_262144: i64 = 262144
5func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
6func main(argc: i64, argv: *i64) -> i64 {
7 js_jit_disable(1)
8 let fd: i64 = sys_openat_rd("knowledge/octane/jsprobes.js\x00" as *u8)
9 if fd < 0 { w("RED: no jsprobes.js\n" as *u8); return 1 }
10 let buf: *u8 = sys_mmap(K_MAGIC_262144)
11 var total: i64 = 0
12 var done: i64 = 0
13 while done == 0 { let n: i64 = sys_read(fd, ((buf as i64) + total) as *u8, K_MAGIC_262144 - total); if n <= 0 { done = 1 } else { total = total + n } }
14 sys_close(fd)
15 buf[total] = 0 as u8
16 let out: *i64 = sys_mmap(16) as *i64
17 let rc: i64 = compile_run(buf, out)
18 w("NOJIT rc=" as *u8)
19 if rc == 0 { w("0 " as *u8) } else { w("1 " as *u8) }
20 if out[0] == VAL_STR { w("'" as *u8); sys_write(1, ev_str_bytes((out[1]) as *i64), ev_str_len((out[1]) as *i64)); w("'" as *u8) } else { w("tag=" as *u8); if out[0]==VAL_NUM { w("num" as *u8) } else { w("other" as *u8) } }
21 w("\n" as *u8)
22 return 0
23}