Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Implement function for adding and removing WASM memory #504

Closed
brianjohnson5972 opened this issue Sep 26, 2017 · 2 comments
Closed

Implement function for adding and removing WASM memory #504

brianjohnson5972 opened this issue Sep 26, 2017 · 2 comments
Assignees
Milestone

Comments

@brianjohnson5972
Copy link
Contributor

Implement logic similar to Emscripten's sbrk function in wasm_interface. Will need to impose a max size of 1M. Also need to perform checktime after memory is grown or shrunk to ensure time allotment isn't exceeded. Function will return the offset of the new memory that can be used for the new buffer. This will be used by #129 to allocate new pages when existing buffers are exhausted.

@brianjohnson5972
Copy link
Contributor Author

Logic is written and now writing unit tests.

@brianjohnson5972
Copy link
Contributor Author

@bytemaster for the emscrypten sbrk function the return value is useful when you pass in a positive num_bytes to allocate, since it will point to the previous number of bytes, which would be the offset of the start of the new block of memory, but I'm not sure how a user could use the return value if a negative num_bytes is passed, since it will be returning the offset of the end of the buffer that is to be removed. So I am thinking that the eoslib provided function will only take positive num_bytes and only the code that returns the MemoryInstance to its original size (a single 64K page) will be able to shrink the memory. Does that make sense?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants