Skip to content

Commit

Permalink
Move RuntimeHelpers.GetRawData and RawData class to shared location
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdageek committed Oct 30, 2020
1 parent fb59f61 commit 6a8bc4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ internal static int EnumCompareTo<T>(T x, T y) where T : struct, Enum
return x.CompareTo(y);
}

internal static ref byte GetRawData(this object obj) =>
ref Unsafe.As<RawData>(obj).Data;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe nuint GetRawObjectDataSize(object obj)
{
Expand Down Expand Up @@ -335,12 +332,6 @@ private static unsafe void DispatchTailCalls(
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern int GetMethodsJittedCount();
}
// Helper class to assist with unsafe pinning of arbitrary objects.
// It's used by VM code.
internal class RawData
{
public byte Data;
}

// CLR arrays are laid out in memory as follows (multidimensional array bounds are optional):
// [ sync block || pMethodTable || num components || MD array bounds || array data .. ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,14 @@ public static void PrepareConstrainedRegionsNoOP()
internal static bool IsPrimitiveType(this CorElementType et)
// COR_ELEMENT_TYPE_I1,I2,I4,I8,U1,U2,U4,U8,R4,R8,I,U,CHAR,BOOLEAN
=> ((1 << (int)et) & 0b_0011_0000_0000_0011_1111_1111_1100) != 0;

internal static ref byte GetRawData(this object obj) =>
ref Unsafe.As<RawData>(obj).Data;
}
// Helper class to assist with unsafe pinning of arbitrary objects.
// It's used by VM code.
internal class RawData
{
public byte Data;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Internal.Runtime.CompilerServices;

namespace System.Runtime.CompilerServices
{
Expand Down Expand Up @@ -55,16 +54,6 @@ public static void RunClassConstructor(RuntimeTypeHandle type)
RunClassConstructor(type.Value);
}

internal static ref byte GetRawData(this object obj) =>
ref Unsafe.As<RawData>(obj).Data;

// Helper class to assist with unsafe pinning of arbitrary objects.
// It's used by VM code.
internal class RawData
{
public byte Data;
}

public static void EnsureSufficientExecutionStack()
{
if (SufficientExecutionStack())
Expand Down

0 comments on commit 6a8bc4d

Please sign in to comment.