Skip to content

Commit 7b050bb

Browse files
authored
Update mscorlib declaration and implement Unsafe.As<T> (#3233)
1 parent 7194b7c commit 7b050bb

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed

CMake/Modules/FindNF_CoreCLR.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ set(NF_CoreCLR_SRCS
110110
corlib_native_System_Reflection_Binder.cpp
111111
corlib_native_System_Reflection_MemberInfo.cpp
112112
corlib_native_System_Runtime_CompilerServices_RuntimeHelpers.cpp
113+
corlib_native_System_Runtime_CompilerServices_Unsafe.cpp
113114
corlib_native_System_Runtime_Remoting_RemotingServices.cpp
114115
corlib_native_System_String.cpp
115116
corlib_native_System_Span_1.cpp

src/CLR/CorLib/CorLib.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<ClCompile Include="corlib_native_System_Reflection_RuntimeMethodInfo.cpp" />
6161
<ClCompile Include="corlib_native_System_RuntimeType.cpp" />
6262
<ClCompile Include="corlib_native_System_Runtime_CompilerServices_RuntimeHelpers.cpp" />
63+
<ClCompile Include="corlib_native_System_Runtime_CompilerServices_Unsafe.cpp" />
6364
<ClCompile Include="corlib_native_System_Runtime_Remoting_RemotingServices.cpp" />
6465
<ClCompile Include="corlib_native_System_Span_1.cpp" />
6566
<ClCompile Include="corlib_native_System_String.cpp" />

src/CLR/CorLib/CorLib.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,8 @@
179179
<ClCompile Include="corlib_native_System_ReadOnlySpan_1.cpp">
180180
<Filter>Source Files</Filter>
181181
</ClCompile>
182+
<ClCompile Include="corlib_native_System_Runtime_CompilerServices_Unsafe.cpp">
183+
<Filter>Source Files</Filter>
184+
</ClCompile>
182185
</ItemGroup>
183186
</Project>

src/CLR/CorLib/corlib_native.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ static const CLR_RT_MethodHandler method_lookup[] =
278278
nullptr,
279279
nullptr,
280280
nullptr,
281+
nullptr,
282+
nullptr,
283+
nullptr,
284+
nullptr,
285+
nullptr,
286+
nullptr,
287+
nullptr,
288+
nullptr,
289+
nullptr,
290+
nullptr,
291+
nullptr,
292+
nullptr,
293+
nullptr,
294+
nullptr,
281295
Library_corlib_native_System_BitConverter::get_IsLittleEndian___STATIC__BOOLEAN,
282296
Library_corlib_native_System_BitConverter::DoubleToInt64Bits___STATIC__I8__R8,
283297
Library_corlib_native_System_BitConverter::GetBytes___STATIC__SZARRAY_U1__BOOLEAN,
@@ -745,6 +759,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
745759
Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::RunClassConstructor___STATIC__VOID__SystemRuntimeTypeHandle,
746760
Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::get_OffsetToStringData___STATIC__I4,
747761
Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::IsReferenceOrContainsReferences___STATIC__BOOLEAN,
762+
Library_corlib_native_System_Runtime_CompilerServices_Unsafe::As___STATIC__GENERICTYPE__OBJECT,
748763
nullptr,
749764
Library_corlib_native_System_Runtime_Remoting_RemotingServices::IsTransparentProxy___STATIC__BOOLEAN__OBJECT,
750765
nullptr,
@@ -1573,7 +1588,7 @@ const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_mscorlib =
15731588

15741589
#if (NANOCLR_REFLECTION == TRUE)
15751590

1576-
0xCF059C3B,
1591+
0x559086F3,
15771592

15781593
#elif (NANOCLR_REFLECTION == FALSE)
15791594

src/CLR/CorLib/corlib_native.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,15 @@ struct Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers
889889
bool &isRefContainsRefs);
890890
};
891891

892+
#if (NANOCLR_REFLECTION == TRUE)
893+
struct Library_corlib_native_System_Runtime_CompilerServices_Unsafe
894+
{
895+
NANOCLR_NATIVE_DECLARE(As___STATIC__GENERICTYPE__OBJECT);
896+
897+
//--//
898+
};
899+
#endif
900+
892901
struct Library_corlib_native_System_Runtime_Remoting_RemotingServices
893902
{
894903
NANOCLR_NATIVE_DECLARE(IsTransparentProxy___STATIC__BOOLEAN__OBJECT);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4+
// See LICENSE file in the project root for full license information.
5+
//
6+
7+
#include "CorLib.h"
8+
9+
HRESULT Library_corlib_native_System_Runtime_CompilerServices_Unsafe::As___STATIC__GENERICTYPE__OBJECT(
10+
CLR_RT_StackFrame &stack)
11+
{
12+
NANOCLR_HEADER();
13+
14+
CLR_RT_HeapBlock &arg = stack.Arg0();
15+
16+
// Set the argument as the return value (ldarg.0; ret)
17+
stack.PushValueAndAssign(arg);
18+
19+
NANOCLR_NOCLEANUP_NOLABEL();
20+
}

0 commit comments

Comments
 (0)