From 4bad8300e5f7532983b4f1a4ac300fde05fb12bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Wed, 7 Feb 2024 14:19:25 +0100 Subject: [PATCH] jit: Add debug code in emit_enter_runtime to catch missing updates --- erts/emulator/beam/jit/arm/beam_asm.hpp | 22 ++++++++++++++++++---- erts/emulator/beam/jit/x86/beam_asm.hpp | 24 ++++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/erts/emulator/beam/jit/arm/beam_asm.hpp b/erts/emulator/beam/jit/arm/beam_asm.hpp index a2d28c27b5e2..346b0b27a987 100644 --- a/erts/emulator/beam/jit/arm/beam_asm.hpp +++ b/erts/emulator/beam/jit/arm/beam_asm.hpp @@ -463,10 +463,24 @@ class BeamAssembler : public ErrorHandler { /* Store HTOP and E in one go. */ ERTS_CT_ASSERT_FIELD_PAIR(Process, htop, stop); a.stp(HTOP, E, arm::Mem(c_p, offsetof(Process, htop))); - } else if (Spec & Update::eStack) { - a.str(E, arm::Mem(c_p, offsetof(Process, stop))); - } else if (Spec & Update::eHeap) { - a.str(HTOP, arm::Mem(c_p, offsetof(Process, htop))); + } else { + if (Spec & Update::eStack) { + a.str(E, arm::Mem(c_p, offsetof(Process, stop))); + } else { +#ifdef DEBUG + /* Store some garbage in the process structure to catch missing + * updates. */ + a.str(active_code_ix, arm::Mem(c_p, offsetof(Process, stop))); +#endif + } + + if (Spec & Update::eHeap) { + a.str(HTOP, arm::Mem(c_p, offsetof(Process, htop))); + } else { +#ifdef DEBUG + a.str(active_code_ix, arm::Mem(c_p, offsetof(Process, htop))); +#endif + } } if (Spec & Update::eReductions) { diff --git a/erts/emulator/beam/jit/x86/beam_asm.hpp b/erts/emulator/beam/jit/x86/beam_asm.hpp index 66891730efc9..1e756bd008d5 100644 --- a/erts/emulator/beam/jit/x86/beam_asm.hpp +++ b/erts/emulator/beam/jit/x86/beam_asm.hpp @@ -641,10 +641,26 @@ class BeamAssembler : public ErrorHandler { a.punpcklqdq(x86::xmm0, x86::xmm1); a.movups(x86::xmmword_ptr(c_p, offsetof(Process, htop)), x86::xmm0); - } else if (Spec & Update::eHeap) { - a.mov(x86::qword_ptr(c_p, offsetof(Process, htop)), HTOP); - } else if (Spec & Update::eStack) { - a.mov(x86::qword_ptr(c_p, offsetof(Process, stop)), E); + } else { + if (Spec & Update::eHeap) { + a.mov(x86::qword_ptr(c_p, offsetof(Process, htop)), HTOP); + } else { +#ifdef DEBUG + /* Store some garbage in the process structure to catch + * missing updates. */ + a.mov(x86::qword_ptr(c_p, offsetof(Process, htop)), + active_code_ix); +#endif + } + + if (Spec & Update::eStack) { + a.mov(x86::qword_ptr(c_p, offsetof(Process, stop)), E); + } else { +#ifdef DEBUG + a.mov(x86::qword_ptr(c_p, offsetof(Process, stop)), + active_code_ix); +#endif + } } #ifdef NATIVE_ERLANG_STACK