Skip to content

Commit 2604b22

Browse files
committed
Store aarch64 link register; and fix stack align on x86_64
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent 60c7da9 commit 2604b22

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

profiling/src/wall_time.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ pub extern "C" fn ddog_php_prof_interrupt_function(execute_data: *mut zend_execu
139139

140140
#[cfg(php_frameless)]
141141
mod frameless {
142-
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
143-
144142
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
145143
mod trampoline {
146144
#[cfg(target_arch = "aarch64")]
@@ -175,15 +173,20 @@ mod frameless {
175173
// Calls original function, then calls interrupt function.
176174
#[cfg(target_arch = "aarch64")]
177175
dynasm!(assembler
176+
; stp x29, x30, [sp, -16]! // save link register and allow clobber of x29
177+
; mov x29, sp // store stack pointer
178178
; mov x16, *orig as u64
179179
; blr x16
180+
; ldp x29, x30, [sp], 16 // restore link register
180181
; mov x16, interrupt_addr as u64
181182
; br x16 // tail call
182183
);
183184
#[cfg(target_arch = "x86_64")]
184185
dynasm!(assembler
186+
; push rbp // align stack
185187
; mov rax, QWORD *orig as i64
186188
; call rax
189+
; pop rbp // restore stack
187190
; mov rax, QWORD interrupt_addr as i64
188191
; jmp rax // tail call
189192
);

0 commit comments

Comments
 (0)