ballercat / walt

:zap: Walt is a JavaScript-like syntax for WebAssembly text format :zap:

Home Page:https://ballercat.github.io/walt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose memory.grow, memory.size, memory.dataLength

ballercat opened this issue · comments

Goal

Unblock work for a full-blown allocator.

Overview

memory_grow are not available through walt, but can be implemented as members of the Memory and Table types.

Acceptance Criteria

This should work

const memory : Memory = { initial: 1 };

function test() {
  memory.size();
  memory.grow();
  memory.dataSize();
}
  • Memory.grow()
  • Memory.size() current size of memory
  • Memory.dataSize length of the data section, always zero until data senction encoding is implemented.

Thanks, hopefully, it only affects text encoding. Might need to adjust some docs etc.,

this would be nice :)

Implemented by #148

Not sure if this is the best place to ask, if I have a function that has to allocate a lot of memory for one operation (say I pass an unusually long array to it), but no more after that, will it keep using up all that memory?

yea, afaik you can't shrink memory.. if that's what you're asking..
The linear memory can only get bigger, not smaller..

Thanks, good to know (that kind of sucks for the things that I was thinking of doing though, because it involves operations on arrays that can get quite big but only incidentally)

you can always reuse the memory for other stuff..