pub const OFF_REGISTER_COUNT: i32 = 8;
pub const OFF_PC: i32 = 12;
pub const OFF_BUDGET: i32 = 16;
pub const OFF_FUNCTION: i32 = 20;
pub const OFF_EXIT_KIND: i32 = 24;
pub const OFF_RETURN_REG: i32 = 28;
pub const OFF_CALL_DEPTH: i32 = 32;
pub const OFF_CALL_STACK: i32 = 40;
pub const OFF_WRITTEN: i32 = 48;
pub const OFF_AS_BOOL: i32 = 80;
pub const OFF_AS_UNIT: i32 = 112;
pub const OFF_ENTRY_BOOL: i32 = 144;
pub const OFF_ENTRY_UNIT: i32 = 176;
pub const MAX_JIT_CALL_DEPTH: usize = 32;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct JitCallRecord {
pub return_pc: u32,
pub return_function: u32,
pub dest_reg: u32,
pub caller_register_count: u32,
}
#[repr(C)]
pub struct JitFrame {
pub slots: *mut i64,
pub register_count: u32,
pub pc: u32,
pub budget: u32,
pub function: u32,
pub exit_kind: u32,
pub return_reg: u32,
pub call_depth: u32,
pub call_stack: *mut JitCallRecord,
pub written: [u64; 4],
pub as_bool: [u64; 4],
pub as_unit: [u64; 4],
pub entry_as_bool: [u64; 4],
pub entry_as_unit: [u64; 4],
}
pub type JitEntry = unsafe extern "C" fn(*mut JitFrame);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tag_words_sit_where_the_compiler_stores_them() {
assert_eq!(
std::mem::offset_of!(JitFrame, written),
OFF_WRITTEN as usize
);
assert_eq!(
std::mem::offset_of!(JitFrame, as_bool),
OFF_AS_BOOL as usize
);
assert_eq!(
std::mem::offset_of!(JitFrame, as_unit),
OFF_AS_UNIT as usize
);
assert_eq!(
std::mem::offset_of!(JitFrame, entry_as_bool),
OFF_ENTRY_BOOL as usize
);
assert_eq!(
std::mem::offset_of!(JitFrame, entry_as_unit),
OFF_ENTRY_UNIT as usize
);
}
}