Skip to content

When v is compiled as. wasm, does it use GC or autofree memory management by default? #19212

Closed Answered by l1mey112
Avey777 asked this question in Questions and Answers
Discussion options

You must be logged in to vote

Currently it uses neither. Just a simple bump allocator able to allocate at possibly at most 64KiBs without crashing. This was a basic allocator created for running the tests and all programs the wasm backend is capable of compiling.

Full code behind vlib/builtin/wasm/alloc.v:

@[has_globals]
module builtin

// Shitty `sbrk` basic `malloc` and `free` impl
// TODO: implement pure V `walloc` later

__global g_heap_base = usize(vwasm_heap_base())

// malloc dynamically allocates a `n` bytes block of memory on the heap.
// malloc returns a `byteptr` pointing to the memory address of the allocated space.
// unlike the `calloc` family of functions - malloc will not zero the memory block.
@[unsafe]

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by spytheman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants