-
Notifications
You must be signed in to change notification settings - Fork 196
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
GC Pinning #1085
base: master
Are you sure you want to change the base?
GC Pinning #1085
Conversation
I think there are some complications with using the GC memtype routines outside of a collection (ok in __Mark). With array data, it is possible that the the pointer is a foreign pointer (Set with NativeArray.setUnmanagedData). In this case, the arrays mAlloc will be -1, and no memory management on the pointer is needed - this should be checked before examining the header. You can check for 'const-ness' with bool IsConstAlloc(const void *inData). In this case, the data does not need any management at all (eg, string data) and will not be deleted. largeness can be determined from a valid header from the size ("size in allocated blocks"), which will be zero in this case int size = flags & 0xffff;
// Size will be 0 for large allocs -> no need to mark block You may need to add some code to prevent large allocations from getting destroyed in a realloc process, see InternalRealloc and InternalReleaseMem. The theory is that only 1 array will hold the byte data, so it can be cleaned when the array is resized. If you are storing GC block pointers in a haxe object, some additional work must be done the in the generational case, HX_OBJ_WB should be called. This is for the case where the object holding the pointer is "old" and the pointer is generationally new. This call means your __Mark will get called when doing a minor generational collection. |
Thanks for the tips, I see what you mean about the large list locking. Perhaps it makes sense to come at this from a different angle then, if arrays had a |
This reverts commit dbeba7e.
OK, I've completely re-jigged this merge. MemType changes have been reverted and it adds pinning spport. |
Probably better to use the atomic inc/dec ops for mPinned manipulation if pinning might happen from any haxe thread. |
I thought of the atomic operations just as I was going to bed, I've changed things around now though so that Another thing I'm unsure of, when marking the pins do I need to do the whole process of checking the pointer type and then calling either mark object, mark string, etc, as is done in the conservative marking function, or is it just to just call |
This seems good. Changing the length is the same as changing, say, the first element - more of a documentation issue if it does not crash. The only alternative is to copy, since there is not real way to do copy-on-write without incurring overhead. |
Yeah, thats fair. The only way to solve it without the extra copy would probably be to introduce an extra BytesData type instead of that being a typedef to an array. Since this is primarially going to be used with haxe bytes that would stop the user peeking at the underlying implementation and resizing it. |
Probably should have opened this as a draft to begin with. I'm not planning on adding anything else so if this looks good its probably good to merge. |
Makes the
MemType
enum andGetMemType
function accessible from thehx
namespace as mentioned in #1082.