From 02ebf2a8db877b8ea9b0b8010e70825a76957a55 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Thu, 19 Sep 2024 18:24:19 +0000
Subject: [PATCH] rts: drop interpretBCO support from non-dyn ways on wasm

This commit drops interpretBCO support from non dynamic rts ways on
wasm. The bytecode interpreter is only useful when the RTS linker also
works, and on wasm it only works for dynamic ways anyway. An
additional benefit of dropping interpretBCO is reduction in code size
of linked wasm modules, especially since interpretBCO references
ffi_call which is an auto-generated large function in libffi-wasm and
unused by most user applications.

(cherry picked from commit 90a35c41bb676b5e68212f63b187d2c50439714c)
(cherry picked from commit 7a16cf7cf9086454ab9558940cf58bb7660e9d65)
(cherry picked from commit 5fcee705555b251f91d0e28d73c0c5bc64161c13)
---
 rts/Schedule.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rts/Schedule.c b/rts/Schedule.c
index 946d79aace7..4a0a6284bad 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -484,9 +484,14 @@ run_thread:
     }
 
     case ThreadInterpret:
+
+#if defined(wasm32_HOST_ARCH) && !defined(DYNAMIC)
+        barf("bytecode interpreter is unsupported in static RTS on wasm");
+#else
         cap = interpretBCO(cap);
         ret = cap->r.rRet;
         break;
+#endif
 
     default:
         barf("schedule: invalid prev_what_next=%u field", prev_what_next);
-- 
GitLab