Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Bootstrap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extern "C" bool RhRegisterOSModule(void * pModule,
void * pvUnboxingStubsStartRange, uint32_t cbUnboxingStubsRange,
void ** pClasslibFunctions, uint32_t nClasslibFunctions);

extern "C" void* PalGetModuleHandleFromPointer(void* pointer);
void* PalGetModuleHandleFromPointer(void* pointer);

#if defined(HOST_X86) && defined(HOST_WINDOWS)
#define STRINGIFY(s) #s
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/nativeaot/Runtime.Base/src/RhBaseName.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ internal static class InternalCalls
// internalcalls for System.GC.
//

private const string RuntimeLibrary = "*";

// Force a garbage collection.
[RuntimeExport("RhCollect")]
internal static void RhCollect(int generation, InternalGCCollectionMode mode, bool lowMemoryP = false)
{
RhpCollect(generation, mode, lowMemoryP ? Interop.BOOL.TRUE : Interop.BOOL.FALSE);
}

[DllImport(Redhawk.BaseName)]
[DllImport(RuntimeLibrary)]
private static extern void RhpCollect(int generation, InternalGCCollectionMode mode, Interop.BOOL lowMemoryP);

[RuntimeExport("RhGetGcTotalMemory")]
Expand All @@ -74,7 +76,7 @@ internal static long RhGetGcTotalMemory()
return RhpGetGcTotalMemory();
}

[DllImport(Redhawk.BaseName)]
[DllImport(RuntimeLibrary)]
private static extern long RhpGetGcTotalMemory();

[RuntimeExport("RhStartNoGCRegion")]
Expand All @@ -94,7 +96,7 @@ internal static int RhEndNoGCRegion()
//

