From 57b1b88153c8fc255068119333dabc15919c49a6 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Thu, 9 Nov 2023 02:53:06 +0800
Subject: [PATCH 11/12] libsampler: support powerpc and aarch64

---
 src/libsampler/sampler.cc | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/libsampler/sampler.cc b/src/libsampler/sampler.cc
index e2091ceb32a..963483f726d 100644
--- a/v8/src/libsampler/sampler.cc
+++ b/v8/src/libsampler/sampler.cc
@@ -468,7 +468,16 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) {
   state->pc = reinterpret_cast<void*>(mcontext->__ss.__eip);
   state->sp = reinterpret_cast<void*>(mcontext->__ss.__esp);
   state->fp = reinterpret_cast<void*>(mcontext->__ss.__ebp);
-#endif  // V8_HOST_ARCH_IA32
+#elif V8_HOST_ARCH_ARM64
+  state->pc = reinterpret_cast<void*>(arm_thread_state64_get_pc(mcontext->__ss));
+  state->sp = reinterpret_cast<void*>(arm_thread_state64_get_sp(mcontext->__ss));
+  state->fp = reinterpret_cast<void*>(arm_thread_state64_get_fp(mcontext->__ss));
+#elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64
+  state->pc = reinterpret_cast<void*>(mcontext->__ss.__srr0);
+  state->sp = reinterpret_cast<void*>(mcontext->__ss.__r1);
+  state->fp = reinterpret_cast<void*>(mcontext->__ss.__r30);
+  state->lr = reinterpret_cast<void*>(mcontext->__ss.__lr);
+#endif  // V8_HOST_ARCH_*
 #elif V8_OS_FREEBSD
 #if V8_HOST_ARCH_IA32
   state->pc = reinterpret_cast<void*>(mcontext.mc_eip);
