commit e83d3aaf8db9b8860a06463f1d4fe9bd9b91c754
parent c3e11dc69bd66905417760d1579ddad1c392052b
Author: Rong "Mantle" Bao <webmaster@csmantle.top>
Date: Wed, 15 Oct 2025 14:13:00 +0000
Bug 1993666 - Part 3: (Drive-by) Make different simulator stack switching gates mutually exclusive. r=yury
Differential Revision: https://phabricator.services.mozilla.com/D268249
Diffstat:
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/js/src/wasm/WasmPI.cpp b/js/src/wasm/WasmPI.cpp
@@ -41,19 +41,13 @@
#include "wasm/WasmGcObject-inl.h"
#include "wasm/WasmInstance-inl.h"
-#ifdef JS_CODEGEN_ARM
+#if defined(JS_CODEGEN_ARM)
# include "jit/arm/Simulator-arm.h"
-#endif
-
-#ifdef JS_CODEGEN_ARM64
+#elif defined(JS_CODEGEN_ARM64)
# include "jit/arm64/vixl/Simulator-vixl.h"
-#endif
-
-#ifdef JS_CODEGEN_RISCV64
+#elif defined(JS_CODEGEN_RISCV64)
# include "jit/riscv64/Simulator-riscv64.h"
-#endif
-
-#ifdef JS_CODEGEN_LOONG64
+#elif defined(JS_CODEGEN_LOONG64)
# include "jit/loong64/Simulator-loong64.h"
#endif
@@ -100,7 +94,7 @@ void SuspenderObjectData::restoreTIBStackFields() {
}
# endif
-# ifdef JS_SIMULATOR_ARM64
+# if defined(JS_SIMULATOR_ARM64)
void SuspenderObjectData::switchSimulatorToMain() {
auto* sim = Simulator::Current();
suspendableSP_ = (void*)sim->xreg(Registers::sp, vixl::Reg31IsStackPointer);
@@ -118,9 +112,8 @@ void SuspenderObjectData::switchSimulatorToSuspendable() {
vixl::Debugger::LogRegWrites, vixl::Reg31IsStackPointer);
sim->set_xreg(Registers::fp, (int64_t)suspendableFP_);
}
-# endif
-# ifdef JS_SIMULATOR_ARM
+# elif defined(JS_SIMULATOR_ARM)
void SuspenderObjectData::switchSimulatorToMain() {
suspendableSP_ = (void*)Simulator::Current()->get_register(Simulator::sp);
suspendableFP_ = (void*)Simulator::Current()->get_register(Simulator::fp);
@@ -134,9 +127,8 @@ void SuspenderObjectData::switchSimulatorToSuspendable() {
Simulator::Current()->set_register(Simulator::sp, (int)suspendableSP_);
Simulator::Current()->set_register(Simulator::fp, (int)suspendableFP_);
}
-# endif
-# if defined(JS_SIMULATOR_RISCV64) || defined(JS_SIMULATOR_LOONG64)
+# elif defined(JS_SIMULATOR_RISCV64) || defined(JS_SIMULATOR_LOONG64)
void SuspenderObjectData::switchSimulatorToMain() {
suspendableSP_ = (void*)Simulator::Current()->getRegister(Simulator::sp);
suspendableFP_ = (void*)Simulator::Current()->getRegister(Simulator::fp);