Implement Write Barrier and dsize for FFI::StructLayout #1006
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.
And FFI::StructLayout::Field
Ref: #991
Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC.
The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected.
This commit also implement a
dsize
function so that these instance report a more relevant size in various memory profilers.I had to get rid of the
memset(0)
instruct_layout_mark
has with Write Barriers it's not guaranteed that the layout will be marked beforefieldName
is moved.I don't think it was a good fix anyway, it's better to mark these VALUE so the GC pin them. I think we could go back to an
st_table
and mark only the keys withrb_mark_set
. But I didn't want to go down this rabbit hole.