Document odd conditional in runtime_heap_base initialization logic
Opened this issue · 0 comments
The runtime heap base is currently set to memory_size under certain conditions, but the reasoning is undocumented and no contributor recalls why this is written this way. Given that this code was recently refactored, this should be investigated by checking out the following commit (cd9b619) and using GitLens or a similar tool to track down the origin of this code to better understand and document this logic. It likely is useful to also review how wasmg___heap_base
is generated to understands paths when that might be zero or non-zero.
runtime_heap_base = wasmg___heap_base;
if (runtime_heap_base == 0) {
runtime_heap_base = memory_size;
}
Follow up context from @Others
"I do think it maybe should always be at the end of memory (not at the heap base), since otherwise malloc might overwrite this. Honestly this is basically just a wasmception hack since wasi does APIs in a more sane way."