// Fetch next object which needs finalization or return null if we've reached the end of the list.
[RuntimeImport(Redhawk.BaseName, "RhpGetNextFinalizableObject")]
[RuntimeImport(RuntimeLibrary, "RhpGetNextFinalizableObject")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern object RhpGetNextFinalizableObject();

Expand All @@ -103,167 +105,167 @@ internal static int RhEndNoGCRegion()
//

// Allocate handle.
[RuntimeImport(Redhawk.BaseName, "RhpHandleAlloc")]
[RuntimeImport(RuntimeLibrary, "RhpHandleAlloc")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern IntPtr RhpHandleAlloc(object value, GCHandleType type);

[RuntimeImport(Redhawk.BaseName, "RhHandleGet")]
[RuntimeImport(RuntimeLibrary, "RhHandleGet")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern object RhHandleGet(IntPtr handle);

[RuntimeImport(Redhawk.BaseName, "RhHandleSet")]
[RuntimeImport(RuntimeLibrary, "RhHandleSet")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern IntPtr RhHandleSet(IntPtr handle, object value);

//
// internal calls for allocation
//
[RuntimeImport(Redhawk.BaseName, "RhpNewFast")]
[RuntimeImport(RuntimeLibrary, "RhpNewFast")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe object RhpNewFast(MethodTable* pEEType); // BEWARE: not for finalizable objects!

[RuntimeImport(Redhawk.BaseName, "RhpNewFinalizable")]
[RuntimeImport(RuntimeLibrary, "RhpNewFinalizable")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe object RhpNewFinalizable(MethodTable* pEEType);

[RuntimeImport(Redhawk.BaseName, "RhpNewArray")]
[RuntimeImport(RuntimeLibrary, "RhpNewArray")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe object RhpNewArray(MethodTable* pEEType, int length);

#if FEATURE_64BIT_ALIGNMENT
[RuntimeImport(Redhawk.BaseName, "RhpNewFastAlign8")]
[RuntimeImport(RuntimeLibrary, "RhpNewFastAlign8")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe object RhpNewFastAlign8(MethodTable * pEEType); // BEWARE: not for finalizable objects!

[RuntimeImport(Redhawk.BaseName, "RhpNewFinalizableAlign8")]
[RuntimeImport(RuntimeLibrary, "RhpNewFinalizableAlign8")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe object RhpNewFinalizableAlign8(MethodTable* pEEType);

[RuntimeImport(Redhawk.BaseName, "RhpNewArrayAlign8")]
[RuntimeImport(RuntimeLibrary, "RhpNewArrayAlign8")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe object RhpNewArrayAlign8(MethodTable* pEEType, int length);

[RuntimeImport(Redhawk.BaseName, "RhpNewFastMisalign")]
[RuntimeImport(RuntimeLibrary, "RhpNewFastMisalign")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe object RhpNewFastMisalign(MethodTable * pEEType);
#endif // FEATURE_64BIT_ALIGNMENT

[RuntimeImport(Redhawk.BaseName, "RhpAssignRef")]
[RuntimeImport(RuntimeLibrary, "RhpAssignRef")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void RhpAssignRef(ref object? address, object? obj);

[MethodImplAttribute(MethodImplOptions.InternalCall)]
[RuntimeImport(Redhawk.BaseName, "RhpGcSafeZeroMemory")]
[RuntimeImport(RuntimeLibrary, "RhpGcSafeZeroMemory")]
internal static extern unsafe ref byte RhpGcSafeZeroMemory(ref byte dmem, nuint size);

[MethodImplAttribute(MethodImplOptions.InternalCall)]
[RuntimeImport(Redhawk.BaseName, "RhBulkMoveWithWriteBarrier")]
[RuntimeImport(RuntimeLibrary, "RhBulkMoveWithWriteBarrier")]
internal static extern unsafe void RhBulkMoveWithWriteBarrier(ref byte dmem, ref byte smem, nuint size);

#if FEATURE_GC_STRESS
//
// internal calls for GC stress
//
[RuntimeImport(Redhawk.BaseName, "RhpInitializeGcStress")]
[RuntimeImport(RuntimeLibrary, "RhpInitializeGcStress")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void RhpInitializeGcStress();
#endif // FEATURE_GC_STRESS

[RuntimeImport(Redhawk.BaseName, "RhpEHEnumInitFromStackFrameIterator")]
[RuntimeImport(RuntimeLibrary, "RhpEHEnumInitFromStackFrameIterator")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpEHEnumInitFromStackFrameIterator(ref StackFrameIterator pFrameIter, out EH.MethodRegionInfo pMethodRegionInfo, void* pEHEnum);

[RuntimeImport(Redhawk.BaseName, "RhpEHEnumNext")]
[RuntimeImport(RuntimeLibrary, "RhpEHEnumNext")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpEHEnumNext(void* pEHEnum, void* pEHClause);

[RuntimeImport(Redhawk.BaseName, "RhpGetDispatchCellInfo")]
[RuntimeImport(RuntimeLibrary, "RhpGetDispatchCellInfo")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void RhpGetDispatchCellInfo(IntPtr pCell, out DispatchCellInfo newCellInfo);

[RuntimeImport(Redhawk.BaseName, "RhpSearchDispatchCellCache")]
[RuntimeImport(RuntimeLibrary, "RhpSearchDispatchCellCache")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe IntPtr RhpSearchDispatchCellCache(IntPtr pCell, MethodTable* pInstanceType);

[RuntimeImport(Redhawk.BaseName, "RhpUpdateDispatchCellCache")]
[RuntimeImport(RuntimeLibrary, "RhpUpdateDispatchCellCache")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe IntPtr RhpUpdateDispatchCellCache(IntPtr pCell, IntPtr pTargetCode, MethodTable* pInstanceType, ref DispatchCellInfo newCellInfo);

[RuntimeImport(Redhawk.BaseName, "RhpGetClasslibFunctionFromCodeAddress")]
[RuntimeImport(RuntimeLibrary, "RhpGetClasslibFunctionFromCodeAddress")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void* RhpGetClasslibFunctionFromCodeAddress(IntPtr address, ClassLibFunctionId id);

[RuntimeImport(Redhawk.BaseName, "RhpGetClasslibFunctionFromEEType")]
[RuntimeImport(RuntimeLibrary, "RhpGetClasslibFunctionFromEEType")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void* RhpGetClasslibFunctionFromEEType(MethodTable* pEEType, ClassLibFunctionId id);

//
// StackFrameIterator
//

[RuntimeImport(Redhawk.BaseName, "RhpSfiInit")]
[RuntimeImport(RuntimeLibrary, "RhpSfiInit")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpSfiInit(ref StackFrameIterator pThis, void* pStackwalkCtx, bool instructionFault, bool* fIsExceptionIntercepted);

[RuntimeImport(Redhawk.BaseName, "RhpSfiNext")]
[RuntimeImport(RuntimeLibrary, "RhpSfiNext")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpSfiNext(ref StackFrameIterator pThis, uint* uExCollideClauseIdx, bool* fUnwoundReversePInvoke, bool* fIsExceptionIntercepted);

//
// Miscellaneous helpers.
//

[RuntimeImport(Redhawk.BaseName, "RhpCallCatchFunclet")]
[RuntimeImport(RuntimeLibrary, "RhpCallCatchFunclet")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe IntPtr RhpCallCatchFunclet(
object exceptionObj, byte* pHandlerIP, void* pvRegDisplay, ref EH.ExInfo exInfo);

[RuntimeImport(Redhawk.BaseName, "RhpCallFinallyFunclet")]
[RuntimeImport(RuntimeLibrary, "RhpCallFinallyFunclet")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void RhpCallFinallyFunclet(byte* pHandlerIP, void* pvRegDisplay);

[RuntimeImport(Redhawk.BaseName, "RhpCallFilterFunclet")]
[RuntimeImport(RuntimeLibrary, "RhpCallFilterFunclet")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpCallFilterFunclet(
object exceptionObj, byte* pFilterIP, void* pvRegDisplay);

#if FEATURE_OBJCMARSHAL
[RuntimeImport(Redhawk.BaseName, "RhpCallPropagateExceptionCallback")]
[RuntimeImport(RuntimeLibrary, "RhpCallPropagateExceptionCallback")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe IntPtr RhpCallPropagateExceptionCallback(
IntPtr callbackContext, IntPtr callback, void* pvRegDisplay, ref EH.ExInfo exInfo, IntPtr pPreviousTransitionFrame);
#endif // FEATURE_OBJCMARSHAL

[RuntimeImport(Redhawk.BaseName, "RhpFallbackFailFast")]
[RuntimeImport(RuntimeLibrary, "RhpFallbackFailFast")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void RhpFallbackFailFast();

[RuntimeImport(Redhawk.BaseName, "RhpSetThreadDoNotTriggerGC")]
[RuntimeImport(RuntimeLibrary, "RhpSetThreadDoNotTriggerGC")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void RhpSetThreadDoNotTriggerGC();

[System.Diagnostics.Conditional("DEBUG")]
[RuntimeImport(Redhawk.BaseName, "RhpValidateExInfoStack")]
[RuntimeImport(RuntimeLibrary, "RhpValidateExInfoStack")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void RhpValidateExInfoStack();

#if TARGET_WINDOWS
[RuntimeImport(Redhawk.BaseName, "RhpFirstChanceExceptionNotification")]
[RuntimeImport(RuntimeLibrary, "RhpFirstChanceExceptionNotification")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void RhpFirstChanceExceptionNotification();
#endif

#if TARGET_WINDOWS
[RuntimeImport(Redhawk.BaseName, "RhpCopyContextFromExInfo")]
[RuntimeImport(RuntimeLibrary, "RhpCopyContextFromExInfo")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe void RhpCopyContextFromExInfo(void* pOSContext, int cbOSContext, EH.PAL_LIMITED_CONTEXT* pPalContext);
#endif

[RuntimeImport(Redhawk.BaseName, "RhpGetThreadAbortException")]
[RuntimeImport(RuntimeLibrary, "RhpGetThreadAbortException")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern Exception RhpGetThreadAbortException();

[RuntimeImport(Redhawk.BaseName, "RhCurrentNativeThreadId")]
[RuntimeImport(RuntimeLibrary, "RhCurrentNativeThreadId")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe IntPtr RhCurrentNativeThreadId();

Expand All @@ -279,21 +281,21 @@ internal static extern unsafe IntPtr RhpCallPropagateExceptionCallback(

// Block the current thread until at least one object needs to be finalized (returns true) or
// memory is low (returns false and the finalizer thread should initiate a garbage collection).
[DllImport(Redhawk.BaseName)]
[DllImport(RuntimeLibrary)]
internal static extern uint RhpWaitForFinalizerRequest();

// Indicate that the current round of finalizations is complete.
[DllImport(Redhawk.BaseName)]
[DllImport(RuntimeLibrary)]
internal static extern void RhpSignalFinalizationComplete(uint fCount, int observedFullGcCount);

// Enters a no GC region, possibly doing a blocking GC if there is not enough
// memory available to satisfy the caller's request.
[DllImport(Redhawk.BaseName)]
[DllImport(RuntimeLibrary)]
internal static extern int RhpStartNoGCRegion(long totalSize, Interop.BOOL hasLohSize, long lohSize, Interop.BOOL disallowFullBlockingGC);

// Exits a no GC region, possibly doing a GC to clean up the garbage that
// the caller allocated.
[DllImport(Redhawk.BaseName)]
[DllImport(RuntimeLibrary)]
internal static extern int RhpEndNoGCRegion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public static unsafe int RhGetCurrentThreadStackTrace(IntPtr[] outputBuffer)
}

#pragma warning disable SYSLIB1054 // Use DllImport here instead of LibraryImport because this file is used by Test.CoreLib.
[DllImport(Redhawk.BaseName)]
[DllImport("*")]
private static extern unsafe int RhpGetCurrentThreadStackTrace(IntPtr* pOutputBuffer, uint outputBufferLength, UIntPtr addressInCurrentFrame);
#pragma warning restore SYSLIB1054

Expand Down
Loading
Loading