From 7a16cf7cf9086454ab9558940cf58bb7660e9d65 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)
---
 rts/Schedule.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rts/Schedule.c b/rts/Schedule.c
index 4f0dcf3e81c..9a209be8e28 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -485,9 +485,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