diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 3aa5e6ca80d10..3df685e240b8e 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -4140,7 +4140,7 @@ class CObjectHeader : public Object _ASSERTE(IsStructAligned((uint8_t *)this, GetMethodTable()->GetBaseAlignment())); #endif // FEATURE_STRUCTALIGN -#ifdef FEATURE_64BIT_ALIGNMENT +#if defined(FEATURE_64BIT_ALIGNMENT) && !defined(FEATURE_REDHAWK) if (pMT->RequiresAlign8()) { _ASSERTE((((size_t)this) & 0x7) == (pMT->IsValueType() ? 4U : 0U)); diff --git a/src/coreclr/gc/gcdesc.h b/src/coreclr/gc/gcdesc.h index 5b557bd315f85..9b461a701a686 100644 --- a/src/coreclr/gc/gcdesc.h +++ b/src/coreclr/gc/gcdesc.h @@ -223,10 +223,12 @@ class CGCDesc } } +#ifndef FEATURE_REDHAWK if (pMT->Collectible()) { NumOfPointers += 1; } +#endif return NumOfPointers; } diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index ecef15208124c..ba50e349badf2 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -194,6 +194,24 @@ enum membarrier_cmd MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = (1 << 6) }; +bool CanFlushUsingMembarrier() +{ + // Starting with Linux kernel 4.14, process memory barriers can be generated + // using MEMBARRIER_CMD_PRIVATE_EXPEDITED. + + int mask = membarrier(MEMBARRIER_CMD_QUERY, 0); + + if (mask >= 0 && + mask & MEMBARRIER_CMD_PRIVATE_EXPEDITED && + // Register intent to use the private expedited command. + membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0) == 0) + { + return true; + } + + return false; +} + // // Tracks if the OS supports FlushProcessWriteBuffers using membarrier // @@ -354,13 +372,7 @@ bool GCToOSInterface::Initialize() assert(s_flushUsingMemBarrier == 0); - // Starting with Linux kernel 4.14, process memory barriers can be generated - // using MEMBARRIER_CMD_PRIVATE_EXPEDITED. - int mask = membarrier(MEMBARRIER_CMD_QUERY, 0); - if (mask >= 0 && - mask & MEMBARRIER_CMD_PRIVATE_EXPEDITED && - // Register intent to use the private expedited command. - membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0) == 0) + if (CanFlushUsingMembarrier()) { s_flushUsingMemBarrier = TRUE; } diff --git a/src/coreclr/inc/cvconst.h b/src/coreclr/inc/cvconst.h index 3a0e3b98d92d7..3fbbfdd011a2c 100644 --- a/src/coreclr/inc/cvconst.h +++ b/src/coreclr/inc/cvconst.h @@ -1580,10 +1580,12 @@ typedef enum CV_HREG_e { CV_ARM64_LR = 80, CV_ARM64_SP = 81, CV_ARM64_ZR = 82, + CV_ARM64_PC = 83, - // statue register + // status registers CV_ARM64_NZCV = 90, + CV_ARM64_CPSR = 91, // 32-bit floating point registers diff --git a/src/coreclr/tools/Common/Compiler/SingleMethodRootProvider.cs b/src/coreclr/tools/Common/Compiler/SingleMethodRootProvider.cs index bd2061428f9f9..afd542d7e1fe2 100644 --- a/src/coreclr/tools/Common/Compiler/SingleMethodRootProvider.cs +++ b/src/coreclr/tools/Common/Compiler/SingleMethodRootProvider.cs @@ -19,7 +19,11 @@ public SingleMethodRootProvider(MethodDesc method) public void AddCompilationRoots(IRootingServiceProvider rootProvider) { - rootProvider.AddCompilationRoot(_method, rootMinimalDependencies: false, reason: "Single method root"); + rootProvider.AddCompilationRoot(_method, +#if READYTORUN + rootMinimalDependencies: false, +#endif + reason: "Single method root"); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs index 7b21c989ec76c..1b067af21b476 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs @@ -271,17 +271,9 @@ private static bool CanCastParamTo(this ParameterizedType thisType, TypeDesc par else if (fromParamUnderlyingType.IsPrimitive) { TypeDesc toParamUnderlyingType = paramType.UnderlyingType; - if (toParamUnderlyingType.IsPrimitive) + if (GetNormalizedIntegralArrayElementType(fromParamUnderlyingType) == GetNormalizedIntegralArrayElementType(toParamUnderlyingType)) { - if (toParamUnderlyingType == fromParamUnderlyingType) - { - return true; - } - - if (ArePrimitveTypesEquivalentSize(fromParamUnderlyingType, toParamUnderlyingType)) - { - return true; - } + return true; } } @@ -289,59 +281,48 @@ private static bool CanCastParamTo(this ParameterizedType thisType, TypeDesc par return false; } - // Returns true of the two types are equivalent primitive types. Used by array casts. - private static bool ArePrimitveTypesEquivalentSize(TypeDesc type1, TypeDesc type2) + private static TypeFlags GetNormalizedIntegralArrayElementType(TypeDesc type) { - Debug.Assert(type1.IsPrimitive && type2.IsPrimitive); + Debug.Assert(!type.IsEnum); // Primitive types such as E_T_I4 and E_T_U4 are interchangeable // Enums with interchangeable underlying types are interchangable // BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2 // Float and double are not interchangable here. - int sourcePrimitiveTypeEquivalenceSize = type1.GetIntegralTypeMatchSize(); - - // Quick check to see if the first type can be matched. - if (sourcePrimitiveTypeEquivalenceSize == 0) + TypeFlags elementType = type.Category; + switch (elementType) { - return false; + case TypeFlags.Byte: + case TypeFlags.UInt16: + case TypeFlags.UInt32: + case TypeFlags.UInt64: + case TypeFlags.UIntPtr: + return elementType - 1; } - int targetPrimitiveTypeEquivalenceSize = type2.GetIntegralTypeMatchSize(); - - return sourcePrimitiveTypeEquivalenceSize == targetPrimitiveTypeEquivalenceSize; + return elementType; } - private static int GetIntegralTypeMatchSize(this TypeDesc type) - { - Debug.Assert(type.IsPrimitive); - switch (type.Category) + public static bool IsArrayElementTypeCastableBySize(TypeDesc elementType) + { + switch (elementType.UnderlyingType.Category) { - case TypeFlags.SByte: case TypeFlags.Byte: - return 1; + case TypeFlags.SByte: case TypeFlags.UInt16: case TypeFlags.Int16: - return 2; - case TypeFlags.Int32: case TypeFlags.UInt32: - return 4; - case TypeFlags.Int64: + case TypeFlags.Int32: case TypeFlags.UInt64: - return 8; - case TypeFlags.IntPtr: + case TypeFlags.Int64: case TypeFlags.UIntPtr: - return type.Context.Target.PointerSize; - default: - return 0; + case TypeFlags.IntPtr: + return true; } - } - public static bool IsArrayElementTypeCastableBySize(TypeDesc elementType) - { - TypeDesc underlyingType = elementType.UnderlyingType; - return underlyingType.IsPrimitive && GetIntegralTypeMatchSize(underlyingType) != 0; + return false; } private static bool CanCastToClassOrInterface(this TypeDesc thisType, TypeDesc otherType, StackOverflowProtect protect) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs index a92cca2669999..3e73dcfd82117 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.FieldLayout.cs @@ -12,7 +12,7 @@ public abstract partial class DefType : TypeDesc /// /// Bit flags for layout /// - private class FieldLayoutFlags + private static class FieldLayoutFlags { /// /// True if ContainsGCPointers has been computed diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/CastingTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/CastingTests.cs index 06e87dc17be26..f6cd2e187d46c 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/CastingTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/CastingTests.cs @@ -79,7 +79,7 @@ public void TestSameSizeArrayTypeCasting() Assert.True(byteType.MakeArrayType().CanCastTo(sbyteType.MakeArrayType())); Assert.False(byteType.CanCastTo(sbyteType)); - Assert.True(intPtrType.MakeArrayType().CanCastTo(ulongType.MakeArrayType())); + Assert.False(intPtrType.MakeArrayType().CanCastTo(ulongType.MakeArrayType())); Assert.False(intPtrType.CanCastTo(ulongType)); // These are same size, but not allowed to cast diff --git a/src/coreclr/vm/gcinfodecoder.cpp b/src/coreclr/vm/gcinfodecoder.cpp index 52c2c3c649c0d..8ca20eaca743f 100644 --- a/src/coreclr/vm/gcinfodecoder.cpp +++ b/src/coreclr/vm/gcinfodecoder.cpp @@ -1508,7 +1508,7 @@ OBJECTREF* GcInfoDecoder::GetRegisterSlot( } -#ifdef TARGET_UNIX +#if defined(TARGET_UNIX) && !defined(FEATURE_REDHAWK) OBJECTREF* GcInfoDecoder::GetCapturedRegister( int regNum, PREGDISPLAY pRD @@ -1524,7 +1524,7 @@ OBJECTREF* GcInfoDecoder::GetCapturedRegister( return (OBJECTREF*)(pR0 + regNum); } -#endif // TARGET_UNIX +#endif // TARGET_UNIX && !FEATURE_REDHAWK bool GcInfoDecoder::IsScratchRegister(int regNum, PREGDISPLAY pRD) @@ -1598,6 +1598,11 @@ OBJECTREF* GcInfoDecoder::GetRegisterSlot( _ASSERTE(regNum >= 0 && regNum <= 30); _ASSERTE(regNum != 18); // TEB +#ifdef FEATURE_REDHAWK + PTR_UIntNative* ppReg = &pRD->pX0; + + return (OBJECTREF*)*(ppReg + regNum); +#else DWORD64 **ppReg; if(regNum <= 17) @@ -1617,6 +1622,7 @@ OBJECTREF* GcInfoDecoder::GetRegisterSlot( ppReg = &pRD->pCurrentContextPointers->X19; return (OBJECTREF*)*(ppReg + regNum-19); +#endif } bool GcInfoDecoder::IsScratchRegister(int regNum, PREGDISPLAY pRD) @@ -1658,7 +1664,7 @@ void GcInfoDecoder::ReportRegisterToGC( // ARM64 LOG((LF_GCROOTS, LL_INFO1000, "Reporting " FMT_REG, regNum )); OBJECTREF* pObjRef = GetRegisterSlot( regNum, pRD ); -#if defined(TARGET_UNIX) && !defined(SOS_TARGET_ARM64) +#if defined(TARGET_UNIX) && !defined(FEATURE_REDHAWK) && !defined(SOS_TARGET_AMD64) // On PAL, we don't always have the context pointers available due to // a limitation of an unwinding library. In such case, the context // pointers for some nonvolatile registers are NULL. @@ -1700,7 +1706,7 @@ void GcInfoDecoder::ReportRegisterToGC( // ARM64 pCallBack(hCallBack, pObjRef, gcFlags DAC_ARG(DacSlotLocation(regNum, 0, false))); } -#ifdef TARGET_UNIX +#if defined(TARGET_UNIX) && !defined(FEATURE_REDHAWK) OBJECTREF* GcInfoDecoder::GetCapturedRegister( int regNum, PREGDISPLAY pRD @@ -1725,7 +1731,7 @@ OBJECTREF* GcInfoDecoder::GetCapturedRegister( return (OBJECTREF*)(pX0 + regNum); } -#endif // TARGET_UNIX +#endif // TARGET_UNIX && !FEATURE_REDHAWK #else // Unknown platform diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 21e32141e9363..c3231e6f7ec09 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -65,6 +65,7 @@ + @@ -1210,7 +1211,7 @@ - + @@ -1246,7 +1247,7 @@ - + @@ -1905,7 +1906,6 @@ - @@ -1978,7 +1978,6 @@ - diff --git a/src/libraries/System.Private.CoreLib/src/System/Attribute.cs b/src/libraries/System.Private.CoreLib/src/System/Attribute.cs index 27ff2091d82b4..2bc115b9f686d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Attribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Attribute.cs @@ -14,7 +14,6 @@ public abstract partial class Attribute { protected Attribute() { } -#if !CORERT [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", Justification = "Unused fields don't make a difference for equality")] public override bool Equals([NotNullWhen(true)] object? obj) @@ -83,7 +82,6 @@ public override int GetHashCode() return type.GetHashCode(); } -#endif // Compares values of custom-attribute fields. private static bool AreFieldValuesEqual(object? thisValue, object? thatValue) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.cs index f7de902164f11..bc5901403874c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - namespace System.Diagnostics.Tracing { /// @@ -27,6 +23,7 @@ internal sealed partial class NativeRuntimeEventSource : EventSource // as you can't make a constructor partial. private NativeRuntimeEventSource(int _) { } +#if FEATURE_PERFTRACING /// /// Dispatch a single event with the specified event ID and payload. /// @@ -62,5 +59,6 @@ internal unsafe void ProcessEvent(uint eventID, uint osThreadID, DateTime timeSt childActivityID: &childActivityId, args: decodedPayloadFields); } +#endif // FEATURE_PERFTRACING } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index 2eef2d0b532e6..81c87972f7842 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -635,7 +635,9 @@ public static void PtrToStructure(IntPtr ptr, [DisallowNull] T structure) case HResults.COR_E_EXCEPTION: return new System.Exception(); case HResults.COR_E_EXECUTIONENGINE: +#pragma warning disable CS0618 // ExecutionEngineException is obsolete return new System.ExecutionEngineException(); +#pragma warning restore CS0618 case HResults.COR_E_FIELDACCESS: return new System.FieldAccessException(); case HResults.COR_E_FILELOAD: @@ -1097,7 +1099,7 @@ public static Delegate GetDelegateForFunctionPointer(IntPtr ptr, Type t) throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t)); } - // For backward compatibility, we allow lookup up of existing delegate to + // For backward compatibility, we allow lookup of existing delegate to // function pointer mappings using abstract MulticastDelegate type. We will check // for the non-abstract delegate type later if no existing mapping is found. if (t.BaseType != typeof(MulticastDelegate) && t != typeof(MulticastDelegate))