#![allow(missing_docs)]
pub(super) const OFF_REGISTER_COUNT: i32 = 8;
pub(super) const OFF_PC: i32 = 12;
pub(super) const OFF_BUDGET: i32 = 16;
pub(super) const OFF_FUNCTION: i32 = 20;
pub(super) const OFF_EXIT_KIND: i32 = 24;
pub(super) const OFF_RETURN_REG: i32 = 28;
pub(super) const OFF_CALL_DEPTH: i32 = 32;
pub(super) const OFF_CALL_STACK: i32 = 40;
pub(super) const OFF_WRITTEN: i32 = 48;
pub(super) const OFF_AS_BOOL: i32 = 80;
pub(super) const OFF_AS_UNIT: i32 = 112;
pub(super) const OFF_ENTRY_BOOL: i32 = 144;
pub(super) const OFF_ENTRY_UNIT: i32 = 176;
pub(super) const OFF_SPILL: i32 = 208;
pub(super) const OFF_SPILL_STRIDE: i32 = 216;
pub(super) const OFF_AS_FLOAT: i32 = 224;
pub(super) const OFF_ENTRY_FLOAT: i32 = 256;
pub(super) const REC_RETURN_PC: i32 = 0;
pub(super) const REC_RETURN_FN: i32 = 4;
pub(super) const REC_DEST: i32 = 8;
pub(super) const REC_CALLER_REGS: i32 = 12;
pub(super) const REC_WRITTEN: i32 = 16;
pub(super) const REC_AS_BOOL: i32 = 48;
pub(super) const REC_AS_UNIT: i32 = 80;
pub(super) const REC_AS_FLOAT: i32 = 112;
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,
pub written: [u64; 4],
pub as_bool: [u64; 4],
pub as_unit: [u64; 4],
pub as_float: [u64; 4],
}
#[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 spill: *mut i64,
pub spill_stride: u32,
pub as_float: [u64; 4],
pub entry_as_float: [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
);
assert_eq!(std::mem::offset_of!(JitFrame, spill), OFF_SPILL as usize);
assert_eq!(
std::mem::offset_of!(JitFrame, spill_stride),
OFF_SPILL_STRIDE as usize
);
assert_eq!(
std::mem::offset_of!(JitFrame, as_float),
OFF_AS_FLOAT as usize
);
assert_eq!(
std::mem::offset_of!(JitFrame, entry_as_float),
OFF_ENTRY_FLOAT as usize
);
assert_eq!(
std::mem::offset_of!(JitCallRecord, written),
REC_WRITTEN as usize
);
assert_eq!(
std::mem::offset_of!(JitCallRecord, as_bool),
REC_AS_BOOL as usize
);
assert_eq!(
std::mem::offset_of!(JitCallRecord, as_unit),
REC_AS_UNIT as usize
);
assert_eq!(
std::mem::offset_of!(JitCallRecord, as_float),
REC_AS_FLOAT as usize
);
}
}