Skip to content

Commit

Permalink
Merge branch 'NativeAOT' into smoketest
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky committed Sep 7, 2020
2 parents ead11fc + e5b23b4 commit c9f9109
Show file tree
Hide file tree
Showing 47 changed files with 430 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ The .NET Foundation licenses this file to you under the MIT license.
</ItemGroup>

<ItemGroup>
<NativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/libSystem.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/libSystem.Globalization.Native$(NativeLibraryExtension)" />
<NativeLibrary Include="$(IlcPath)/framework/libSystem.IO.Compression.Native$(NativeLibraryExtension)" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ internal extern static unsafe bool RhpCallFilterFunclet(
internal static extern void RhpReleaseCastCacheLock();

[DllImport(Redhawk.BaseName, CallingConvention = CallingConvention.Cdecl)]
internal extern static long PalGetTickCount64();
internal extern static ulong PalGetTickCount64();

[DllImport(Redhawk.BaseName, CallingConvention = CallingConvention.Cdecl)]
internal static extern void RhpAcquireThunkPoolLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ private static class CastCache
//
private static Entry[] s_cache = new Entry[InitialCacheSize]; // Initialize the cache eagerly to avoid null checks.
private static UnsafeGCHandle s_previousCache;
private static long s_tickCountOfLastOverflow = InternalCalls.PalGetTickCount64();
private static ulong s_tickCountOfLastOverflow = InternalCalls.PalGetTickCount64();
private static int s_entries;
private static bool s_roundRobinFlushing;

Expand Down Expand Up @@ -1161,7 +1161,7 @@ private static Entry[] ResizeCacheForNewEntryAsNecessary()
s_entries = 0;

// See how long it has been since the last time the cache was overflowing
long tickCount = InternalCalls.PalGetTickCount64();
ulong tickCount = InternalCalls.PalGetTickCount64();
int tickCountSinceLastOverflow = (int)(tickCount - s_tickCountOfLastOverflow);
s_tickCountOfLastOverflow = tickCount;

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/nativeaot/Runtime/GcStressControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GcStressControl
if (g_pRhConfig->GetGcStressSeed())
s_lGcStressRNGSeed = g_pRhConfig->GetGcStressSeed();
else
s_lGcStressRNGSeed = PalGetTickCount();
s_lGcStressRNGSeed = (UInt32)PalGetTickCount64();

if (g_pRhConfig->GetGcStressFreqDenom())
s_lGcStressFreqDenom = g_pRhConfig->GetGcStressFreqDenom();
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/src/nativeaot/Runtime/PalRedhawk.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ REDHAWK_PALIMPORT UInt32_BOOL REDHAWK_PALAPI PalVirtualProtect(_In_ void* pAddre
REDHAWK_PALIMPORT void REDHAWK_PALAPI PalSleep(UInt32 milliseconds);
REDHAWK_PALIMPORT UInt32_BOOL REDHAWK_PALAPI PalSwitchToThread();
REDHAWK_PALIMPORT HANDLE REDHAWK_PALAPI PalCreateEventW(_In_opt_ LPSECURITY_ATTRIBUTES pEventAttributes, UInt32_BOOL manualReset, UInt32_BOOL initialState, _In_opt_z_ LPCWSTR pName);
REDHAWK_PALIMPORT UInt32 REDHAWK_PALAPI PalGetTickCount();
REDHAWK_PALIMPORT HANDLE REDHAWK_PALAPI PalCreateFileW(_In_z_ LPCWSTR pFileName, uint32_t desiredAccess, uint32_t shareMode, _In_opt_ void* pSecurityAttributes, uint32_t creationDisposition, uint32_t flagsAndAttributes, HANDLE hTemplateFile);
REDHAWK_PALIMPORT HANDLE REDHAWK_PALAPI PalCreateLowMemoryNotification();
REDHAWK_PALIMPORT void REDHAWK_PALAPI PalTerminateCurrentProcess(UInt32 exitCode);
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/src/nativeaot/Runtime/unix/PalRedhawkUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,6 @@ REDHAWK_PALEXPORT UInt64 REDHAWK_PALAPI PalGetTickCount64()
return retval;
}

REDHAWK_PALEXPORT UInt32 REDHAWK_PALAPI PalGetTickCount()
{
return (UInt32)PalGetTickCount64();
}

REDHAWK_PALEXPORT HANDLE REDHAWK_PALAPI PalGetModuleHandleFromPointer(_In_ void* pointer)
{
HANDLE moduleHandle = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,6 @@ REDHAWK_PALEXPORT bool REDHAWK_PALAPI PalStartFinalizerThread(_In_ BackgroundCal
return PalStartBackgroundWork(callback, pCallbackContext, TRUE) != NULL;
}

REDHAWK_PALEXPORT UInt32 REDHAWK_PALAPI PalGetTickCount()
{
#pragma warning(push)
#pragma warning(disable: 28159) // Consider GetTickCount64 instead
return GetTickCount();
#pragma warning(pop)
}

REDHAWK_PALEXPORT bool REDHAWK_PALAPI PalEventEnabled(REGHANDLE regHandle, _In_ const EVENT_DESCRIPTOR* eventDescriptor)
{
return !!EventEnabled(regHandle, eventDescriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,42 +365,38 @@
<Compile Include="src\System\Threading\WaitSubsystem.ThreadWaitInfo.Unix.cs" />
<Compile Include="src\System\Threading\WaitSubsystem.Unix.cs" />
<Compile Include="src\System\Threading\WaitSubsystem.WaitableObject.Unix.cs" />
<Compile Include="src\Interop\Unix\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.Abort.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.Abort.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Abort.cs">
<Link>Interop\Unix\System.Native\Interop.Abort.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.Exit.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.Exit.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Exit.cs">
<Link>Interop\Unix\System.Native\Interop.Exit.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.GetEnv.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.GetEnv.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetEnv.cs">
<Link>Interop\Unix\System.Native\Interop.GetEnv.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.GetExecutableAbsolutePath.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.GetExecutableAbsolutePath.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetExecutableAbsolutePath.cs">
<Link>Interop\Unix\System.Native\Interop.GetExecutableAbsolutePath.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.MemAllocFree.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.MemAllocFree.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.MemAllocFree.cs">
<Link>Interop\Unix\System.Native\Interop.MemAllocFree.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.MemReAlloc.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.MemReAlloc.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.MemReAlloc.cs">
<Link>Interop\Unix\System.Native\Interop.MemReAlloc.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.GetTickCount64.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.GetTickCount64.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.SchedGetCpu.cs">
<Link>Interop\Unix\System.Native\Interop.SchedGetCpu.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.SchedGetCpu.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.SchedGetCpu.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.DynamicLoad.cs">
<Link>Interop\Unix\System.Native\Interop.DynamicLoad.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.DynamicLoad.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.DynamicLoad.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Threading.cs">
<Link>Interop\Unix\System.Native\Interop.Threading.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.Threading.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.Threading.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.ErrNo.cs">
<Link>Interop\Unix\System.Native\Interop.ErrNo.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.ErrNo.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.ErrNo.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Private.CoreLib.Native\Interop.GetEnviron.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.GetEnviron.cs</Link>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetEnviron.cs">
<Link>Interop\Unix\System.Native\Interop.GetEnviron.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -437,9 +433,6 @@
<Compile Include="$(AotCommonPath)\System\Runtime\InteropServices\McgIntrinsicsAttribute.cs">
<Link>System\Runtime\InteropServices\McgIntrinsicsAttribute.cs</Link>
</Compile>
<Compile Include="$(AotCommonPath)\System\Runtime\InteropServices\McgGeneratedNativeCallCodeAttribute.cs">
<Link>System\Runtime\InteropServices\McgGeneratedNativeCallCodeAttribute.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\NotImplemented.cs">
<Link>System\NotImplemented.cs</Link>
</Compile>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Runtime;
using System.Text;
using System.Threading;

Expand Down Expand Up @@ -148,6 +149,6 @@ unsafe bool ParseEntry(IntPtr current, out string key, out string value)
[DoesNotReturn]
private static void ExitRaw() => Interop.Sys.Exit(s_latchedExitCode);

public static long TickCount64 => (long)Interop.Sys.GetTickCount64();
public static long TickCount64 => (long)RuntimeImports.PalGetTickCount64();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public static class RuntimeImports
{
private const string RuntimeLibrary = "[MRT]";

[DllImport(RuntimeLibrary, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
[SuppressGCTransition]
internal static extern ulong PalGetTickCount64();

[MethodImpl(MethodImplOptions.InternalCall)]
[RuntimeImport(RuntimeLibrary, "RhpSendCustomEventToDebugger")]
internal static extern void RhpSendCustomEventToDebugger(IntPtr payload, int length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,7 @@ public override MethodIL GetMethodIL(MethodDesc method)
return result;
}

// TODO: Remove: Workaround for missing ClearInitLocals transforms in CoreRT CoreLib
bool clearInitLocals = ecmaMethod.Module == ecmaMethod.Context.SystemModule;

MethodIL methodIL = EcmaMethodIL.Create(ecmaMethod, clearInitLocals);
MethodIL methodIL = EcmaMethodIL.Create(ecmaMethod);
if (methodIL != null)
return methodIL;

Expand Down
13 changes: 4 additions & 9 deletions src/coreclr/src/tools/Common/TypeSystem/IL/EcmaMethodIL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@ public sealed partial class EcmaMethodIL : MethodIL
private LocalVariableDefinition[] _locals;
private ILExceptionRegion[] _ilExceptionRegions;

// TODO: Remove: Workaround for missing ClearInitLocals transforms in CoreRT CoreLib
private readonly bool _clearInitLocals;

public static EcmaMethodIL Create(EcmaMethod method, bool clearInitLocals = false)
public static EcmaMethodIL Create(EcmaMethod method)
{
var rva = method.MetadataReader.GetMethodDefinition(method.Handle).RelativeVirtualAddress;
if (rva == 0)
return null;
return new EcmaMethodIL(method, rva, clearInitLocals);
return new EcmaMethodIL(method, rva);
}

private EcmaMethodIL(EcmaMethod method, int rva, bool clearInitLocals)
private EcmaMethodIL(EcmaMethod method, int rva)
{
_method = method;
_module = method.Module;
_methodBody = _module.PEReader.GetMethodBody(rva);

_clearInitLocals = clearInitLocals;
}

public EcmaModule Module
Expand Down Expand Up @@ -71,7 +66,7 @@ public override bool IsInitLocals
{
get
{
return !_clearInitLocals && _methodBody.LocalVariablesInitialized;
return _methodBody.LocalVariablesInitialized;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static partial class Interop
internal unsafe partial class Sys
{
[DoesNotReturn]
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_Abort")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Abort")]
internal static extern void Abort();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_LoadLibrary")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_LoadLibrary")]
internal static extern IntPtr LoadLibrary(string filename);

[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_GetProcAddress")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetProcAddress")]
internal static extern IntPtr GetProcAddress(IntPtr handle, byte* symbol);

[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_GetProcAddress")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetProcAddress")]
internal static extern IntPtr GetProcAddress(IntPtr handle, string symbol);

[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_FreeLibrary")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_FreeLibrary")]
internal static extern void FreeLibrary(IntPtr handle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_GetErrNo")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetErrNo")]
[SuppressGCTransition]
internal static extern int GetErrNo();

[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_ClearErrNo")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_ClearErrNo")]
[SuppressGCTransition]
internal static extern void ClearErrNo();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static partial class Interop
internal unsafe partial class Sys
{
[DoesNotReturn]
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_Exit")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Exit")]
internal static extern void Exit(int exitCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_GetEnv")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetEnv")]
internal static extern unsafe IntPtr GetEnv(string name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_GetEnviron")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetEnviron")]
internal static extern unsafe IntPtr GetEnviron();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_GetExecutableAbsolutePath", SetLastError = true)]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetExecutableAbsolutePath", SetLastError = true)]
internal static extern unsafe int GetExecutableAbsolutePath([Out] char[] buffer, int bufferSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_MemAlloc")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_MemAlloc")]
internal static extern IntPtr MemAlloc(UIntPtr sizeInBytes);

[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_MemFree")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_MemFree")]
internal static extern void MemFree(IntPtr ptr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_MemReAlloc")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_MemReAlloc")]
internal static extern IntPtr MemReAlloc(IntPtr ptr, UIntPtr newSize);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_SchedGetCpu")]
[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_SchedGetCpu")]
internal static extern int SchedGetCpu();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal unsafe partial class Sys
{
internal delegate IntPtr ThreadProc(IntPtr parameter);

[DllImport(Libraries.CoreLibNative, EntryPoint = "CoreLibNative_RuntimeThread_CreateThread")]
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RuntimeThread_CreateThread")]
internal static extern bool RuntimeThread_CreateThread(IntPtr stackSize, IntPtr startAddress, IntPtr parameter);
}
}

This file was deleted.

Loading

0 comments on commit c9f9109

Please sign in to comment.