From 4b4113a0217ee27c78e7efddb66ff5a455d49083 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 12 Nov 2026 13:19:32 -0300 Subject: debugger: add a native GUI with live V8 JIT debugging --- gui/targets/jit.js | 14 ++++++++++++++ gui/targets/loop.c | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gui/targets/jit.js create mode 100644 gui/targets/loop.c (limited to 'gui/targets') diff --git a/gui/targets/jit.js b/gui/targets/jit.js new file mode 100644 index 0000000..254050a --- /dev/null +++ b/gui/targets/jit.js @@ -0,0 +1,14 @@ +// Print the optimized function's machine code, then let the native debugger +// install a breakpoint before the next invocation. No V8 inspector required. +function jitWork(n) { + let sum = 0; + for (let i = 0; i < n; i++) sum = (sum + (i ^ n)) | 0; + return sum; +} +%PrepareFunctionForOptimization(jitWork); +jitWork(10); +jitWork(20); +%OptimizeFunctionOnNextCall(jitWork); +jitWork(30); +%SystemBreak(); +print(jitWork(10000)); diff --git a/gui/targets/loop.c b/gui/targets/loop.c new file mode 100644 index 0000000..d95a852 --- /dev/null +++ b/gui/targets/loop.c @@ -0,0 +1,13 @@ +#include + +__attribute__((noinline)) uint32_t work(uint32_t n) { + uint32_t sum = 0; + for (uint32_t i = 0; i < n; ++i) { + sum += i ^ n; + } + return sum; +} + +int main(void) { + return (int)(work(1000000000) & 0x7f); +} -- cgit v1.3