mmtk / mmtk-core

Memory Management ToolKit
https://www.mmtk.io
Other
379 stars 69 forks source link

Add alloc_no_gc #1218

Open qinsoon opened 3 weeks ago

qinsoon commented 3 weeks ago

This PR adds allocation functions that are not GC safe points. On failed allocation, they will not attempt a GC and will just return a null address.

Our current alloc functions assume they are GC safe points and will trigger GCs internally. A runtime may have different assumptions. We see GHC has allocateMightFail (https://gitlab.haskell.org/ghc/ghc/-/blob/90746a591919fc51a0ec9dec58d8f1c8397040e3/rts/sm/Storage.c?page=2#L1089). Also Julia assumes perm alloc will not trigger a GC (https://github.com/mmtk/mmtk-julia/issues/172). Having a variant of alloc that is not GC safepoints could be generally useful.

qinsoon commented 3 weeks ago

I changed the documentation based on the suggestions.

qinsoon commented 3 weeks ago

I’m awaiting feedback from @JunmingZhao42 and Ben before merging this PR, as they requested this feature.