summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShravan Narayan <shravanrn@gmail.com>2024-10-15 21:19:30 -0500
committerShravan Narayan <shravanrn@gmail.com>2024-10-18 14:10:21 -0500
commitd6e97afe0eb1977a6fd198f5a221314a82c26c84 (patch)
tree9ff174a9ce1f05657abfca067902841ab28f5de7
parent3bcb05b9b7100688ab166591b02bad1415ba7baf (diff)
downloadwabt-d6e97afe0eb1977a6fd198f5a221314a82c26c84.tar.gz
wabt-d6e97afe0eb1977a6fd198f5a221314a82c26c84.tar.bz2
wabt-d6e97afe0eb1977a6fd198f5a221314a82c26c84.zip
wasm2c: Reset the segment register after call_indirect as the register may have changed
-rw-r--r--src/c-writer.cc3
-rw-r--r--test/wasm2c/check-imports.txt3
-rw-r--r--test/wasm2c/hello.txt3
3 files changed, 9 insertions, 0 deletions
diff --git a/src/c-writer.cc b/src/c-writer.cc
index a698cd59..76ff52f9 100644
--- a/src/c-writer.cc
+++ b/src/c-writer.cc
@@ -3558,6 +3558,9 @@ void CWriter::Write(const ExprList& exprs) {
Write(", ", StackVar(num_params - i));
}
Write(");", Newline());
+ if (IsSingleUnsharedMemory()) {
+ InstallSegueBase(module_->memories[0], false /* save_old_value */);
+ }
DropTypes(num_params + 1);
PushTypes(decl.sig.result_types);
if (num_results > 1) {
diff --git a/test/wasm2c/check-imports.txt b/test/wasm2c/check-imports.txt
index 7870c885..f162e066 100644
--- a/test/wasm2c/check-imports.txt
+++ b/test/wasm2c/check-imports.txt
@@ -869,6 +869,9 @@ u32 w2c_test_f0(w2c_test* instance, u32 var_p0) {
u32 var_i0;
var_i0 = var_p0;
var_i0 = CALL_INDIRECT((*instance->w2c_env_0x5F_indirect_function_table), u32 (*)(void*), w2c_test_t1, var_i0, (*instance->w2c_env_0x5F_indirect_function_table).data[var_i0].module_instance);
+#if WASM_RT_USE_SEGUE_FOR_THIS_MODULE
+ wasm_rt_segue_write_base((*instance->w2c_env_0x5F_linear_memory).data);
+#endif
FUNC_EPILOGUE;
return var_i0;
}
diff --git a/test/wasm2c/hello.txt b/test/wasm2c/hello.txt
index 2e72bf0e..60d18099 100644
--- a/test/wasm2c/hello.txt
+++ b/test/wasm2c/hello.txt
@@ -911,6 +911,9 @@ void w2c_test_0x5Fstart_0(w2c_test* instance) {
var_i3 = 0u;
var_i4 = 0u;
var_i0 = CALL_INDIRECT(instance->w2c_T0, u32 (*)(void*, u32, u32, u32, u32), w2c_test_t0, var_i4, instance->w2c_T0.data[var_i4].module_instance, var_i0, var_i1, var_i2, var_i3);
+#if WASM_RT_USE_SEGUE_FOR_THIS_MODULE
+ wasm_rt_segue_write_base(instance->w2c_memory.data);
+#endif
w2c_wasi__snapshot__preview1_proc_exit(instance->w2c_wasi__snapshot__preview1_instance, var_i0);
FUNC_EPILOGUE;
}