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

Commit

Permalink
Merge pull request #4918 from dotnet/nmirror
Browse files Browse the repository at this point in the history
Merge nmirror to master
  • Loading branch information
jkotas authored Nov 12, 2017
2 parents 2c25bb9 + 4e49c95 commit 7246a7a
Show file tree
Hide file tree
Showing 61 changed files with 443 additions and 460 deletions.
2 changes: 1 addition & 1 deletion dir.props
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
</Choose>

<!-- Set up various other constants -->
<PropertyGroup Condition="'$(IsProjectNLibrary)' != 'true'">
<PropertyGroup>
<DefineConstants>CORERT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsWindows)'=='true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static unsafe void InitializeGlobalTablesForModule(TypeManagerHandle typ
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)
Expand Down Expand Up @@ -141,7 +141,7 @@ private static unsafe void RunEagerClassConstructors(IntPtr cctorTableStart, int
}
}

#if CORERT
#if !PROJECTN
private static unsafe void InitializeStatics(IntPtr gcStaticRegionStart, int length)
{
IntPtr gcStaticRegionEnd = (IntPtr)((byte*)gcStaticRegionStart + length);
Expand Down Expand Up @@ -172,7 +172,7 @@ private static unsafe void InitializeStatics(IntPtr gcStaticRegionStart, int len
}
}
}
#endif // CORERT
#endif // !PROJECTN
}

[StructLayout(LayoutKind.Sequential)]
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/Internal/Runtime/EEType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ internal IntPtr PointerToTypeManager
}
}
#endif
#endif // CORERT
#endif // EETYPE_TYPE_MANAGER

internal unsafe EETypeRareFlags RareFlags
{
Expand Down
8 changes: 4 additions & 4 deletions src/Common/src/Internal/Runtime/TypeManagerHandle.RVA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public unsafe IntPtr OsModuleBase
[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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public UtcDictionaryLayoutNode(TypeSystemEntity owningMethodOrType) : base(ownin

}

#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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool IsTypeExplicitlyDisabledInner(DefType type, out string outputTypeName)
/// </summary>
string GetAppExeDirectory()
{
#if !CORERT
#if PROJECTN
var process = Process.GetCurrentProcess();
string fullPath = process.MainModule.FileName;
return Path.GetDirectoryName(fullPath);
Expand All @@ -137,10 +137,7 @@ string GetAppExeDirectory()
/// </summary>
void LoadExceptionFile(string exceptionFileName)
{
#if CORERT
Debug.Assert(false);
return;
#else
#if PROJECTN
if (!File.Exists(exceptionFileName))
return;

Expand Down
8 changes: 4 additions & 4 deletions src/Native/Runtime/EHHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -373,6 +370,9 @@ static bool InWriteBarrierHelper(UIntNative faultingIP)
(UIntNative)&RhpCopyMultibyteWithWriteBarrierSrcAVLocation,
(UIntNative)&RhpCopyAnyWithWriteBarrierDestAVLocation,
(UIntNative)&RhpCopyAnyWithWriteBarrierSrcAVLocation,
#else
(UIntNative)&RhpLockCmpXchg32AVLocation,
(UIntNative)&RhpLockCmpXchg64AVLocation,
#endif
};

Expand Down
6 changes: 3 additions & 3 deletions src/Native/Runtime/MathHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions src/Native/Runtime/MiscHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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))
Expand All @@ -268,7 +268,7 @@ COOP_PINVOKE_HELPER(Boolean, RhFindBlob, (TypeManagerHandle *pTypeManagerHandle,

return pBlob != NULL;
}
#if !CORERT
#if PROJECTN
else
{
HANDLE hOsModule = typeManagerHandle.AsOsModule();
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Native/Runtime/RuntimeInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Native/Runtime/TypeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ HANDLE TypeManager::GetOsModuleHandle()

bool TypeManagerHandle::IsTypeManager()
{
#if !CORERT
#if PROJECTN
if (((uintptr_t)_value & 1) == 0)
return false;
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/Native/Runtime/amd64/ExceptionHandling.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/Native/Runtime/inc/rhbinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_
Expand All @@ -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_
Expand Down
4 changes: 2 additions & 2 deletions src/Native/Runtime/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -167,7 +167,7 @@ void DetectCPUFeatures()
g_fHasFastFxsave = true;
#endif

#endif // !CORERT
#endif // PROJECTN
}

#ifdef PROFILE_STARTUP
Expand Down
12 changes: 6 additions & 6 deletions src/Native/Runtime/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++)
Expand All @@ -392,7 +392,7 @@ void Thread::Destroy()
}
delete[] m_pThreadLocalModuleStatics;
}
#endif // CORERT
#endif // !PROJECTN

RedhawkGCInterface::ReleaseAllocContext(GetAllocContext());

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/Native/Runtime/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -261,10 +261,10 @@ class Thread : private ThreadBuffer
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
Expand Down
Loading

0 comments on commit 7246a7a

Please sign in to comment.