Skip to content
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

use GC.malloc_atomic to allocate objects without pointers #4081

Closed
wants to merge 1 commit into from

Conversation

kostya
Copy link
Contributor

@kostya kostya commented Feb 26, 2017

bdwgc recommend to use malloc_atomic (https://github.com/ivmai/bdwgc#the-c-interface-to-the-allocator) to allocate binary data. I apply this to some places, but there is actually much more places, that can be optimized. Bytes.new for example, or better Pointer(T).malloc choose to use atomic if T is not reference.

@asterite
Copy link
Member

asterite commented Mar 2, 2017

I've thought about making Pointer(T).malloc use GC.malloc_atomic if T doesn't have references (the check is trivial for primitive types but a bit more tricky for other types, for example structs). The only gotcha would be to do something like Pointer(UInt8).malloc(size).as(SomeReferenceType) but for those cases we can probably use Pointer(Void) and document that Void should be used in those cases (and we consider Void as potentially having inner pointers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants