-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[NativeAOT] Remove unused native memcopy helpers. #84314
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,91 +21,17 @@ | |
// | ||
// USAGE: The caller is responsible for hoisting any null reference exceptions to a place where the hardware exception | ||
// can be properly translated to a managed exception. | ||
COOP_PINVOKE_CDECL_HELPER(void *, RhpInitMultibyte, (void * mem, int c, size_t size)) | ||
COOP_PINVOKE_CDECL_HELPER(void *, RhpInitMultibyte, (void * mem, size_t size)) | ||
{ | ||
// The caller must do the null-check because we cannot take an AV in the runtime and translate it to managed. | ||
ASSERT(mem != nullptr); | ||
|
||
uintptr_t bv = (uint8_t)c; | ||
uintptr_t pv = 0; | ||
|
||
if (bv != 0) | ||
{ | ||
pv = | ||
#if (POINTER_SIZE == 8) | ||
bv << 7*8 | bv << 6*8 | bv << 5*8 | bv << 4*8 | | ||
#endif | ||
bv << 3*8 | bv << 2*8 | bv << 1*8 | bv; | ||
} | ||
|
||
InlineGCSafeFillMemory(mem, size, pv); | ||
InlineGCSafeFillMemory(mem, size, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this to |
||
|
||
// memset returns the destination buffer | ||
return mem; | ||
} | ||
|
||
|
||
// This is a GC-safe variant of memcpy. It guarantees that the object references in the GC heap are updated atomically. | ||
// This is required for type safety and proper operation of the background GC. | ||
// | ||
// USAGE: 1) The caller is responsible for performing the appropriate bulk write barrier. | ||
// 2) The caller is responsible for hoisting any null reference exceptions to a place where the hardware | ||
// exception can be properly translated to a managed exception. This is handled by RhpCopyMultibyte. | ||
// 3) The caller must ensure that all three parameters are pointer-size-aligned. This should be the case for | ||
// value types which contain GC refs anyway, so if you want to copy structs without GC refs which might be | ||
// unaligned, then you must use RhpCopyMultibyteNoGCRefs. | ||
COOP_PINVOKE_CDECL_HELPER(void *, memcpyGCRefs, (void * dest, const void *src, size_t len)) | ||
{ | ||
// null pointers are not allowed (they are checked by RhpCopyMultibyte) | ||
ASSERT(dest != nullptr); | ||
ASSERT(src != nullptr); | ||
|
||
InlineForwardGCSafeCopy(dest, src, len); | ||
|
||
// memcpy returns the destination buffer | ||
return dest; | ||
} | ||
|
||
// This is a GC-safe variant of memcpy. It guarantees that the object references in the GC heap are updated atomically. | ||
// This is required for type safety and proper operation of the background GC. | ||
// Writebarrier is included. | ||
// | ||
// USAGE: | ||
// 1) The caller is responsible for hoisting any null reference exceptions to a place where the hardware | ||
// exception can be properly translated to a managed exception. This is handled by RhpCopyMultibyte. | ||
// 2) The caller must ensure that all three parameters are pointer-size-aligned. This should be the case for | ||
// value types which contain GC refs anyway, so if you want to copy structs without GC refs which might be | ||
// unaligned, then you must use RhpCopyMultibyteNoGCRefs. | ||
COOP_PINVOKE_CDECL_HELPER(void *, memcpyGCRefsWithWriteBarrier, (void * dest, const void *src, size_t len)) | ||
{ | ||
// null pointers are not allowed (they are checked by RhpCopyMultibyteWithWriteBarrier) | ||
ASSERT(dest != nullptr); | ||
ASSERT(src != nullptr); | ||
|
||
InlineForwardGCSafeCopy(dest, src, len); | ||
InlinedBulkWriteBarrier(dest, len); | ||
|
||
// memcpy returns the destination buffer | ||
return dest; | ||
} | ||
|
||
// Same as memcpyGCRefsWithWriteBarrier, except it checks if memory might contain GC pointers | ||
// and if so dispatches to memcpyGCRefsWithWriteBarrier and if not uses traditional memcpy | ||
COOP_PINVOKE_CDECL_HELPER(void *, memcpyAnyWithWriteBarrier, (void * dest, const void *src, size_t len)) | ||
{ | ||
// null pointers are not allowed (they are checked by RhpCopyMultibyteWithWriteBarrier) | ||
ASSERT(dest != nullptr); | ||
ASSERT(src != nullptr); | ||
|
||
// Use GC safe copy whenever there might be GC pointers | ||
if (IS_ALIGNED(dest, sizeof(size_t)) && IS_ALIGNED(src, sizeof(size_t)) && IS_ALIGNED(len, sizeof(size_t))) | ||
{ | ||
return memcpyGCRefsWithWriteBarrier(dest, src, len); | ||
} | ||
|
||
return memcpy(dest, src, len); | ||
} | ||
|
||
// Move memory, in a way that is compatible with a move onto the heap, but | ||
// does not require the destination pointer to be on the heap. | ||
|
||
|
@@ -119,12 +45,6 @@ COOP_PINVOKE_HELPER(void, RhBulkMoveWithWriteBarrier, (uint8_t* pDest, uint8_t* | |
InlinedBulkWriteBarrier(pDest, cbDest); | ||
} | ||
|
||
void GCSafeCopyMemoryWithWriteBarrier(void * dest, const void *src, size_t len) | ||
{ | ||
InlineForwardGCSafeCopy(dest, src, len); | ||
InlinedBulkWriteBarrier(dest, len); | ||
} | ||
|
||
void REDHAWK_CALLCONV RhpBulkWriteBarrier(void* pMemStart, uint32_t cbMemSize) | ||
{ | ||
InlinedBulkWriteBarrier(pMemStart, cbMemSize); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the comment and/or the name to indicate that the buffer can contain GC references?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I am also tempted to move this to a managed helper as well, but I do not see a lot of reasons.
This is only used when unboxing a nullable null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move this to managed when/if we have a caller that could realistically need to zero something larger than
BulkMoveWithWriteBarrierChunk
.