Skip to content

Commit

Permalink
jit: Add debug code in emit_enter_runtime to catch missing updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jhogberg authored and sverker committed Feb 8, 2024
1 parent b8989bf commit 4bad830
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
22 changes: 18 additions & 4 deletions erts/emulator/beam/jit/arm/beam_asm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 20 additions & 4 deletions erts/emulator/beam/jit/x86/beam_asm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4bad830

Please sign in to comment.