summaryrefslogtreecommitdiff
path: root/gui/targets
diff options
context:
space:
mode:
Diffstat (limited to 'gui/targets')
-rw-r--r--gui/targets/jit.js14
-rw-r--r--gui/targets/loop.c13
2 files changed, 27 insertions, 0 deletions
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 <stdint.h>
+
+__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);
+}