Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried to give a shot to #445 just for fun and as a challenge with this draft PR, which is still WIP.
This introduces a new struct called
SharedMemory
which is indeed shared between calls. I'd like a feedback on my implementation to see what it can done better.Here are some implementation choices I made:
Memory
implementationcurrent_slice
which is internally used to refer to the portion of data reserved for the current context. This requires twounsafe
methodsget_current_slice
andget_current_slice_mut
which deferences the raw pointercurrent_slice
pointer is updated when entering a new context (which is when a newInterpreter
instance is created) using theuse_new_memory
method (every name is still WIP too) and when exiting it, which happens when thereturn_value
method ofInterpreter
is calledSharedMemory
work properly, it is wrapped in aRc
for dealing with recursive calls and with anRefCell
to allow mutabilityLittle problem: now test passes because I always allocate
u32::MAX
bytes. If I use the estimation however they fail because some tests have an impressive gas limit (at least 4_503_599_627_349_304), and my system fails to allocate so much memory (34_359_713_280 bytes). I don't really know how to handle this at the momentThanks in advance for any feedback!