From ba8c99a123daf3691914ad379c614889056e8b43 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Thu, 19 Mar 2026 22:01:51 +0000 Subject: [PATCH] Mirror IP and RSP regs in memory This will allow the profiler to sample the current return stack and instruction pointer. It can't just use the ip and rsp globals directly, as I had initially planned, since these cannot be sent in between threads. --- wipforth.ws | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wipforth.ws b/wipforth.ws index 2e84e8b..aedca4b 100644 --- a/wipforth.ws +++ b/wipforth.ws @@ -9,6 +9,9 @@ .def RXHEAD 48h .def RXTAIL 4Ch +;; Mirror of registers for profiler to sample +.def PROF_DATA 58h + .def DICT_START 0200h .def RSP_INIT 10000h @@ -2073,6 +2076,13 @@ KERNEL_DEFS_END: .func trampoline loop iter global.get fn call_indirect codeword codewords + + i32.const PROF_DATA + global.get ip i64.extend_i32_u + global.get rsp i64.extend_i32_u + i64.const 32 i64.shl i64.or + i64.atomic.store 3 0 + global.get run br_if iter end