Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

[Interpreter] Array #6965

Merged
merged 13 commits into from
Feb 12, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@

using Volatile = System.Threading.Volatile;

#if BIT64
jkotas marked this conversation as resolved.
Show resolved Hide resolved
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
#endif

namespace Internal.Runtime.Augments
{
[ReflectionBlocked]
Expand Down Expand Up @@ -158,6 +164,17 @@ public static unsafe Array NewMultiDimArray(RuntimeTypeHandle typeHandleForArray
return Array.NewMultiDimArray(typeHandleForArrayType.ToEETypePtr(), pLengths, lengths.Length);
}

public static void StelemRef(Array array, int index, object obj)
{
TypeCast.StelemRef(array, index, obj);
Copy link
Member

@jkotas jkotas Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that this won't compile in the closed source ProjectN build (the Runtime,Base is not part of CoreLib in that build). @MichalStrehovsky Do you agree?

I think it would be easier to delete this method; and replace the calls with Unsafe.As<Object[]>(array)[index] = obj;.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it wouldn't compile. Unsafe.As sounds good!

}

public static ref byte GetSzArrayElementAddress(Array array, int index)
{
ref byte start = ref array.GetRawSzArrayData();
return ref Unsafe.Add(ref start, (IntPtr)((nuint)index * array.ElementSize));
}

public static IntPtr GetAllocateObjectHelperForType(RuntimeTypeHandle type)
{
return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeImports.RuntimeHelperKind.AllocateObject);
Expand Down
Loading