Open
Description
background
as described in #126, svm runtime gives the user heap to use anyways with or without defining a heap allocator.
default BumpAllocator
will store two usize
on bss section, one indicating the free pointer and the other max len.
NoAllocator
now does not allow alloc
generated heap allocation, and #126 adds a manual allocation for NoAllocator
.
a few thoughts
NoAllocator
's name is confusing. it is able to let user to claim heap memory, but it cannot letalloc
crate to get memory.NoAllocator
is very dev-unfriendly (maybe we can introduce some static check to avoid overlap?)- using allocating functions in crate
alloc
likeBox::new
will introduces some rust runtime check, like null ptr check. subsequently it emits panic stuff like in useget_unchecked
over [] to preventfmt
code emission #85 . allocate_unchecked
needs the annoying#![cfg_attr(target_os = "solana", feature(const_mut_refs))]
some easy todo improvements:
- remove
len
field ofBumpAllocator
- remove
const
forallocate_unchecked
(or we wait for toolchain updating to 1.83.0) - add same interface (
allocate_unchecked
) forBumpAllocator
-
allocate_unchecked
should return&'static mut MaybeUninit<T>
- introduce static_assertions for
allocate_unchecked
to through compile-time error for assertion (e.g. heap oob)
some challenging ones:
- compile time overlap check (not sure if it's possible without touching the compiler)
- bypass
alloc
runtime check (i.e. lightweight panic if allocation fails). i tried but failed. compiler change needed for this one
Metadata
Metadata
Assignees
Labels
No labels