Define CORERT for ProjectN builds
CoreRT is component of ProjectN (aka .NET Native for UWP), but our current defines do not reflect it because of CORERT is not defined in ProjectN builds. This creates confusion for folks outside the core runtime team, and conflicts with our documentation. For example, https://github.com/dotnet/corert/blob/master/Documentation/intro-to-corert.md says "CoreRT is the .NET Core runtime that is optimized for AOT scenarios, which .NET Native targets". It does not say "CoreRT is the .NET Core runtime optimized for AOT scenarios that uses RyuJIT backend" or anything like that. - Before this change: PROJECTN: defined in closed source ProjectN builds CORERT: defined in open source CoreRT builds CORECLR: defined in CoreCLR builds - After this change: PROJECTN: defined in closed source ProjectN builds (same) CORERT: defined in both open source CoreRT builds and closed source ProjectN builds (different) CORECLR: defined in CoreCLR builds (same) [tfs-changeset: 1680901]
This commit is contained in:
Родитель
f2445930d6
Коммит
e0416c0125
|
@ -214,7 +214,7 @@
|
|||
</Choose>
|
||||
|
||||
<!-- Set up various other constants -->
|
||||
<PropertyGroup Condition="'$(IsProjectNLibrary)' != 'true'">
|
||||
<PropertyGroup>
|
||||
<DefineConstants>CORERT;$(DefineConstants)</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetsWindows)'=='true'">
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
section->TypeManager = typeManager;
|
||||
section->ModuleIndex = moduleIndex;
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
// Initialize statics if any are present
|
||||
IntPtr staticsSection = RuntimeImports.RhGetModuleSection(typeManager, ReadyToRunSectionType.GCStaticRegion, out length);
|
||||
if (staticsSection != IntPtr.Zero)
|
||||
|
@ -141,7 +141,7 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
}
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
private static unsafe void InitializeStatics(IntPtr gcStaticRegionStart, int length)
|
||||
{
|
||||
IntPtr gcStaticRegionEnd = (IntPtr)((byte*)gcStaticRegionStart + length);
|
||||
|
@ -172,7 +172,7 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // CORERT
|
||||
#endif // !PROJECTN
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
|
|
@ -1184,7 +1184,7 @@ namespace Internal.Runtime
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif // CORERT
|
||||
#endif // EETYPE_TYPE_MANAGER
|
||||
|
||||
internal unsafe EETypeRareFlags RareFlags
|
||||
{
|
||||
|
|
|
@ -71,11 +71,11 @@ namespace System.Runtime
|
|||
[CLSCompliant(false)]
|
||||
public unsafe byte* ConvertRVAToPointer(uint rva)
|
||||
{
|
||||
#if CORERT
|
||||
Environment.FailFast("RVA fixups not supported in CoreRT");
|
||||
return null;
|
||||
#else
|
||||
#if PROJECTN
|
||||
return ((byte*)OsModuleBase) + rva;
|
||||
#else
|
||||
Environment.FailFast("RVA fixups not supported");
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace ILCompiler.DependencyAnalysis
|
|||
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
public override void EnsureEntry(GenericLookupResult lookupResult) => throw new NotImplementedException();
|
||||
public override int GetSlotForEntry(GenericLookupResult entry) => throw new NotImplementedException();
|
||||
public override IEnumerable<GenericLookupResult> Entries => throw new NotImplementedException();
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace ILCompiler
|
|||
/// </summary>
|
||||
string GetAppExeDirectory()
|
||||
{
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
var process = Process.GetCurrentProcess();
|
||||
string fullPath = process.MainModule.FileName;
|
||||
return Path.GetDirectoryName(fullPath);
|
||||
|
@ -137,10 +137,7 @@ namespace ILCompiler
|
|||
/// </summary>
|
||||
void LoadExceptionFile(string exceptionFileName)
|
||||
{
|
||||
#if CORERT
|
||||
Debug.Assert(false);
|
||||
return;
|
||||
#else
|
||||
#if PROJECTN
|
||||
if (!File.Exists(exceptionFileName))
|
||||
return;
|
||||
|
||||
|
|
|
@ -361,10 +361,7 @@ static bool InWriteBarrierHelper(UIntNative faultingIP)
|
|||
(UIntNative)&RhpCheckedAssignRefAVLocation,
|
||||
(UIntNative)&RhpCheckedLockCmpXchgAVLocation,
|
||||
(UIntNative)&RhpCheckedXchgAVLocation,
|
||||
#ifdef CORERT
|
||||
(UIntNative)&RhpLockCmpXchg32AVLocation,
|
||||
(UIntNative)&RhpLockCmpXchg64AVLocation,
|
||||
#else
|
||||
#ifdef PROJECTN
|
||||
(UIntNative)&RhpCopyMultibyteDestAVLocation,
|
||||
(UIntNative)&RhpCopyMultibyteSrcAVLocation,
|
||||
(UIntNative)&RhpCopyMultibyteNoGCRefsDestAVLocation,
|
||||
|
@ -373,6 +370,9 @@ static bool InWriteBarrierHelper(UIntNative faultingIP)
|
|||
(UIntNative)&RhpCopyMultibyteWithWriteBarrierSrcAVLocation,
|
||||
(UIntNative)&RhpCopyAnyWithWriteBarrierDestAVLocation,
|
||||
(UIntNative)&RhpCopyAnyWithWriteBarrierSrcAVLocation,
|
||||
#else
|
||||
(UIntNative)&RhpLockCmpXchg32AVLocation,
|
||||
(UIntNative)&RhpLockCmpXchg64AVLocation,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ EXTERN_C REDHAWK_API UInt64 REDHAWK_CALLCONV RhpDbl2ULng(double val)
|
|||
return((UInt64)val);
|
||||
}
|
||||
|
||||
// CORERT Specific - on Project N the arguments to these helpers are inverted
|
||||
#ifdef CORERT
|
||||
// On ProjectN the arguments to these helpers are inverted
|
||||
#ifndef PROJECTN
|
||||
#undef min
|
||||
#undef max
|
||||
#include <cmath>
|
||||
|
@ -80,7 +80,7 @@ EXTERN_C REDHAWK_API float REDHAWK_CALLCONV RhpFltRound(float value)
|
|||
return roundf(value);
|
||||
}
|
||||
|
||||
#endif // CORERT
|
||||
#endif // !PROJECTN
|
||||
|
||||
#ifdef _ARM_
|
||||
EXTERN_C REDHAWK_API Int32 REDHAWK_CALLCONV RhpIDiv(Int32 i, Int32 j)
|
||||
|
|
|
@ -185,9 +185,7 @@ COOP_PINVOKE_HELPER(HANDLE, RhGetOSModuleFromPointer, (PTR_VOID pPointerVal))
|
|||
|
||||
COOP_PINVOKE_HELPER(HANDLE, RhGetOSModuleFromEEType, (EEType * pEEType))
|
||||
{
|
||||
#if CORERT
|
||||
return pEEType->GetTypeManagerPtr()->AsTypeManager()->GetOsModuleHandle();
|
||||
#else
|
||||
#if PROJECTN
|
||||
#if EETYPE_TYPE_MANAGER
|
||||
if (pEEType->HasTypeManager())
|
||||
return pEEType->GetTypeManagerPtr()->AsTypeManager()->GetOsModuleHandle();
|
||||
|
@ -210,14 +208,14 @@ COOP_PINVOKE_HELPER(HANDLE, RhGetOSModuleFromEEType, (EEType * pEEType))
|
|||
// We should never get here (an EEType not located in any module) so fail fast to indicate the bug.
|
||||
RhFailFast();
|
||||
return NULL;
|
||||
#endif // !CORERT
|
||||
#else
|
||||
return pEEType->GetTypeManagerPtr()->AsTypeManager()->GetOsModuleHandle();
|
||||
#endif // PROJECTN
|
||||
}
|
||||
|
||||
COOP_PINVOKE_HELPER(TypeManagerHandle, RhGetModuleFromEEType, (EEType * pEEType))
|
||||
{
|
||||
#if CORERT
|
||||
return *pEEType->GetTypeManagerPtr();
|
||||
#else
|
||||
#if PROJECTN
|
||||
#if EETYPE_TYPE_MANAGER
|
||||
if (pEEType->HasTypeManager())
|
||||
return *pEEType->GetTypeManagerPtr();
|
||||
|
@ -244,7 +242,9 @@ COOP_PINVOKE_HELPER(TypeManagerHandle, RhGetModuleFromEEType, (EEType * pEEType)
|
|||
// We should never get here (an EEType not located in any module) so fail fast to indicate the bug.
|
||||
RhFailFast();
|
||||
return TypeManagerHandle::Null();
|
||||
#endif // !CORERT
|
||||
#else
|
||||
return *pEEType->GetTypeManagerPtr();
|
||||
#endif // PROJECTN
|
||||
}
|
||||
|
||||
COOP_PINVOKE_HELPER(Boolean, RhFindBlob, (TypeManagerHandle *pTypeManagerHandle, UInt32 blobId, UInt8 ** ppbBlob, UInt32 * pcbBlob))
|
||||
|
@ -268,7 +268,7 @@ COOP_PINVOKE_HELPER(Boolean, RhFindBlob, (TypeManagerHandle *pTypeManagerHandle,
|
|||
|
||||
return pBlob != NULL;
|
||||
}
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
else
|
||||
{
|
||||
HANDLE hOsModule = typeManagerHandle.AsOsModule();
|
||||
|
@ -307,7 +307,7 @@ COOP_PINVOKE_HELPER(Boolean, RhFindBlob, (TypeManagerHandle *pTypeManagerHandle,
|
|||
}
|
||||
END_FOREACH_MODULE
|
||||
}
|
||||
#endif // !CORERT
|
||||
#endif // PROJECTN
|
||||
|
||||
// If we get here we were passed a bad module handle and should fail fast since this indicates a nasty bug
|
||||
// (which could lead to the wrong blob being returned in some cases).
|
||||
|
@ -384,7 +384,7 @@ COOP_PINVOKE_HELPER(UInt8 *, RhGetThreadStaticFieldAddress, (EEType * pEEType, U
|
|||
}
|
||||
else
|
||||
{
|
||||
#if EETYPE_TYPE_MANAGER && !CORERT /* TODO: CORERT */
|
||||
#if EETYPE_TYPE_MANAGER && PROJECTN /* TODO: CORERT */
|
||||
if (pEEType->HasTypeManager())
|
||||
{
|
||||
TypeManager* pTypeManager = pEEType->GetTypeManagerPtr()->AsTypeManager();
|
||||
|
|
|
@ -715,7 +715,7 @@ bool RuntimeInstance::CreateGenericAndStaticInfo(EEType * pEEType,
|
|||
}
|
||||
|
||||
NewArrayHolder<UInt8> pGcStaticData;
|
||||
#ifndef CORERT
|
||||
#ifdef PROJECTN
|
||||
if (gcStaticDataSize > 0)
|
||||
{
|
||||
// The value of gcStaticDataSize is read from native layout info in the managed layer, where
|
||||
|
|
|
@ -180,7 +180,7 @@ HANDLE TypeManager::GetOsModuleHandle()
|
|||
|
||||
bool TypeManagerHandle::IsTypeManager()
|
||||
{
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
if (((uintptr_t)_value & 1) == 0)
|
||||
return false;
|
||||
#endif
|
||||
|
|
|
@ -424,11 +424,11 @@ endif
|
|||
movdqa xmm14,[r8 + OFFSETOF__REGDISPLAY__Xmm + 8*10h]
|
||||
movdqa xmm15,[r8 + OFFSETOF__REGDISPLAY__Xmm + 9*10h]
|
||||
|
||||
ifdef CORERT ;; @TODO Reconcile
|
||||
ifdef PROJECTN ;; @TODO Reconcile
|
||||
mov rcx, [rsp + rsp_offsetof_arguments + 0h] ;; rcx <- exception object
|
||||
else
|
||||
mov rcx, [r8 + OFFSETOF__REGDISPLAY__SP] ;; rcx <- establisher frame
|
||||
mov rdx, [rsp + rsp_offsetof_arguments + 0h] ;; rdx <- exception object
|
||||
else
|
||||
mov rcx, [rsp + rsp_offsetof_arguments + 0h] ;; rcx <- exception object
|
||||
endif
|
||||
call qword ptr [rsp + rsp_offsetof_arguments + 8h] ;; call handler funclet
|
||||
|
||||
|
@ -666,11 +666,11 @@ NESTED_ENTRY RhpCallFilterFunclet, _TEXT
|
|||
mov rbp, [rax]
|
||||
|
||||
mov rax, rdx ;; rax <- handler funclet address
|
||||
ifdef CORERT ;; @TODO Reconcile
|
||||
ifdef PROJECTN ;; @TODO Reconcile
|
||||
;; RCX still contains the exception object
|
||||
else
|
||||
mov rdx, rcx ;; rdx <- exception object
|
||||
mov rcx, [r8 + OFFSETOF__REGDISPLAY__SP] ;; rcx <- establisher frame
|
||||
else
|
||||
;; RCX still contains the exception object
|
||||
endif
|
||||
call rax
|
||||
|
||||
|
|
|
@ -689,7 +689,7 @@ enum PInvokeTransitionFrameFlags
|
|||
#pragma warning(push)
|
||||
#pragma warning(disable:4200) // nonstandard extension used: zero-sized array in struct/union
|
||||
class Thread;
|
||||
#if defined(USE_PORTABLE_HELPERS) && defined(CORERT)
|
||||
#if defined(USE_PORTABLE_HELPERS)
|
||||
//the members of this structure are currently unused except m_pThread and exist only to allow compilation
|
||||
//of StackFrameIterator their values are not currently being filled in and will require significant rework
|
||||
//in order to satisfy the runtime requirements of StackFrameIterator
|
||||
|
@ -700,7 +700,7 @@ struct PInvokeTransitionFrame
|
|||
// can be an invalid pointer in universal transition cases (which never need to call GetThread)
|
||||
uint32_t m_dwFlags; // PInvokeTransitionFrameFlags
|
||||
};
|
||||
#else // USE_PORTABLE_HELPERS && CORERT
|
||||
#else // USE_PORTABLE_HELPERS
|
||||
struct PInvokeTransitionFrame
|
||||
{
|
||||
#ifdef _TARGET_ARM_
|
||||
|
@ -722,7 +722,7 @@ struct PInvokeTransitionFrame
|
|||
#endif
|
||||
UIntTarget m_PreservedRegs[];
|
||||
};
|
||||
#endif // USE_PORTABLE_HELPERS && CORERT
|
||||
#endif // USE_PORTABLE_HELPERS
|
||||
#pragma warning(pop)
|
||||
|
||||
#ifdef _TARGET_AMD64_
|
||||
|
|
|
@ -147,7 +147,7 @@ static void CheckForPalFallback()
|
|||
|
||||
void DetectCPUFeatures()
|
||||
{
|
||||
#if !defined(CORERT) // @TODO: CORERT: DetectCPUFeatures
|
||||
#ifdef PROJECTN // @TODO: CORERT: DetectCPUFeatures
|
||||
|
||||
#ifdef _X86_
|
||||
// We depend on fxsave / fxrstor. These were added to Pentium II and later, so they're pretty well guaranteed to be
|
||||
|
@ -167,7 +167,7 @@ void DetectCPUFeatures()
|
|||
g_fHasFastFxsave = true;
|
||||
#endif
|
||||
|
||||
#endif // !CORERT
|
||||
#endif // PROJECTN
|
||||
}
|
||||
|
||||
#ifdef PROFILE_STARTUP
|
||||
|
|
|
@ -289,10 +289,10 @@ void Thread::Construct()
|
|||
m_numDynamicTypesTlsCells = 0;
|
||||
m_pDynamicTypesTlsCells = NULL;
|
||||
|
||||
#if CORERT
|
||||
#ifndef PROJECTN
|
||||
m_pThreadLocalModuleStatics = NULL;
|
||||
m_numThreadLocalModuleStatics = 0;
|
||||
#endif // CORERT
|
||||
#endif // PROJECTN
|
||||
|
||||
// NOTE: We do not explicitly defer to the GC implementation to initialize the alloc_context. The
|
||||
// alloc_context will be initialized to 0 via the static initialization of tls_CurrentThread. If the
|
||||
|
@ -380,7 +380,7 @@ void Thread::Destroy()
|
|||
delete[] m_pDynamicTypesTlsCells;
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
#ifndef PROJECTN
|
||||
if (m_pThreadLocalModuleStatics != NULL)
|
||||
{
|
||||
for (UInt32 i = 0; i < m_numThreadLocalModuleStatics; i++)
|
||||
|
@ -392,7 +392,7 @@ void Thread::Destroy()
|
|||
}
|
||||
delete[] m_pThreadLocalModuleStatics;
|
||||
}
|
||||
#endif // CORERT
|
||||
#endif // !PROJECTN
|
||||
|
||||
RedhawkGCInterface::ReleaseAllocContext(GetAllocContext());
|
||||
|
||||
|
@ -1199,7 +1199,7 @@ COOP_PINVOKE_HELPER(Object *, RhpGetThreadAbortException, ())
|
|||
return pCurThread->GetThreadAbortException();
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
#ifndef PROJECTN
|
||||
Object* Thread::GetThreadStaticStorageForModule(UInt32 moduleIndex)
|
||||
{
|
||||
// Return a pointer to the TLS storage if it has already been
|
||||
|
@ -1282,7 +1282,7 @@ COOP_PINVOKE_HELPER(UInt8*, RhCurrentNativeThreadId, ())
|
|||
return (UInt8*)ThreadStore::RawGetCurrentThread();
|
||||
#endif // PLATFORM_UNIX
|
||||
}
|
||||
#endif // CORERT
|
||||
#endif // !PROJECTN
|
||||
|
||||
// Standard calling convention variant and actual implementation for RhpReversePInvokeAttachOrTrapThread
|
||||
EXTERN_C NOINLINE void FASTCALL RhpReversePInvokeAttachOrTrapThread2(ReversePInvokeFrame * pFrame)
|
||||
|
|
|
@ -93,10 +93,10 @@ struct ThreadBuffer
|
|||
UInt32 m_numDynamicTypesTlsCells;
|
||||
PTR_PTR_UInt8 m_pDynamicTypesTlsCells;
|
||||
|
||||
#if CORERT
|
||||
#ifndef PROJECTN
|
||||
PTR_PTR_VOID m_pThreadLocalModuleStatics;
|
||||
UInt32 m_numThreadLocalModuleStatics;
|
||||
#endif // CORERT
|
||||
#endif // PROJECTN
|
||||
};
|
||||
|
||||
struct ReversePInvokeFrame
|
||||
|
@ -261,10 +261,10 @@ public:
|
|||
Object * GetThreadAbortException();
|
||||
void SetThreadAbortException(Object *exception);
|
||||
|
||||
#if CORERT
|
||||
#ifndef PROJECTN
|
||||
Object* GetThreadStaticStorageForModule(UInt32 moduleIndex);
|
||||
Boolean SetThreadStaticStorageForModule(Object * pStorage, UInt32 moduleIndex);
|
||||
#endif // CORERT
|
||||
#endif // PROJECTN
|
||||
};
|
||||
|
||||
#ifndef GCENV_INCLUDED
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <evntprov.h>
|
||||
#ifndef CORERT
|
||||
#ifdef PROJECTN
|
||||
#include <roapi.h>
|
||||
#endif
|
||||
|
||||
|
@ -1377,7 +1377,7 @@ REDHAWK_PALEXPORT _Ret_maybenull_ void* REDHAWK_PALAPI PalSetWerDataBuffer(_In_
|
|||
|
||||
static LARGE_INTEGER g_performanceFrequency;
|
||||
|
||||
#ifndef CORERT
|
||||
#ifdef PROJECTN
|
||||
static bool g_roInitialized;
|
||||
#endif
|
||||
|
||||
|
@ -1391,7 +1391,7 @@ bool GCToOSInterface::Initialize()
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifndef CORERT
|
||||
#ifdef PROJECTN
|
||||
// TODO: Remove the RoInitialize call when we implement non-WinRT framework for classic apps
|
||||
HRESULT hr = RoInitialize(RO_INIT_MULTITHREADED);
|
||||
|
||||
|
@ -1415,7 +1415,7 @@ bool GCToOSInterface::Initialize()
|
|||
// Must be called on the same thread as Initialize.
|
||||
void GCToOSInterface::Shutdown()
|
||||
{
|
||||
#ifndef CORERT
|
||||
#ifdef PROJECTN
|
||||
if (g_roInitialized)
|
||||
{
|
||||
RoUninitialize();
|
||||
|
|
|
@ -29,12 +29,12 @@ namespace Internal.Runtime
|
|||
if (pGetArrayEEType != IntPtr.Zero)
|
||||
return (EEType*)CalliIntrinsics.Call<IntPtr>(pGetArrayEEType);
|
||||
}
|
||||
#if CORERT
|
||||
EH.FallbackFailFast(RhFailFastReason.InternalError, null);
|
||||
return null;
|
||||
#else
|
||||
#if PROJECTN
|
||||
fixed (EEType* pThis = &this)
|
||||
return InternalCalls.RhpGetArrayBaseType(pThis);
|
||||
#else
|
||||
EH.FallbackFailFast(RhFailFastReason.InternalError, null);
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ namespace System
|
|||
return (Internal.Runtime.EEType*)(void*)_value;
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
// This only works on CoreRT (with no fallback) because Runtime.Base doesn't have enough infrastructure
|
||||
#if !PROJECTN
|
||||
// This does not work on ProjectN (with no fallback) because Runtime.Base doesn't have enough infrastructure
|
||||
// to let us express typeof(T).TypeHandle.ToEETypePtr().
|
||||
[Intrinsic]
|
||||
internal static EETypePtr EETypePtrOf<T>()
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace System
|
|||
{
|
||||
private EETypePtr _pEEType;
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
[Intrinsic]
|
||||
internal static unsafe IntPtr GetValueInternal(RuntimeTypeHandle handle)
|
||||
{
|
||||
|
|
|
@ -19,11 +19,11 @@ namespace System.Collections
|
|||
/// will be smaller and faster than a Hashtable if the number of elements is 10 or less.
|
||||
/// This should not be used if performance is important for large numbers of elements.
|
||||
[Serializable]
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#if CORECLR
|
||||
internal
|
||||
#else
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#if CORERT
|
||||
public
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
class ListDictionaryInternal : IDictionary
|
||||
{
|
||||
|
|
|
@ -8,10 +8,10 @@ using CultureInfo = System.Globalization.CultureInfo;
|
|||
|
||||
namespace System
|
||||
{
|
||||
#if CORECLR
|
||||
internal
|
||||
#else
|
||||
#if CORERT
|
||||
public sealed
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
partial class DefaultBinder : Binder
|
||||
{
|
||||
|
|
|
@ -173,9 +173,7 @@ namespace System
|
|||
return Unsafe.Add(ref _pointer.Value, index);
|
||||
}
|
||||
#else
|
||||
#if CORERT
|
||||
[Intrinsic]
|
||||
#endif
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[NonVersionable]
|
||||
get
|
||||
|
|
|
@ -6,11 +6,10 @@ namespace System.Reflection
|
|||
{
|
||||
public abstract partial class MethodInfo : MethodBase
|
||||
{
|
||||
#if CORECLR
|
||||
internal
|
||||
#if CORERT
|
||||
public // Needs to be public so that Reflection.Core can see it.
|
||||
#else
|
||||
// Not an api but needs to be public so that Reflection.Core can access it.
|
||||
public
|
||||
internal
|
||||
#endif
|
||||
virtual int GenericParameterCount => GetGenericArguments().Length;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ using System.Diagnostics;
|
|||
|
||||
namespace System.Reflection
|
||||
{
|
||||
#if CORECLR
|
||||
internal
|
||||
#else
|
||||
#if CORERT
|
||||
public // Needs to be public so that Reflection.Core can see it.
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
static class SignatureTypeExtensions
|
||||
{
|
||||
|
|
|
@ -160,10 +160,10 @@ namespace System.Resources
|
|||
// into smaller chunks, each of size sqrt(n), would be substantially better for
|
||||
// resource files containing thousands of resources.
|
||||
//
|
||||
#if CORECLR
|
||||
internal
|
||||
#else
|
||||
#if CORERT
|
||||
public // On CoreRT, this must be public because of need to whitelist past the ReflectionBlock.
|
||||
#else
|
||||
internal
|
||||
#endif
|
||||
sealed class RuntimeResourceSet : ResourceSet, IEnumerable
|
||||
{
|
||||
|
@ -431,4 +431,4 @@ namespace System.Resources
|
|||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,14 @@ namespace System.Runtime.CompilerServices
|
|||
/// <summary>Creates an instance of the <see cref="AsyncValueTaskMethodBuilder{TResult}"/> struct.</summary>
|
||||
/// <returns>The initialized instance.</returns>
|
||||
public static AsyncValueTaskMethodBuilder<TResult> Create() =>
|
||||
#if CORECLR
|
||||
// _methodBuilder should be initialized to AsyncTaskMethodBuilder<TResult>.Create(), but on coreclr
|
||||
// that Create() is a nop, so we can just return the default here.
|
||||
default(AsyncValueTaskMethodBuilder<TResult>);
|
||||
#else
|
||||
#if CORERT
|
||||
// corert's AsyncTaskMethodBuilder<TResult>.Create() currently does additional debugger-related
|
||||
// work, so we need to delegate to it.
|
||||
new AsyncValueTaskMethodBuilder<TResult>() { _methodBuilder = AsyncTaskMethodBuilder<TResult>.Create() };
|
||||
#else
|
||||
// _methodBuilder should be initialized to AsyncTaskMethodBuilder<TResult>.Create(), but on coreclr
|
||||
// that Create() is a nop, so we can just return the default here.
|
||||
default(AsyncValueTaskMethodBuilder<TResult>);
|
||||
#endif
|
||||
|
||||
/// <summary>Begins running the builder with the associated state machine.</summary>
|
||||
|
|
|
@ -185,9 +185,7 @@ namespace System
|
|||
return ref Unsafe.Add(ref _pointer.Value, index);
|
||||
}
|
||||
#else
|
||||
#if CORERT
|
||||
[Intrinsic]
|
||||
#endif
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[NonVersionable]
|
||||
get
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace System
|
|||
/// This only exists for compatibility with .NET Framework.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
#if CORECLR
|
||||
internal
|
||||
#if CORERT
|
||||
public
|
||||
#else
|
||||
public // On CoreRT this must be public.
|
||||
internal
|
||||
#endif
|
||||
sealed class UnitySerializationHolder : ISerializable, IObjectReference
|
||||
{
|
||||
|
|
|
@ -592,10 +592,7 @@ namespace Internal.Runtime.Augments
|
|||
[Intrinsic]
|
||||
public static RuntimeTypeHandle GetCanonType(CanonTypeKind kind)
|
||||
{
|
||||
#if CORERT
|
||||
// Compiler needs to expand this. This is not expressible in IL.
|
||||
throw new NotSupportedException();
|
||||
#else
|
||||
#if PROJECTN
|
||||
switch (kind)
|
||||
{
|
||||
case CanonTypeKind.NormalCanon:
|
||||
|
@ -606,6 +603,9 @@ namespace Internal.Runtime.Augments
|
|||
Debug.Assert(false);
|
||||
return default(RuntimeTypeHandle);
|
||||
}
|
||||
#else
|
||||
// Compiler needs to expand this. This is not expressible in IL.
|
||||
throw new NotSupportedException();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
[System.Runtime.CompilerServices.DependencyReductionRoot]
|
||||
public static MethodBase GetCurrentMethodNonGeneric(RuntimeMethodHandle methodHandle)
|
||||
{
|
||||
#if CORERT
|
||||
return MethodBase.GetMethodFromHandle(methodHandle);
|
||||
#else
|
||||
#if PROJECTN
|
||||
// The compiler should ideally provide us with a RuntimeMethodHandle for the uninstantiated thing,
|
||||
// but the Project N toolchain cannot express a RuntimeMethodHandle for a generic definition of a generic method.
|
||||
return MethodBase.GetMethodFromHandle(methodHandle).MetadataDefinitionMethod;
|
||||
#else
|
||||
return MethodBase.GetMethodFromHandle(methodHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -52,12 +52,12 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
[System.Runtime.CompilerServices.DependencyReductionRoot]
|
||||
public static MethodBase GetCurrentMethodGeneric(RuntimeMethodHandle methodHandle, RuntimeTypeHandle typeHandle)
|
||||
{
|
||||
#if CORERT
|
||||
return MethodBase.GetMethodFromHandle(methodHandle, typeHandle);
|
||||
#else
|
||||
#if PROJECTN
|
||||
// The compiler should ideally provide us with a RuntimeMethodHandle for the uninstantiated thing,
|
||||
// but the Project N toolchain cannot express a RuntimeMethodHandle for a generic definition of a generic method.
|
||||
return MethodBase.GetMethodFromHandle(methodHandle, typeHandle).MetadataDefinitionMethod;
|
||||
#else
|
||||
return MethodBase.GetMethodFromHandle(methodHandle, typeHandle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,19 +14,7 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
// ProjectN doesn't have access to a convenient always-reflection-enabled type to use.
|
||||
// (We can't use the <Module> type because of IL2IL toolchain limitations.)
|
||||
|
||||
#if CORERT
|
||||
private static RuntimeTypeHandle s_entryAssemblyType;
|
||||
|
||||
internal static void InitializeEntryAssembly(RuntimeTypeHandle entryAssemblyType)
|
||||
{
|
||||
s_entryAssemblyType = entryAssemblyType;
|
||||
}
|
||||
|
||||
internal static Assembly GetEntryAssembly()
|
||||
{
|
||||
return Type.GetTypeFromHandle(s_entryAssemblyType).Assembly;
|
||||
}
|
||||
#else
|
||||
#if PROJECTN
|
||||
private static string s_entryAssemblyName;
|
||||
|
||||
// The only reason why this is public is because the Project N IL2IL toolchain will remove this method
|
||||
|
@ -46,6 +34,18 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
}
|
||||
return null;
|
||||
}
|
||||
#else
|
||||
private static RuntimeTypeHandle s_entryAssemblyType;
|
||||
|
||||
internal static void InitializeEntryAssembly(RuntimeTypeHandle entryAssemblyType)
|
||||
{
|
||||
s_entryAssemblyType = entryAssemblyType;
|
||||
}
|
||||
|
||||
internal static Assembly GetEntryAssembly()
|
||||
{
|
||||
return Type.GetTypeFromHandle(s_entryAssemblyType).Assembly;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -957,7 +957,7 @@ namespace System
|
|||
// correctness as well.
|
||||
private static EqualityComparer<T> GetComparerForReferenceTypesOnly<T>()
|
||||
{
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
// When T is a reference type or a universal canon type, then this will redirect to EqualityComparer<T>.Default.
|
||||
return null;
|
||||
#else
|
||||
|
|
|
@ -21,13 +21,13 @@ namespace System.Collections.Generic
|
|||
[Intrinsic]
|
||||
private static Comparer<T> Create()
|
||||
{
|
||||
#if CORERT
|
||||
// CORERT: TODO: https://github.com/dotnet/corert/issues/763
|
||||
return (_default = new DefaultComparer<T>());
|
||||
#else
|
||||
#if PROJECTN
|
||||
// The compiler will overwrite the Create method with optimized
|
||||
// instantiation-specific implementation.
|
||||
throw new NotSupportedException();
|
||||
#else
|
||||
// CORERT: TODO: https://github.com/dotnet/corert/issues/763
|
||||
return (_default = new DefaultComparer<T>());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,13 @@ namespace System.Collections.Generic
|
|||
[Intrinsic]
|
||||
private static EqualityComparer<T> Create()
|
||||
{
|
||||
#if CORERT
|
||||
// CORERT: TODO: https://github.com/dotnet/corert/issues/763
|
||||
return (_default = new DefaultEqualityComparer<T>());
|
||||
#else
|
||||
#if PROJECTN
|
||||
// The compiler will overwrite the Create method with optimized
|
||||
// instantiation-specific implementation.
|
||||
throw new NotSupportedException();
|
||||
#else
|
||||
// CORERT: TODO: https://github.com/dotnet/corert/issues/763
|
||||
return (_default = new DefaultEqualityComparer<T>());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ namespace System
|
|||
|
||||
// CORERT-TODO: RhpEtwExceptionThrown
|
||||
// https://github.com/dotnet/corert/issues/2457
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
if (isFirstFrame)
|
||||
{
|
||||
string typeName = !outOfMemory ? ex.GetType().ToString() : "System.OutOfMemoryException";
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace System.Runtime.CompilerServices
|
|||
//
|
||||
// No attempt is made to detect or break deadlocks due to other synchronization mechanisms.
|
||||
//==============================================================================================================
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
[RuntimeExport("CheckStaticClassConstruction")]
|
||||
public static unsafe void* CheckStaticClassConstruction(void* returnValue, StaticClassConstructionContext* pContext)
|
||||
{
|
||||
|
|
|
@ -529,7 +529,14 @@ namespace System.Runtime
|
|||
return RhGetModuleSection(ref module, section, out length);
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
#if PROJECTN
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
[RuntimeImport(RuntimeLibrary, "RhGetLoadedOSModules")]
|
||||
internal static extern uint RhGetLoadedOSModules(IntPtr[] resultArray);
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
[RuntimeImport(RuntimeLibrary, "RhGetLoadedModules")]
|
||||
internal static extern uint RhGetLoadedModules(TypeManagerHandle[] resultArray);
|
||||
#else
|
||||
internal static uint RhGetLoadedOSModules(IntPtr[] resultArray)
|
||||
{
|
||||
IntPtr[] loadedModules = Internal.Runtime.CompilerHelpers.StartupCodeHelpers.OSModules;
|
||||
|
@ -549,13 +556,6 @@ namespace System.Runtime
|
|||
}
|
||||
return (uint)loadedModules.Length;
|
||||
}
|
||||
#else
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
[RuntimeImport(RuntimeLibrary, "RhGetLoadedOSModules")]
|
||||
internal static extern uint RhGetLoadedOSModules(IntPtr[] resultArray);
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
[RuntimeImport(RuntimeLibrary, "RhGetLoadedModules")]
|
||||
internal static extern uint RhGetLoadedModules(TypeManagerHandle[] resultArray);
|
||||
#endif
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
|
@ -578,7 +578,7 @@ namespace System.Runtime
|
|||
[RuntimeImport(RuntimeLibrary, "RhGetThreadStaticFieldAddress")]
|
||||
internal static extern unsafe byte* RhGetThreadStaticFieldAddress(EETypePtr pEEType, int threadStaticsBlockOffset, int fieldOffset);
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
[RuntimeImport(RuntimeLibrary, "RhGetThreadStaticStorageForModule")]
|
||||
internal static unsafe extern Array RhGetThreadStaticStorageForModule(Int32 moduleIndex);
|
||||
|
@ -747,7 +747,7 @@ namespace System.Runtime
|
|||
[RuntimeImport(RuntimeLibrary, "RhpEtwExceptionThrown")]
|
||||
internal extern static unsafe void RhpEtwExceptionThrown(char* exceptionTypeName, char* exceptionMessage, IntPtr faultingIP, long hresult);
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
//
|
||||
// Interlocked helpers
|
||||
//
|
||||
|
@ -778,7 +778,7 @@ namespace System.Runtime
|
|||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
[RuntimeImport(RuntimeLibrary, "RhpMemoryBarrier")]
|
||||
internal extern static void MemoryBarrier();
|
||||
#endif // CORERT
|
||||
#endif // !PROJECTN
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
|
|
|
@ -10,223 +10,7 @@ namespace System.Threading
|
|||
{
|
||||
public static class Interlocked
|
||||
{
|
||||
#if CORERT
|
||||
|
||||
#region CompareExchange
|
||||
|
||||
[Intrinsic]
|
||||
public static int CompareExchange(ref int location1, int value, int comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long CompareExchange(ref long location1, long value, long comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static IntPtr CompareExchange(ref IntPtr location1, IntPtr value, IntPtr comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe float CompareExchange(ref float location1, float value, float comparand)
|
||||
{
|
||||
float ret;
|
||||
*(int*)&ret = CompareExchange(ref Unsafe.As<float, int>(ref location1), *(int*)&value, *(int*)&comparand);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe double CompareExchange(ref double location1, double value, double comparand)
|
||||
{
|
||||
double ret;
|
||||
*(long*)&ret = CompareExchange(ref Unsafe.As<double, long>(ref location1), *(long*)&value, *(long*)&comparand);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T CompareExchange<T>(ref T location1, T value, T comparand) where T : class
|
||||
{
|
||||
return Unsafe.As<T>(RuntimeImports.InterlockedCompareExchange(ref Unsafe.As<T, Object>(ref location1), value, comparand));
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static object CompareExchange(ref object location1, object value, object comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Exchange
|
||||
|
||||
[Intrinsic]
|
||||
public static int Exchange(ref int location1, int value)
|
||||
{
|
||||
int oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Exchange(ref long location1, long value)
|
||||
{
|
||||
long oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static IntPtr Exchange(ref IntPtr location1, IntPtr value)
|
||||
{
|
||||
IntPtr oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe float Exchange(ref float location1, float value)
|
||||
{
|
||||
float ret;
|
||||
*(int*)&ret = Exchange(ref Unsafe.As<float, int>(ref location1), *(int*)&value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe double Exchange(ref double location1, double value)
|
||||
{
|
||||
double ret;
|
||||
*(long*)&ret = Exchange(ref Unsafe.As<double, long>(ref location1), *(long*)&value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Exchange<T>(ref T location1, T value) where T : class
|
||||
{
|
||||
return Unsafe.As<T>(RuntimeImports.InterlockedExchange(ref Unsafe.As<T, Object>(ref location1), value));
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static object Exchange(ref object location1, object value)
|
||||
{
|
||||
return RuntimeImports.InterlockedExchange(ref location1, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Increment
|
||||
|
||||
[Intrinsic]
|
||||
public static int Increment(ref int location)
|
||||
{
|
||||
return ExchangeAdd(ref location, 1) + 1;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Increment(ref long location)
|
||||
{
|
||||
return ExchangeAdd(ref location, 1) + 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Decrement
|
||||
|
||||
[Intrinsic]
|
||||
public static int Decrement(ref int location)
|
||||
{
|
||||
return ExchangeAdd(ref location, -1) - 1;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Decrement(ref long location)
|
||||
{
|
||||
return ExchangeAdd(ref location, -1) - 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add
|
||||
|
||||
[Intrinsic]
|
||||
public static int Add(ref int location1, int value)
|
||||
{
|
||||
return ExchangeAdd(ref location1, value) + value;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Add(ref long location1, long value)
|
||||
{
|
||||
return ExchangeAdd(ref location1, value) + value;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int ExchangeAdd(ref int location1, int value)
|
||||
{
|
||||
int oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, oldValue + value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static long ExchangeAdd(ref long location1, long value)
|
||||
{
|
||||
long oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, oldValue + value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MemoryBarrier
|
||||
[Intrinsic]
|
||||
public static void MemoryBarrier()
|
||||
{
|
||||
RuntimeImports.MemoryBarrier();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Read
|
||||
public static long Read(ref long location)
|
||||
{
|
||||
return CompareExchange(ref location, 0, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#else // CORERT
|
||||
#if PROJECTN
|
||||
|
||||
#region CompareExchange
|
||||
|
||||
|
@ -494,7 +278,223 @@ namespace System.Threading
|
|||
}
|
||||
#endregion
|
||||
|
||||
#endif // CORERT
|
||||
#else // PROJECTN
|
||||
|
||||
#region CompareExchange
|
||||
|
||||
[Intrinsic]
|
||||
public static int CompareExchange(ref int location1, int value, int comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long CompareExchange(ref long location1, long value, long comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static IntPtr CompareExchange(ref IntPtr location1, IntPtr value, IntPtr comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe float CompareExchange(ref float location1, float value, float comparand)
|
||||
{
|
||||
float ret;
|
||||
*(int*)&ret = CompareExchange(ref Unsafe.As<float, int>(ref location1), *(int*)&value, *(int*)&comparand);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe double CompareExchange(ref double location1, double value, double comparand)
|
||||
{
|
||||
double ret;
|
||||
*(long*)&ret = CompareExchange(ref Unsafe.As<double, long>(ref location1), *(long*)&value, *(long*)&comparand);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T CompareExchange<T>(ref T location1, T value, T comparand) where T : class
|
||||
{
|
||||
return Unsafe.As<T>(RuntimeImports.InterlockedCompareExchange(ref Unsafe.As<T, Object>(ref location1), value, comparand));
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static object CompareExchange(ref object location1, object value, object comparand)
|
||||
{
|
||||
return RuntimeImports.InterlockedCompareExchange(ref location1, value, comparand);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Exchange
|
||||
|
||||
[Intrinsic]
|
||||
public static int Exchange(ref int location1, int value)
|
||||
{
|
||||
int oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Exchange(ref long location1, long value)
|
||||
{
|
||||
long oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static IntPtr Exchange(ref IntPtr location1, IntPtr value)
|
||||
{
|
||||
IntPtr oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe float Exchange(ref float location1, float value)
|
||||
{
|
||||
float ret;
|
||||
*(int*)&ret = Exchange(ref Unsafe.As<float, int>(ref location1), *(int*)&value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static unsafe double Exchange(ref double location1, double value)
|
||||
{
|
||||
double ret;
|
||||
*(long*)&ret = Exchange(ref Unsafe.As<double, long>(ref location1), *(long*)&value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Exchange<T>(ref T location1, T value) where T : class
|
||||
{
|
||||
return Unsafe.As<T>(RuntimeImports.InterlockedExchange(ref Unsafe.As<T, Object>(ref location1), value));
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static object Exchange(ref object location1, object value)
|
||||
{
|
||||
return RuntimeImports.InterlockedExchange(ref location1, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Increment
|
||||
|
||||
[Intrinsic]
|
||||
public static int Increment(ref int location)
|
||||
{
|
||||
return ExchangeAdd(ref location, 1) + 1;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Increment(ref long location)
|
||||
{
|
||||
return ExchangeAdd(ref location, 1) + 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Decrement
|
||||
|
||||
[Intrinsic]
|
||||
public static int Decrement(ref int location)
|
||||
{
|
||||
return ExchangeAdd(ref location, -1) - 1;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Decrement(ref long location)
|
||||
{
|
||||
return ExchangeAdd(ref location, -1) - 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add
|
||||
|
||||
[Intrinsic]
|
||||
public static int Add(ref int location1, int value)
|
||||
{
|
||||
return ExchangeAdd(ref location1, value) + value;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
public static long Add(ref long location1, long value)
|
||||
{
|
||||
return ExchangeAdd(ref location1, value) + value;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int ExchangeAdd(ref int location1, int value)
|
||||
{
|
||||
int oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, oldValue + value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
[Intrinsic]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static long ExchangeAdd(ref long location1, long value)
|
||||
{
|
||||
long oldValue;
|
||||
|
||||
do
|
||||
{
|
||||
oldValue = location1;
|
||||
} while (CompareExchange(ref location1, oldValue + value, oldValue) != oldValue);
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MemoryBarrier
|
||||
[Intrinsic]
|
||||
public static void MemoryBarrier()
|
||||
{
|
||||
RuntimeImports.MemoryBarrier();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Read
|
||||
public static long Read(ref long location)
|
||||
{
|
||||
return CompareExchange(ref location, 0, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endif // PROJECTN
|
||||
|
||||
public static void MemoryBarrierProcessWide()
|
||||
{
|
||||
|
|
|
@ -60,12 +60,12 @@ namespace System.Threading
|
|||
}
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
private static IntPtr CurrentNativeThreadId => (IntPtr)RuntimeImports.RhCurrentNativeThreadId();
|
||||
#else
|
||||
#if PROJECTN
|
||||
// Use a compiler intrinsic for .NET Native
|
||||
private static IntPtr CurrentNativeThreadId => (IntPtr)Environment.CurrentNativeThreadId;
|
||||
#endif // CORERT
|
||||
#else
|
||||
private static IntPtr CurrentNativeThreadId => (IntPtr)RuntimeImports.RhCurrentNativeThreadId();
|
||||
#endif // PROJECTN
|
||||
|
||||
// On platforms where CurrentNativeThreadId redirects to ManagedThreadId.Current the inlined
|
||||
// version of Lock.Acquire has the ManagedThreadId.Current call not inlined, while the non-inlined
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Internal.Runtime.CompilerHelpers
|
|||
{
|
||||
public static void InitializeLibrary()
|
||||
{
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
__vtable_IUnknown.Initialize();
|
||||
McgModuleManager.Initialize();
|
||||
#endif
|
||||
|
|
|
@ -1109,7 +1109,7 @@ namespace System.Runtime.InteropServices
|
|||
internal static void InitRefCountedHandleCallback()
|
||||
{
|
||||
// TODO: <https://github.com/dotnet/corert/issues/1596>
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
//
|
||||
// Register the callback to ref-counted handles
|
||||
// Inside this callback we'll determine whether the ref count handle to the target object
|
||||
|
@ -1482,7 +1482,7 @@ namespace System.Runtime.InteropServices
|
|||
}
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
// TODO: Dynamic Boxing support
|
||||
// TODO: Optimize--it is possible that the following dynamic code is faster than above static code(CCWTemplate)
|
||||
// if we cann't find a interfaceType for giving guid, try to enumerate all interfaces implemented by this target object to see anyone matchs given guid
|
||||
|
|
|
@ -610,7 +610,7 @@ namespace System.Runtime.InteropServices
|
|||
|
||||
internal static __ComGenericInterfaceDispatcher CreateGenericComDispatcher(RuntimeTypeHandle genericDispatcherDef, RuntimeTypeHandle[] genericArguments, __ComObject comThisPointer)
|
||||
{
|
||||
#if !RHTESTCL && !CORECLR && !CORERT
|
||||
#if !RHTESTCL && PROJECTN
|
||||
Debug.Assert(genericDispatcherDef.IsGenericTypeDefinition());
|
||||
Debug.Assert(genericArguments != null && genericArguments.Length > 0);
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ namespace System.Runtime.InteropServices
|
|||
// We need to call via an imported stub to do a stdcall without triggering GC
|
||||
// We can't use managed calli because the native target address could potentially satisfy a magic
|
||||
// bit check and causing the stub to believe it is a managed method which leads to crash.
|
||||
#if !RHTESTCL && !CORECLR && !CORERT
|
||||
#if !RHTESTCL && PROJECTN
|
||||
[MethodImplAttribute(InternalCall)]
|
||||
#if X86
|
||||
[RuntimeImport("*", "@StdCallCOOP0@8")]
|
||||
|
|
|
@ -1150,10 +1150,10 @@ namespace System.Runtime.InteropServices
|
|||
/// </summary>
|
||||
public static IntPtr GetCurrentCalleeOpenStaticDelegateFunctionPointer()
|
||||
{
|
||||
#if RHTESTCL || CORECLR || CORERT
|
||||
throw new NotSupportedException();
|
||||
#else
|
||||
#if !RHTESTCL && PROJECTN
|
||||
return PInvokeMarshal.GetCurrentCalleeOpenStaticDelegateFunctionPointer();
|
||||
#else
|
||||
throw new NotSupportedException();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1162,10 +1162,10 @@ namespace System.Runtime.InteropServices
|
|||
/// </summary>
|
||||
public static T GetCurrentCalleeDelegate<T>() where T : class // constraint can't be System.Delegate
|
||||
{
|
||||
#if RHTESTCL || CORECLR || CORERT
|
||||
throw new NotSupportedException();
|
||||
#else
|
||||
#if !RHTESTCL && PROJECTN
|
||||
return PInvokeMarshal.GetCurrentCalleeDelegate<T>();
|
||||
#else
|
||||
throw new NotSupportedException();
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -680,7 +680,7 @@ namespace System.Runtime.InteropServices
|
|||
}
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
// Dynamic boxing support
|
||||
// TODO: Consider to use the field boxingStub for all projected reference types.
|
||||
// TODO: now it is only used for boxing "System.Uri".
|
||||
|
|
|
@ -26,7 +26,7 @@ using System.Runtime;
|
|||
using Internal.NativeFormat;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT
|
||||
#if !RHTESTCL && PROJECTN
|
||||
using Internal.Runtime.Augments;
|
||||
using Internal.Runtime.TypeLoader;
|
||||
#endif
|
||||
|
@ -321,7 +321,7 @@ namespace System.Runtime.InteropServices
|
|||
return;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
{
|
||||
name = DynamicInteropTypeHelper.GetTypeName(typeHandle, out isWinRT);
|
||||
|
@ -455,7 +455,7 @@ namespace System.Runtime.InteropServices
|
|||
bool isWinRT;
|
||||
Type type = McgModuleManager.GetTypeFromName(name, out isWinRT);
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT
|
||||
#if !RHTESTCL && PROJECTN
|
||||
if (type == null && McgModuleManager.UseDynamicInterop && nativeTypeKind == (int)TypeKind.Metadata)
|
||||
{
|
||||
type = DynamicInteropTypeHelper.GetTypeFromWinRTName(name, nativeTypeKind);
|
||||
|
@ -894,7 +894,7 @@ namespace System.Runtime.InteropServices
|
|||
return !McgModuleManager.GetInterfaceDataByIndex(moduleIndex, interfaceIndex).DynamicAdapterClassType.IsNull(); ;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop && interfaceType.IsGenericType())
|
||||
return false;
|
||||
#endif
|
||||
|
@ -1102,7 +1102,7 @@ namespace System.Runtime.InteropServices
|
|||
return mcgGenericArgumentMarshalInfo.IteratorType;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
return DynamicInteropTypeHelper.ReplaceOpenGenericTypeInGenericInstantiation(
|
||||
interfaceType,
|
||||
|
@ -1120,7 +1120,7 @@ namespace System.Runtime.InteropServices
|
|||
return mcgGenericArgumentMarshalInfo.ElementClassType;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
{
|
||||
RuntimeTypeHandle[] genericTypeArgumentHandles;
|
||||
|
@ -1141,7 +1141,7 @@ namespace System.Runtime.InteropServices
|
|||
return mcgGenericArgumentMarshalInfo.ElementInterfaceType;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
{
|
||||
RuntimeTypeHandle[] genericTypeArgumentHandles;
|
||||
|
@ -1161,7 +1161,7 @@ namespace System.Runtime.InteropServices
|
|||
return mcgGenericArgumentMarshalInfo.VectorViewType;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
return DynamicInteropTypeHelper.ReplaceOpenGenericTypeInGenericInstantiation(
|
||||
interfaceType,
|
||||
|
@ -1179,7 +1179,7 @@ namespace System.Runtime.InteropServices
|
|||
return mcgGenericArgumentMarshalInfo.AsyncOperationType;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
return DynamicInteropTypeHelper.ReplaceOpenGenericTypeInGenericInstantiation(
|
||||
interfaceType,
|
||||
|
@ -1197,7 +1197,7 @@ namespace System.Runtime.InteropServices
|
|||
return (int)mcgGenericArgumentMarshalInfo.ElementSize;
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
{
|
||||
RuntimeTypeHandle[] genericTypeArgumentHandles;
|
||||
|
@ -1220,7 +1220,7 @@ namespace System.Runtime.InteropServices
|
|||
string ccwRuntimeClassName;
|
||||
if (McgModuleManager.TryGetCCWRuntimeClassName(ccwType, out ccwRuntimeClassName))
|
||||
return ccwRuntimeClassName;
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
return DynamicInteropCCWTemplateHelper.GetCCWRuntimeClassName(ccwType);
|
||||
#endif
|
||||
|
@ -1331,7 +1331,7 @@ namespace System.Runtime.InteropServices
|
|||
}
|
||||
}
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
private static void GetIIDsImpl_dynamic(RuntimeTypeHandle typeHandle, System.Collections.Generic.Internal.List<Guid> iids)
|
||||
{
|
||||
// Enumerate interfaces from itself and its baseclass
|
||||
|
@ -1363,7 +1363,7 @@ namespace System.Runtime.InteropServices
|
|||
}
|
||||
|
||||
// if there isn't any data about this type, just return empty list
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
if (McgModuleManager.UseDynamicInterop)
|
||||
GetIIDsImpl_dynamic(ccwType, iids);
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,7 @@ using System.Runtime;
|
|||
|
||||
using Internal.NativeFormat;
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
using Internal.Runtime.Augments;
|
||||
using Internal.Runtime.TypeLoader;
|
||||
#endif
|
||||
|
@ -72,7 +72,7 @@ namespace System
|
|||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[CLSCompliant(false)]
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
public unsafe class __ComObject : CastableObject, ICastable
|
||||
#else
|
||||
public unsafe class __ComObject : ICastable
|
||||
|
@ -161,7 +161,7 @@ namespace System
|
|||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private RCWFinalizer m_finalizer;
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private static readonly System.Collections.Generic.Dictionary<RuntimeTypeHandle, RuntimeTypeHandle> s_DynamicRCWAdapters =
|
||||
new System.Collections.Generic.Dictionary<RuntimeTypeHandle, RuntimeTypeHandle>();
|
||||
|
@ -333,7 +333,7 @@ namespace System
|
|||
|
||||
static __ComObject()
|
||||
{
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
// Projected types
|
||||
s_DynamicRCWAdapters[typeof(IEnumerable<>).TypeHandle] = typeof(IEnumerable_RCWAdapter<>).TypeHandle;
|
||||
s_DynamicRCWAdapters[typeof(IList<>).TypeHandle] = typeof(IList_RCWAdapter<>).TypeHandle;
|
||||
|
@ -1326,7 +1326,7 @@ namespace System
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT
|
||||
#if !RHTESTCL && PROJECTN
|
||||
|
||||
//
|
||||
// Search the existing cached interfaces in the simple cache that we can cast to the input interface type
|
||||
|
@ -1571,7 +1571,7 @@ namespace System
|
|||
#endregion
|
||||
|
||||
#region CastableObject implementation for weakly typed RCWs
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
object CastToICollectionHelper(RuntimeTypeHandle genericTypeDef, RuntimeTypeHandle[] genericArguments, bool testForIDictionary)
|
||||
{
|
||||
Debug.Assert(genericTypeDef.Equals(typeof(ICollection<>).TypeHandle) || genericTypeDef.Equals(typeof(IReadOnlyCollection<>).TypeHandle));
|
||||
|
@ -1871,7 +1871,7 @@ namespace System
|
|||
//
|
||||
bool hasValidDispatcher = true;
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
hasValidDispatcher = McgModuleManager.UseDynamicInterop && interfaceType.IsGenericType() ?
|
||||
!interfaceType.GetDispatchClassType().IsInvalid() :
|
||||
true;
|
||||
|
@ -2267,7 +2267,7 @@ namespace System
|
|||
if (dynamicAdapter != null)
|
||||
return dynamicAdapter;
|
||||
|
||||
#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT
|
||||
#if !RHTESTCL && PROJECTN && ENABLE_WINRT
|
||||
// Try dynamic rcw, The Caller will generate/throw exception if return null
|
||||
Exception e;
|
||||
dynamicAdapter = CastToInterface(requestedType, /*produceCastErrorException*/ false, out e);
|
||||
|
|
|
@ -1313,7 +1313,12 @@ namespace Internal.Reflection.Execution
|
|||
else
|
||||
{
|
||||
Debug.Assert((fieldAccessMetadata.Flags & FieldTableFlags.IsUniversalCanonicalEntry) == 0);
|
||||
#if CORERT
|
||||
#if PROJECTN
|
||||
// The fieldAccessMetadata.Offset value is not really a field offset, but a static field RVA. We'll use the
|
||||
// field's address as a 'staticsBase', and just use a field offset of zero.
|
||||
fieldOffset = 0;
|
||||
staticsBase = TypeLoaderEnvironment.RvaToNonGenericStaticFieldAddress(fieldAccessMetadata.MappingTableModule, fieldAccessMetadata.Offset);
|
||||
#else
|
||||
if (isGcStatic)
|
||||
{
|
||||
fieldOffset = fieldAccessMetadata.Offset;
|
||||
|
@ -1326,11 +1331,6 @@ namespace Internal.Reflection.Execution
|
|||
fieldOffset = 0;
|
||||
staticsBase = fieldAccessMetadata.Cookie;
|
||||
}
|
||||
#else
|
||||
// The fieldAccessMetadata.Offset value is not really a field offset, but a static field RVA. We'll use the
|
||||
// field's address as a 'staticsBase', and just use a field offset of zero.
|
||||
fieldOffset = 0;
|
||||
staticsBase = TypeLoaderEnvironment.RvaToNonGenericStaticFieldAddress(fieldAccessMetadata.MappingTableModule, fieldAccessMetadata.Offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Internal.Reflection.Execution.FieldAccessors
|
|||
|
||||
unsafe protected sealed override Object GetFieldBypassCctor()
|
||||
{
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
if (IsGcStatic)
|
||||
{
|
||||
// The _staticsBase variable points to a GC handle, which points at the GC statics base of the type.
|
||||
|
@ -30,8 +30,7 @@ namespace Internal.Reflection.Execution.FieldAccessors
|
|||
|
||||
unsafe protected sealed override void UncheckedSetFieldBypassCctor(Object value)
|
||||
{
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
if (IsGcStatic)
|
||||
{
|
||||
// The _staticsBase variable points to a GC handle, which points at the GC statics base of the type.
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Internal.Reflection.Execution.FieldAccessors
|
|||
|
||||
unsafe protected sealed override Object GetFieldBypassCctor()
|
||||
{
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
if (IsGcStatic)
|
||||
{
|
||||
// The _staticsBase variable points to a GC handle, which points at the GC statics base of the type.
|
||||
|
@ -30,8 +30,7 @@ namespace Internal.Reflection.Execution.FieldAccessors
|
|||
|
||||
unsafe protected sealed override void UncheckedSetFieldBypassCctor(Object value)
|
||||
{
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
if (IsGcStatic)
|
||||
{
|
||||
// The _staticsBase variable points to a GC handle, which points at the GC statics base of the type.
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Internal.Reflection.Execution.FieldAccessors
|
|||
|
||||
unsafe protected sealed override Object GetFieldBypassCctor()
|
||||
{
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
if (IsGcStatic)
|
||||
{
|
||||
// The _staticsBase variable points to a GC handle, which points at the GC statics base of the type.
|
||||
|
@ -30,8 +30,7 @@ namespace Internal.Reflection.Execution.FieldAccessors
|
|||
|
||||
unsafe protected sealed override void UncheckedSetFieldBypassCctor(Object value)
|
||||
{
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
if (IsGcStatic)
|
||||
{
|
||||
// The _staticsBase variable points to a GC handle, which points at the GC statics base of the type.
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
#endif
|
||||
private delegate IntPtr RuntimeCacheFuncSignatureDel(IntPtr context, IntPtr callDescIntPtr, object contextObject, out IntPtr auxResult);
|
||||
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
[DllImport("*", ExactSpelling = true, EntryPoint = "ConstrainedCallSupport_GetStubs")]
|
||||
private extern static unsafe void ConstrainedCallSupport_GetStubs(out IntPtr constrainedCallSupport_DerefThisAndCall_CommonCallingStub, out IntPtr constrainedCallSupport_DirectConstrainedCall_CommonCallingStub);
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
static ConstrainedCallSupport()
|
||||
{
|
||||
// TODO: export this unmanaged API in CoreRT
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
ConstrainedCallSupport_GetStubs(out s_constrainedCallSupport_DerefThisAndCall_CommonCallingStub,
|
||||
out s_constrainedCallSupport_DirectConstrainedCall_CommonCallingStub);
|
||||
#else
|
||||
|
|
|
@ -457,7 +457,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
pEEType->OptionalFieldsPtr = (byte*)pEEType + cbEEType;
|
||||
optionalFields.WriteToEEType(pEEType, cbOptionalFieldsSize);
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
pEEType->PointerToTypeManager = PermanentAllocatedMemoryBlobs.GetPointerToIntPtr(moduleInfo.Handle.GetIntPtrUNSAFE());
|
||||
#endif
|
||||
pEEType->DynamicModule = dynamicModulePtr;
|
||||
|
|
|
@ -77,30 +77,23 @@ namespace Internal.Runtime.TypeLoader
|
|||
|
||||
unsafe public uint GetRvaFromIndex(uint index)
|
||||
{
|
||||
#if CORERT
|
||||
// The usage of this API will need to go away since this is not fully portable
|
||||
// and we'll not be able to support this for CppCodegen.
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
#if PROJECTN
|
||||
Debug.Assert(!_moduleHandle.IsNull);
|
||||
|
||||
if (index >= _elementsCount)
|
||||
throw new BadImageFormatException();
|
||||
|
||||
return ((TableElement*)_elements)[index];
|
||||
#else
|
||||
// The usage of this API will need to go away since this is not fully portable
|
||||
// and we'll not be able to support this for CppCodegen.
|
||||
throw new PlatformNotSupportedException();
|
||||
#endif
|
||||
}
|
||||
|
||||
unsafe public IntPtr GetIntPtrFromIndex(uint index)
|
||||
{
|
||||
#if CORERT
|
||||
if (index >= _elementsCount)
|
||||
throw new BadImageFormatException();
|
||||
|
||||
// TODO: indirection through IAT
|
||||
int* pRelPtr32 = &((int*)_elements)[index];
|
||||
return (IntPtr)((byte*)pRelPtr32 + *pRelPtr32);
|
||||
#else
|
||||
#if PROJECTN
|
||||
uint rva = GetRvaFromIndex(index);
|
||||
if ((rva & IndirectionConstants.RVAPointsToIndirection) != 0)
|
||||
{
|
||||
|
@ -111,19 +104,19 @@ namespace Internal.Runtime.TypeLoader
|
|||
{
|
||||
return (IntPtr)(_moduleHandle.ConvertRVAToPointer(rva));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
unsafe public IntPtr GetFunctionPointerFromIndex(uint index)
|
||||
{
|
||||
#if CORERT
|
||||
#else
|
||||
if (index >= _elementsCount)
|
||||
throw new BadImageFormatException();
|
||||
|
||||
// TODO: indirection through IAT
|
||||
int* pRelPtr32 = &((int*)_elements)[index];
|
||||
return (IntPtr)((byte*)pRelPtr32 + *pRelPtr32);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
unsafe public IntPtr GetFunctionPointerFromIndex(uint index)
|
||||
{
|
||||
#if PROJECTN
|
||||
uint rva = GetRvaFromIndex(index);
|
||||
|
||||
if ((rva & DynamicInvokeMapEntry.IsImportMethodFlag) == DynamicInvokeMapEntry.IsImportMethodFlag)
|
||||
|
@ -134,6 +127,13 @@ namespace Internal.Runtime.TypeLoader
|
|||
{
|
||||
return (IntPtr)(_moduleHandle.ConvertRVAToPointer(rva));
|
||||
}
|
||||
#else
|
||||
if (index >= _elementsCount)
|
||||
throw new BadImageFormatException();
|
||||
|
||||
// TODO: indirection through IAT
|
||||
int* pRelPtr32 = &((int*)_elements)[index];
|
||||
return (IntPtr)((byte*)pRelPtr32 + *pRelPtr32);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
return GetIntPtrFromIndex(index);
|
||||
}
|
||||
|
||||
#if CORERT
|
||||
#if !PROJECTN
|
||||
unsafe public IntPtr GetFieldAddressFromIndex(uint index)
|
||||
{
|
||||
if (index >= _elementsCount)
|
||||
|
|
|
@ -505,7 +505,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
// If so, use that, otherwise, run down the template type loader path with the universal template
|
||||
if ((state.TemplateType == null) || isTemplateUniversalCanon)
|
||||
{
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
// CanonAlike types do not get dictionaries
|
||||
if ((state.TemplateType == null) && (type.IsConstructedOverType(type.Context.CanonAlikeTypeArray)))
|
||||
return;
|
||||
|
@ -643,7 +643,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
TypeLoaderLogger.WriteLine("Found BagElementKind.DictionaryLayout");
|
||||
Debug.Assert(!isTemplateUniversalCanon, "Universal template nativelayout do not have DictionaryLayout");
|
||||
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
if (type.IsConstructedOverType(type.Context.CanonAlikeTypeArray))
|
||||
{
|
||||
TypeLoaderLogger.WriteLine("Type is CanonAlike, skip generation of dictionary");
|
||||
|
@ -1682,9 +1682,16 @@ namespace Internal.Runtime.TypeLoader
|
|||
NativeReader reader;
|
||||
uint offset;
|
||||
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
// If the system module is compiled with as a type manager, all modules are compiled as such
|
||||
if (ModuleList.Instance.SystemModule.Handle.IsTypeManager)
|
||||
if (!ModuleList.Instance.SystemModule.Handle.IsTypeManager)
|
||||
{
|
||||
IntPtr moduleHandle = RuntimeAugments.GetOSModuleFromPointer(signature);
|
||||
typeManager = new TypeManagerHandle(moduleHandle);
|
||||
reader = TypeLoaderEnvironment.Instance.GetNativeLayoutInfoReader(typeManager);
|
||||
offset = reader.AddressToOffset(signature);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// The first is a pointer that points to the TypeManager indirection cell.
|
||||
|
@ -1694,15 +1701,6 @@ namespace Internal.Runtime.TypeLoader
|
|||
offset = checked((uint)new IntPtr(lazySignature[1]).ToInt32());
|
||||
reader = TypeLoaderEnvironment.Instance.GetNativeLayoutInfoReader(typeManager);
|
||||
}
|
||||
#if !CORERT
|
||||
else
|
||||
{
|
||||
IntPtr moduleHandle = RuntimeAugments.GetOSModuleFromPointer(signature);
|
||||
typeManager = new TypeManagerHandle(moduleHandle);
|
||||
reader = TypeLoaderEnvironment.Instance.GetNativeLayoutInfoReader(typeManager);
|
||||
offset = reader.AddressToOffset(signature);
|
||||
}
|
||||
#endif
|
||||
|
||||
NativeParser parser = new NativeParser(reader, offset);
|
||||
|
||||
|
|
|
@ -236,14 +236,14 @@ namespace Internal.Runtime.TypeLoader
|
|||
}
|
||||
else
|
||||
{
|
||||
#if CORERT
|
||||
#if PROJECTN
|
||||
fieldOffset = (int)externalReferences.GetRvaFromIndex(entryParser.GetUnsigned());
|
||||
#else
|
||||
fieldOffset = 0;
|
||||
fieldAddressCookie = externalReferences.GetFieldAddressFromIndex(entryParser.GetUnsigned());
|
||||
|
||||
if((entryFlags & FieldTableFlags.IsGcSection) != 0)
|
||||
fieldOffset = (int)entryParser.GetUnsigned();
|
||||
#else
|
||||
fieldOffset = (int)externalReferences.GetRvaFromIndex(entryParser.GetUnsigned());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,9 +256,17 @@ namespace Internal.Runtime.TypeLoader
|
|||
RuntimeFieldHandleInfo* fieldData = *(RuntimeFieldHandleInfo**)&runtimeFieldHandle;
|
||||
RuntimeSignature signature;
|
||||
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
// If the system module is compiled with as a type manager, all modules are compiled as such
|
||||
if (ModuleList.Instance.SystemModule.Handle.IsTypeManager)
|
||||
if (!ModuleList.Instance.SystemModule.Handle.IsTypeManager)
|
||||
{
|
||||
IntPtr moduleHandle = RuntimeAugments.GetOSModuleFromPointer(fieldData->NativeLayoutInfoSignature);
|
||||
|
||||
signature = RuntimeSignature.CreateFromNativeLayoutSignature(
|
||||
new TypeManagerHandle(moduleHandle),
|
||||
GetNativeLayoutInfoReader(new TypeManagerHandle(moduleHandle)).AddressToOffset(fieldData->NativeLayoutInfoSignature));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// The native layout info signature is a pair.
|
||||
|
@ -270,16 +278,6 @@ namespace Internal.Runtime.TypeLoader
|
|||
new TypeManagerHandle(*(IntPtr*)nativeLayoutInfoSignatureData[0]),
|
||||
(uint)nativeLayoutInfoSignatureData[1].ToInt32());
|
||||
}
|
||||
#if !CORERT
|
||||
else
|
||||
{
|
||||
IntPtr moduleHandle = RuntimeAugments.GetOSModuleFromPointer(fieldData->NativeLayoutInfoSignature);
|
||||
|
||||
signature = RuntimeSignature.CreateFromNativeLayoutSignature(
|
||||
new TypeManagerHandle(moduleHandle),
|
||||
GetNativeLayoutInfoReader(new TypeManagerHandle(moduleHandle)).AddressToOffset(fieldData->NativeLayoutInfoSignature));
|
||||
}
|
||||
#endif
|
||||
|
||||
RuntimeSignature remainingSignature;
|
||||
if (!GetTypeFromSignatureAndContext(signature, null, null, out declaringTypeHandle, out remainingSignature))
|
||||
|
@ -425,9 +423,17 @@ namespace Internal.Runtime.TypeLoader
|
|||
|
||||
RuntimeMethodHandleInfo* methodData = *(RuntimeMethodHandleInfo**)&runtimeMethodHandle;
|
||||
RuntimeSignature signature;
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
// If the system module is compiled with as a type manager, all modules are compiled as such
|
||||
if (ModuleList.Instance.SystemModule.Handle.IsTypeManager)
|
||||
if (!ModuleList.Instance.SystemModule.Handle.IsTypeManager)
|
||||
{
|
||||
IntPtr moduleHandle = RuntimeAugments.GetOSModuleFromPointer(methodData->NativeLayoutInfoSignature);
|
||||
|
||||
signature = RuntimeSignature.CreateFromNativeLayoutSignature(
|
||||
new TypeManagerHandle(moduleHandle),
|
||||
GetNativeLayoutInfoReader(new TypeManagerHandle(moduleHandle)).AddressToOffset(methodData->NativeLayoutInfoSignature));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// The native layout info signature is a pair.
|
||||
|
@ -439,16 +445,6 @@ namespace Internal.Runtime.TypeLoader
|
|||
new TypeManagerHandle(*(IntPtr*)nativeLayoutInfoSignatureData[0]),
|
||||
(uint)nativeLayoutInfoSignatureData[1].ToInt32());
|
||||
}
|
||||
#if !CORERT
|
||||
else
|
||||
{
|
||||
IntPtr moduleHandle = RuntimeAugments.GetOSModuleFromPointer(methodData->NativeLayoutInfoSignature);
|
||||
|
||||
signature = RuntimeSignature.CreateFromNativeLayoutSignature(
|
||||
new TypeManagerHandle(moduleHandle),
|
||||
GetNativeLayoutInfoReader(new TypeManagerHandle(moduleHandle)).AddressToOffset(methodData->NativeLayoutInfoSignature));
|
||||
}
|
||||
#endif
|
||||
|
||||
RuntimeSignature remainingSignature;
|
||||
return GetMethodFromSignatureAndContext(signature, null, null, out declaringTypeHandle, out nameAndSignature, out genericMethodArgs, out remainingSignature);
|
||||
|
|
|
@ -847,14 +847,14 @@ namespace Internal.Runtime.TypeLoader
|
|||
// done at runtime. When working with the CoreRT ABI, the correct slot numbers will be written to the map,
|
||||
// and no adjustments will be performed at runtime.
|
||||
//
|
||||
|
||||
#if CORERT
|
||||
|
||||
#if PROJECTN
|
||||
CanonicallyEquivalentEntryLocator canonHelper = new CanonicallyEquivalentEntryLocator(
|
||||
methodHandleDeclaringType,
|
||||
Instance.GetTypeDefinition(methodHandleDeclaringType),
|
||||
CanonicalFormKind.Specific);
|
||||
#else
|
||||
CanonicallyEquivalentEntryLocator canonHelper = new CanonicallyEquivalentEntryLocator(
|
||||
Instance.GetTypeDefinition(methodHandleDeclaringType),
|
||||
methodHandleDeclaringType,
|
||||
CanonicalFormKind.Specific);
|
||||
#endif
|
||||
|
||||
|
@ -931,7 +931,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
{
|
||||
uint slot = entryParser.GetUnsigned();
|
||||
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
RuntimeTypeHandle searchForSharedGenericTypesInParentHierarchy = declaringTypeOfVirtualInvoke;
|
||||
while (!searchForSharedGenericTypesInParentHierarchy.IsNull())
|
||||
{
|
||||
|
|
|
@ -756,7 +756,7 @@ namespace Internal.Runtime.TypeLoader
|
|||
|
||||
bool methodRequestedIsCanonical = Method.IsCanonicalMethod(CanonicalFormKind.Specific);
|
||||
MethodDesc canonAlikeForm;
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
if (methodRequestedIsCanonical)
|
||||
{
|
||||
canonAlikeForm = Method.ReplaceTypesInConstructionOfMethod(Method.Context.CanonTypeArray, Method.Context.CanonAlikeTypeArray);
|
||||
|
|
|
@ -647,7 +647,7 @@ namespace Internal.TypeSystem
|
|||
_typesToFlushTypeSystemStateFrom = null;
|
||||
}
|
||||
|
||||
#if !CORERT
|
||||
#if PROJECTN
|
||||
private TypeDesc _canonAlikeType;
|
||||
|
||||
public TypeDesc CanonAlikeType
|
||||
|
|
Загрузка…
Ссылка в новой задаче