Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi version IR - CP transition baed on JIT state #16

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

Pavel-Durov
Copy link
Owner

No description provided.

@Pavel-Durov Pavel-Durov changed the title Dynamically calculate the offset of the return address. Multi version IR - CP transition baed on JIT state Nov 23, 2024
@Pavel-Durov
Copy link
Owner Author

// ; int3 // Insert a breakpoint for GDB
; mov rax, QWORD target_addr
; mov [rsp], rax
; ret
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we do the jump we need to adjust rsp:

  1. check stack size of unopt
  2. calculate the difference
  3. sub the diff from rsp

// );

// asm.finalize().unwrap()
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjust rsp here.


#[cfg(tracer_swt)]
fn build_livevars_cp_asm(src_smid: usize, dst_smid: usize, asm: &mut Assembler) {
let (src_rec, _) = AOT_STACKMAPS.as_ref().unwrap().get(src_smid);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

records size is the size of the stack.

1 => dynasm!(asm
// ; mov al, BYTE [Rq(src_reg)]
// ; mov BYTE [Rq(dst_reg) + *dst_off], al#
; mov al, BYTE [rsp + src_offset]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
; mov al, BYTE [rsp + src_offset]
; mov al, BYTE [rbp + src_offset]

Direct(src_reg_num, src_off, src_val_size),
Direct(dst_reg_num, dst_off, dst_val_size),
) => {
assert_eq!(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it probably.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be ignored.

Direct(src_reg_num, src_off, src_val_size),
Direct(dst_reg_num, dst_off, dst_val_size),
) => {
assert_eq!(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be ignored.

// ; pop r14 // Corresponds to push r14
// ; pop r15 // Corresponds to push r15
// ; ret
// );
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverse the change of rsp.

ykrt/src/mt.rs Outdated
// let func: unsafe fn() = std::mem::transmute(debug_return_into_unopt_cp().as_ptr());
let func: unsafe fn() = std::mem::transmute(RETURN_INTO_UNOPT_CP.as_ptr());
// self.log.log(Verbosity::JITEvent, "returning into unopt cp");
func();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I call my control point transition asm code the $rsp is affected (I guess by this function execution).
Expected return address at main+330: 0x7fffffffdcd0
But $rsp value when RETURN_INTO_UNOPT_CP asm is executed is 0x7fffffffd360 which is off by:
0x7fffffffdcd0 - 0x7fffffffd360 = 2416
Therefore I get segfaults downstream...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant