luaur-code-gen 0.1.3

Native (A64/X64) code generation for Luau (Rust).
Documentation
use crate::functions::allocate_pages_impl_code_allocator::allocate_pages_impl;
use crate::records::code_allocator::CodeAllocator;

impl CodeAllocator {
    pub fn allocate_pages(&self, size: usize) -> *mut u8 {
        unsafe {
            let page_aligned_size = CodeAllocator::align_to_page_size(size);

            let mem = allocate_pages_impl(page_aligned_size);
            if mem.is_null() {
                return core::ptr::null_mut();
            }

            if let Some(callback) = self.allocation_callback {
                callback(
                    self.allocation_callback_context,
                    core::ptr::null_mut(),
                    0,
                    mem.cast(),
                    page_aligned_size,
                );
            }

            mem
        }
    }
}