Skip to content

Commit 97b1d70

Browse files
committed
Use Buffer.BulkMoveWithWriteBarrier
1 parent 0db8727 commit 97b1d70

File tree

6 files changed

+10
-18
lines changed

6 files changed

+10
-18
lines changed

src/coreclr/inc/jithelpers.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@
153153
JITHELPER(CORINFO_HELP_ASSIGN_REF_ENSURE_NONHEAP, JIT_WriteBarrierEnsureNonHeapTarget,CORINFO_HELP_SIG_REG_ONLY)
154154

155155
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_BYREF, JIT_ByRefWriteBarrier,CORINFO_HELP_SIG_NO_ALIGN_STUB)
156-
157-
JITHELPER(CORINFO_HELP_ASSIGN_STRUCT, JIT_StructWriteBarrier,CORINFO_HELP_SIG_4_STACK)
156+
DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_STRUCT, NULL, CORINFO_HELP_SIG_REG_ONLY)
158157

159158
// Accessing fields
160159
JITHELPER(CORINFO_HELP_GETFIELD8, JIT_GetField8,CORINFO_HELP_SIG_REG_ONLY)

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id,
6868
mangledName = context.Target.Architecture == TargetArchitecture.ARM64 ? "RhpCheckedAssignRefArm64" : "RhpCheckedAssignRef";
6969
break;
7070
case ReadyToRunHelper.AssignStruct:
71-
mangledName = "RhBulkMoveWithWriteBarrier";
71+
mangledName = "RhBuffer_BulkMoveWithWriteBarrier";
7272
break;
7373
case ReadyToRunHelper.ByRefWriteBarrier:
7474
mangledName = context.Target.Architecture == TargetArchitecture.ARM64 ? "RhpByRefAssignRefArm64" : "RhpByRefAssignRef";

src/coreclr/vm/corelib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ DEFINE_METHOD(DEBUGGER, BREAK, Break,
891891
DEFINE_CLASS(BUFFER, System, Buffer)
892892
DEFINE_METHOD(BUFFER, MEMCPY_PTRBYTE_ARRBYTE, Memcpy, SM_PtrByte_Int_ArrByte_Int_Int_RetVoid)
893893
DEFINE_METHOD(BUFFER, MEMCPY, Memcpy, SM_PtrByte_PtrByte_Int_RetVoid)
894+
DEFINE_METHOD(BUFFER, MEMCOPYGC, BulkMoveWithWriteBarrier, SM_RefByte_RefByte_UIntPtr_RetVoid)
894895

895896
DEFINE_CLASS(STUBHELPERS, StubHelpers, StubHelpers)
896897
DEFINE_METHOD(STUBHELPERS, GET_DELEGATE_TARGET, GetDelegateTarget, SM_Delegate_RetIntPtr)

src/coreclr/vm/ecall.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ void ECall::PopulateManagedHelpers()
157157
pDest = pMD->GetMultiCallableAddrOfCode();
158158
SetJitHelperFunction(CORINFO_HELP_MEMCPY, pDest);
159159

160+
pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__BUFFER__MEMCOPYGC));
161+
pDest = pMD->GetMultiCallableAddrOfCode();
162+
SetJitHelperFunction(CORINFO_HELP_ASSIGN_STRUCT, pDest);
163+
160164
pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__MATH__ROUND));
161165
pDest = pMD->GetMultiCallableAddrOfCode();
162166
SetJitHelperFunction(CORINFO_HELP_DBLROUND, pDest);

src/coreclr/vm/jithelpers.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4779,21 +4779,6 @@ HCIMPLEND
47794779
//
47804780
//========================================================================
47814781

4782-
/*************************************************************/
4783-
HCIMPL3(VOID, JIT_StructWriteBarrier, intptr_t* dst, intptr_t* src, size_t byteCount)
4784-
{
4785-
FCALL_CONTRACT;
4786-
4787-
_ASSERT(byteCount > 0);
4788-
_ASSERT((byteCount % TARGET_POINTER_SIZE) == 0);
4789-
4790-
if (dst != src && byteCount != 0)
4791-
InlinedMemmoveGCRefsHelper(dst, src, byteCount);
4792-
4793-
FC_GC_POLL();
4794-
}
4795-
HCIMPLEND
4796-
47974782
/*************************************************************/
47984783
// Slow helper to tailcall from the fast one
47994784
NOINLINE HCIMPL0(void, JIT_PollGC_Framed)

src/libraries/System.Private.CoreLib/src/System/Buffer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ ref Unsafe.As<T, byte>(ref source),
177177
private const uint BulkMoveWithWriteBarrierChunk = 0x4000;
178178
#endif
179179

180+
#if NATIVEAOT
181+
[System.Runtime.RuntimeExport("RhBuffer_BulkMoveWithWriteBarrier")]
182+
#endif
180183
internal static void BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount)
181184
{
182185
if (byteCount <= BulkMoveWithWriteBarrierChunk)

0 commit comments

Comments
 (0)