-
-
Notifications
You must be signed in to change notification settings - Fork 673
Implement a memory manager #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See: examples/tlsf/assembly/tlsf.ts Feel free to do excessive test-runs if you have some spare time :) |
Hi, which kind of problem with TLSF implementation now? |
Something appears to be odd about the code currently. Whenever a new block is allocated, it appears that it loses track of all the previous blocks. Or something like that, not sure, but it always grows the memory even if just two small blocks are allocated, which is an indicator for something going haywire. Another thing is that adding a memory pool adds that sentinel block, which seems to be invalid according to My last attempt was to make an html page that visualizes all the stuff that's going on, by reimplementing |
Hmm, I think first of all I try to implement and visualize this by transpiling to javascript whole tlsf code for easer debugging. If all will be correct that mean problem in some part of compiler |
That's a good plan as well, yeah |
The latest commit added a re-implementation of TLSF that, according to its test, works properly. There'll most likely be additional optimization opportunities, though, and when growing memory it doesn't yet coalesce pages, but that should be trivial to add. One more thing to think about are aligned allocations, for instance when allocating memory for a class that starts with an 8-byte long field. |
Excellent job! |
Yeah, 32-bit TLSF has the inconvenient property of having a 4-byte block header. Still thinking about more efficient solutions than splitting away MIN_SIZE-sized small blocks on alignment misses. |
What do you think, is this ready for dynamic object allocation? Except 8-byte alignment of course |
According to this test setup, yes (i.e. run |
Yes. Test was passed. Great work! So can we focused on dynamic object creation such as arrays? |
Once there is a GC implementation, yes. For testing purposes, it's also ok-ish to use the arena allocator. A specific allocator can be set by including one in the entry file, like For reference, without a GC, something like |
Ok, will try to using this approach. Actually I want just test some wasm generation with compare to rust and needs in arraylike entity. |
Ok, we have several memory allocators now: TLSF, Buddy and Arena. These all pass their tests and all align to 8 bytes, so I'm going to close this issue. Next steps: Optimize them where beneficial and figure out GC. |
Memory management is pretty much a filler currently and consists of a large linear chunk of non-disposable memory.
Ref: std/assembly/heap.ts
API is:
usize
):usize
Pretty much like C's
malloc
.usize
):void
Pretty much like C's
free
.Requirements are, in this order:
TLSF seems to be a viable candidate.
Useful resources:
The text was updated successfully, but these errors were encountered: