aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 14e23db225103e5ba657d631b0998c1466b9d520
parent a53309dc0d32d09c2590d68f17026aedde5c6670
Author: anon <anon@example.com>
Date:   Sat, 17 Oct 2026 14:47:32 +0000

Skip unused indirect-call history in portable release builds

Diffstat:
Msrc/runtime/recomp_types.h | 19+++++++++++++------
Msrc/tests/shadow_contact.c | 2+-
2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/runtime/recomp_types.h b/src/runtime/recomp_types.h @@ -1099,6 +1099,17 @@ extern RECOMP_THREAD_LOCAL uint32_t g_icall_from[ICALL_TRACE_SIZE]; extern RECOMP_THREAD_LOCAL uint32_t g_icall_trace_idx; extern RECOMP_THREAD_LOCAL uint32_t g_icall_count; +/* Keep recent-call history for Windows diagnostics and trace builds. */ +#if !defined(RECOMP_PORTABLE) || defined(RECOMP_TRACE) +#define RECOMP_RECORD_ICALL(va) do { \ + g_icall_trace[g_icall_trace_idx & (ICALL_TRACE_SIZE-1)] = (va); \ + g_icall_from[g_icall_trace_idx & (ICALL_TRACE_SIZE-1)] = g_cur_func; \ + g_icall_trace_idx++; \ +} while (0) +#else +#define RECOMP_RECORD_ICALL(va) ((void)0) +#endif + /* Lookup functions */ recomp_func_t recomp_lookup(uint32_t va); /* binary search in dispatch table */ recomp_func_t recomp_lookup_manual(uint32_t va); /* manual overrides */ @@ -1136,9 +1147,7 @@ recomp_func_t recomp_lookup_import(uint32_t va); /* import bridges */ /* Indirect call through dispatch */ #define RECOMP_ICALL(target_va) do { \ uint32_t _va = (uint32_t)(target_va); \ - g_icall_trace[g_icall_trace_idx & (ICALL_TRACE_SIZE-1)] = _va; \ - g_icall_from[g_icall_trace_idx & (ICALL_TRACE_SIZE-1)] = g_cur_func; \ - g_icall_trace_idx++; \ + RECOMP_RECORD_ICALL(_va); \ g_icall_count++; \ recomp_func_t _fn = recomp_lookup_manual(_va); \ if (!_fn) _fn = recomp_lookup(_va); \ @@ -1164,9 +1173,7 @@ recomp_func_t recomp_lookup_import(uint32_t va); /* import bridges */ /* Indirect tail call (jmp through dispatch) */ #define RECOMP_ITAIL(target_va) do { \ uint32_t _va = (uint32_t)(target_va); \ - g_icall_trace[g_icall_trace_idx & (ICALL_TRACE_SIZE-1)] = _va; \ - g_icall_from[g_icall_trace_idx & (ICALL_TRACE_SIZE-1)] = g_cur_func; \ - g_icall_trace_idx++; \ + RECOMP_RECORD_ICALL(_va); \ g_icall_count++; \ recomp_func_t _fn = recomp_lookup_manual(_va); \ if (!_fn) _fn = recomp_lookup(_va); \ diff --git a/src/tests/shadow_contact.c b/src/tests/shadow_contact.c @@ -115,7 +115,7 @@ recomp_func_t recomp_lookup(uint32_t address) case 0x70000010: return geometry; case 0x70000014: return update; case 0x7000001c: return zero_segments; - default: fprintf(stderr, "Unexpected shadow dependency: %08x from %08x\n", address, g_icall_from[(g_icall_trace_idx - 1) & (ICALL_TRACE_SIZE - 1)]); abort(); + default: fprintf(stderr, "Unexpected shadow dependency: %08x from %08x\n", address, g_cur_func); abort(); } }