Use boolean allocation options #1400
Draft
+68
−51
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.
We remove
OnAllocationFail
and add three boolean fields toAllocationOptions
:allow_polling
: whether this allocation attempt allows polling and trigger GCat_safepoint
: whether this allocation is at a safepoint, allowing it to block for GC when GC is triggeredallow_overcommit
: whether we allow overcommitThis will allow new combinations that cannot be expressed by the previous
OnAllocationFail
type. Particularly, it allows both polling and over-committing to happen in one allocation attempt. If this allocation is also not at a safepoint, this combination will allow the current mutator to allocate normally in this allocation, but block for GC at the nearest safepoint.Note: This PR implements the idea proposed in #1382 (comment). I created a new PR because the resulting commit will be radically different from #1382.
TODO:
AllocationOptions
can still be stored and loaded atomically. It should suffice if its size is smaller than the word size. If Rust is unhappy with three boolean fields, replace it with a bit field.This PR supersedes the following PRs: