Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime;

namespace Internal.Runtime.CompilerHelpers
{
/// <summary>
/// These methods are used to implement memcpy and memset intrinsics with null checks.
/// </summary>
internal static class MemoryHelpers
{
private static unsafe void MemSet(ref byte dest, byte value, nuint size)
{
if (size > 0)
{
_ = dest;
SpanHelpers.Fill(ref dest, size, value);
}
}

private static unsafe void MemCopy(ref byte dest, ref byte src, nuint size)
{
if (size > 0)
{
_ = dest;
_ = src;
Buffer.Memmove(ref dest, ref src, size);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<Compile Include="Internal\Runtime\CompilerHelpers\ArrayHelpers.cs" />
<Compile Include="Internal\Runtime\CompilerHelpers\InteropHelpers.cs" />
<Compile Include="Internal\Runtime\CompilerHelpers\LdTokenHelpers.cs" />
<Compile Include="Internal\Runtime\CompilerHelpers\MemoryHelpers.cs" />
<Compile Include="Internal\Runtime\CompilerHelpers\RuntimeInteropData.cs" />
<Compile Include="Internal\Runtime\CompilerHelpers\SynchronizedMethodHelpers.cs" />
<Compile Include="Internal\Runtime\CompilerHelpers\TypedReferenceHelpers.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id,
break;

case ReadyToRunHelper.MemCpy:
mangledName = "memcpy"; // TODO: Null reference handling
methodDesc = context.GetHelperEntryPoint("MemoryHelpers", "MemCopy");
break;
case ReadyToRunHelper.MemSet:
mangledName = "memset"; // TODO: Null reference handling
methodDesc = context.GetHelperEntryPoint("MemoryHelpers", "MemSet");
break;

case ReadyToRunHelper.GetRuntimeTypeHandle:
Expand Down