summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Högberg <john@erlang.org>2023-05-11 16:46:24 +0200
committerJohn Högberg <john@erlang.org>2023-05-11 16:46:24 +0200
commit48f26e305be6f321afc8343d36e78830824839c1 (patch)
tree638d4ec8b69a7ea1f5b1bef86fd49401d8a88554
parent5c1282324d2ea5bdc09ca678767357e76fadba7c (diff)
parent4a6fcd75289130da6752195a013d0699ce154ce3 (diff)
downloaderlang-48f26e305be6f321afc8343d36e78830824839c1.tar.gz
Merge branch 'john/jit/fix-tracing-non-native-stack/OTP-18561' into maint
* john/jit/fix-tracing-non-native-stack/OTP-18561: jit: Fix tracing for non-native stack
-rw-r--r--erts/emulator/beam/jit/x86/instr_trace.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/erts/emulator/beam/jit/x86/instr_trace.cpp b/erts/emulator/beam/jit/x86/instr_trace.cpp
index f3a825775d..3e7720c0fc 100644
--- a/erts/emulator/beam/jit/x86/instr_trace.cpp
+++ b/erts/emulator/beam/jit/x86/instr_trace.cpp
@@ -109,10 +109,10 @@ void BeamGlobalAssembler::emit_generic_bp_local() {
a.cmp(RET, imm(BeamOpCodeAddr(op_i_debug_breakpoint)));
a.je(labels[debug_bp]);
+#ifdef NATIVE_ERLANG_STACK
/* Note that we don't restore our return addresses in the `debug_bp` case
* above, since it tail calls the error handler and thus never returns to
* module code or `call_nif_early`. */
-#ifdef NATIVE_ERLANG_STACK
a.push(TMP_MEM1q);
a.push(TMP_MEM2q);
#endif
@@ -127,6 +127,12 @@ void BeamGlobalAssembler::emit_generic_bp_local() {
void BeamGlobalAssembler::emit_debug_bp() {
Label error = a.newLabel();
+#ifndef NATIVE_ERLANG_STACK
+ /* We're never going to return to module code, so we have to discard the
+ * return addresses added by the breakpoint trampoline. */
+ a.add(x86::rsp, imm(sizeof(ErtsCodePtr[2])));
+#endif
+
emit_assert_erlang_stack();
emit_enter_frame();
@@ -203,16 +209,19 @@ void BeamModuleAssembler::emit_i_return_time_trace() {
}
void BeamModuleAssembler::emit_i_return_to_trace() {
- emit_enter_runtime<Update::eStack | Update::eHeap>();
+ /* Remove our stack frame so that `beam_jit_return_to_trace` can inspect
+ * the next one.
+ *
+ * (This doesn't do anything if the native stack is used.) */
+ emit_deallocate(ArgWord(0));
+
+ emit_enter_runtime<Update::eReductions | Update::eStack | Update::eHeap>();
a.mov(ARG1, c_p);
runtime_call<1>(beam_jit_return_to_trace);
- emit_leave_runtime<Update::eStack | Update::eHeap>();
+ emit_leave_runtime<Update::eReductions | Update::eStack | Update::eHeap>();
- /* Remove the zero-sized stack frame. (Will actually do nothing if
- * the native stack is used.) */
- emit_deallocate(ArgWord(0));
emit_return();
}