Skip to content

Implement Write Barrier and dsize for FFI::Pointer#1010

Merged
larskanis merged 1 commit into
ffi:masterfrom
casperisfine:pointer-write-barrier
Mar 6, 2023
Merged

Implement Write Barrier and dsize for FFI::Pointer#1010
larskanis merged 1 commit into
ffi:masterfrom
casperisfine:pointer-write-barrier

Conversation

@casperisfine

Copy link
Copy Markdown

Ref: #991

As well as FFI::MemoryPointer and FFI::AbstractMemory

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.

@larskanis I'm curious whether FFI::AbstractMemory.new is ever meant to be used? If I make it raise no test fail, and I really don't see what the usage would be.

I'm tempted to just undefine the allocation function.

@casperisfine
casperisfine force-pushed the pointer-write-barrier branch 2 times, most recently from 3959a43 to 7bbb50c Compare March 6, 2023 17:30
As well as FFI::MemoryPointer and FFI::AbstractMemory

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.
@casperisfine
casperisfine force-pushed the pointer-write-barrier branch from 7bbb50c to eebf524 Compare March 6, 2023 17:43
@casperisfine

Copy link
Copy Markdown
Author

I added FFI::Buffer as well, as it's mostly the same code.

@larskanis
larskanis merged commit d54ea5a into ffi:master Mar 6, 2023
larskanis added a commit to larskanis/ffi that referenced this pull request Mar 6, 2023
This disables AbstractMemory.new, which has no practical use.

As discussed in ffi#1010
@larskanis

Copy link
Copy Markdown
Member

Probably no. I couldn't find any use of FFI::AbstractMemory.new by the github search. And I don't have an idea what a FFI::AbstractMemory object could be used for. I opened #1013, probably similar of what you though about.

@casperisfine casperisfine mentioned this pull request Apr 3, 2023
40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants