diff --git a/src/coreclr/vm/comsynchronizable.cpp b/src/coreclr/vm/comsynchronizable.cpp index e98f7ec66de23a..952e38989d8fbc 100644 --- a/src/coreclr/vm/comsynchronizable.cpp +++ b/src/coreclr/vm/comsynchronizable.cpp @@ -474,20 +474,6 @@ extern "C" INT32 QCALLTYPE ThreadNative_GetApartmentState(QCall::ObjectHandleOnS retVal = thread->GetApartment(); -#ifdef FEATURE_COMINTEROP - if (retVal == Thread::AS_Unknown) - { - // If the CLR hasn't started COM yet, start it up and attempt the call again. - // We do this in order to minimize the number of situations under which we return - // ApartmentState.Unknown to our callers. - if (!g_fComStarted) - { - EnsureComStarted(); - retVal = thread->GetApartment(); - } - } -#endif // FEATURE_COMINTEROP - END_QCALL; return retVal; } diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 283a2e045dd1c3..9bf757b3ba0750 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -3326,7 +3326,7 @@ BOOL PInvoke::MarshalingRequired( // We enable the runtime marshalling system whenever it is enabled on the module as a whole // or when the call is a COM interop call. COM interop calls are already using a significant portion of the runtime // marshalling system just to function at all, so we aren't going to disable the parameter marshalling; - // we'd rather have developers use the feature flag to diable the whole COM interop subsystem at once. + // we'd rather have developers use the feature flag to disable the whole COM interop subsystem at once. bool runtimeMarshallingEnabled = pModule->IsRuntimeMarshallingEnabled(); #ifdef FEATURE_COMINTEROP runtimeMarshallingEnabled |= pMD && pMD->IsCLRToCOMCall(); diff --git a/src/coreclr/vm/finalizerthread.cpp b/src/coreclr/vm/finalizerthread.cpp index e7f6b88b3bc37f..e10889c9f5542d 100644 --- a/src/coreclr/vm/finalizerthread.cpp +++ b/src/coreclr/vm/finalizerthread.cpp @@ -131,13 +131,6 @@ static void DoExtraWorkForFinalizer(Thread* finalizerThread) } CONTRACTL_END; -#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT - if (finalizerThread->RequiresCoInitialize()) - { - finalizerThread->SetApartment(Thread::AS_InMTA); - } -#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT - if (finalizerThread->RequireSyncBlockCleanup()) { SyncBlockCache::GetSyncBlockCache()->CleanupSyncBlocks(); diff --git a/src/coreclr/vm/interoputil.cpp b/src/coreclr/vm/interoputil.cpp index 79b7d73749ab67..a8f58ead1b3603 100644 --- a/src/coreclr/vm/interoputil.cpp +++ b/src/coreclr/vm/interoputil.cpp @@ -1372,14 +1372,13 @@ HRESULT LoadRegTypeLib(_In_ REFGUID guid, return hr; } -VOID EnsureComStarted(BOOL fCoInitCurrentThread) +VOID EnsureComStarted() { CONTRACTL { THROWS; GC_TRIGGERS; MODE_ANY; - PRECONDITION(GetThreadNULLOk() || !fCoInitCurrentThread); PRECONDITION(g_fEEStarted); } CONTRACTL_END; @@ -1388,7 +1387,7 @@ VOID EnsureComStarted(BOOL fCoInitCurrentThread) _ASSERTE(g_fComStarted); } -HRESULT EnsureComStartedNoThrow(BOOL fCoInitCurrentThread) +HRESULT EnsureComStartedNoThrow() { CONTRACTL { @@ -1396,7 +1395,6 @@ HRESULT EnsureComStartedNoThrow(BOOL fCoInitCurrentThread) GC_TRIGGERS; MODE_ANY; PRECONDITION(g_fEEStarted); - PRECONDITION(GetThreadNULLOk() != NULL); // Should always be inside BEGIN_EXTERNAL_ENTRYPOINT } CONTRACTL_END; diff --git a/src/coreclr/vm/interoputil.h b/src/coreclr/vm/interoputil.h index 89026337b1cdd6..a3446e2b2b58e1 100644 --- a/src/coreclr/vm/interoputil.h +++ b/src/coreclr/vm/interoputil.h @@ -357,8 +357,8 @@ VOID LogRCWDestroy(RCW* pWrap); //-------------------------------------------------------------------------------- // Ensure COM is started up. -HRESULT EnsureComStartedNoThrow(BOOL fCoInitCurrentThread = TRUE); -VOID EnsureComStarted(BOOL fCoInitCurrentThread = TRUE); +HRESULT EnsureComStartedNoThrow(); +VOID EnsureComStarted(); IUnknown* MarshalObjectToInterface(OBJECTREF* ppObject, MethodTable* pItfMT, MethodTable* pClassMT, DWORD dwFlags); void UnmarshalObjectFromInterface(OBJECTREF *ppObjectDest, IUnknown **ppUnkSrc, MethodTable *pItfMT, MethodTable *pClassMT, DWORD dwFlags); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index dc809ea7cd339f..5dd96ab78c80de 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -406,13 +406,6 @@ CorInfoType CEEInfo::asCorInfoType(CorElementType eeType, RETURN res; } - -inline static CorInfoType toJitType(TypeHandle typeHnd, CORINFO_CLASS_HANDLE *clsRet = NULL) -{ - WRAPPER_NO_CONTRACT; - return CEEInfo::asCorInfoType(typeHnd.GetInternalCorElementType(), typeHnd, clsRet); -} - enum ConvToJitSigFlags : int { CONV_TO_JITSIG_FLAGS_NONE = 0x0, @@ -2580,7 +2573,7 @@ CorInfoType CEEInfo::asCorInfoType (CORINFO_CLASS_HANDLE clsHnd) JIT_TO_EE_TRANSITION(); TypeHandle VMClsHnd(clsHnd); - result = toJitType(VMClsHnd); + result = asCorInfoType(VMClsHnd.GetInternalCorElementType(), VMClsHnd); EE_TO_JIT_TRANSITION(); diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 8bdb740663485e..7070a5a3054a2c 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -5035,7 +5035,7 @@ MethodTableBuilder::ValidateMethods() } } - // Make sure that fcalls have a 0 rva. This is assumed by the prejit fixup logic + // Make sure that fcalls have a 0 rva. if (it.MethodType() == mcFCall && it.RVA() != 0) { BuildMethodTableThrowException(BFA_ECALLS_MUST_HAVE_ZERO_RVA, it.Token()); diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 659f8c7b751119..3321bce80ba281 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -972,6 +972,8 @@ DWORD GetRuntimeId() DWORD_PTR Thread::OBJREF_HASH = OBJREF_TABSIZE; #endif +#ifndef FEATURE_PORTABLE_HELPERS + extern "C" void STDCALL JIT_PatchedCodeStart(); extern "C" void STDCALL JIT_PatchedCodeLast(); @@ -1024,6 +1026,20 @@ extern "C" void *JIT_WriteBarrier_Table_Loc; void *JIT_WriteBarrier_Table_Loc = 0; #endif // TARGET_ARM64 || TARGET_LOONGARCH64 || TARGET_RISCV64 +#else // FEATURE_PORTABLE_HELPERS + +BOOL IsIPInWriteBarrierCodeCopy(PCODE controlPc) +{ + return FALSE; +} + +PCODE AdjustWriteBarrierIP(PCODE controlPc) +{ + UNREACHABLE(); +} + +#endif // FEATURE_PORTABLE_HELPERS + #ifndef TARGET_UNIX // g_TlsIndex is only used by the DAC. Disable optimizations around it to prevent it from getting optimized out. #pragma optimize("", off) @@ -4625,9 +4641,6 @@ Thread::ApartmentState Thread::SetApartment(ApartmentState state) // This method can be called on current thread only _ASSERTE(m_OSThreadId == ::GetCurrentThreadId()); - // Reset any bits that request for CoInitialize - ResetRequiresCoInitialize(); - // Setting the state to AS_Unknown indicates we should CoUninitialize // the thread. if (state == AS_Unknown) @@ -4788,10 +4801,6 @@ Thread::ApartmentState Thread::SetApartment(ApartmentState state) } } - // Since we've just called CoInitialize, COM has effectively been started up. - // To ensure the CLR is aware of this, we need to call EnsureComStarted. - EnsureComStarted(FALSE); - return GetApartment(); } diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index f55dc631957d98..ea982e831f0251 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -592,9 +592,6 @@ class Thread enum ThreadTasks { TT_CleanupSyncBlock = 0x00000001, // The synch block needs to be cleaned up. -#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT - TT_CallCoInitialize = 0x00000002, // CoInitialize needs to be called. -#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT }; // Thread flags that have no concurrency issues (i.e., they are only manipulated by the owning thread). Use these @@ -759,7 +756,6 @@ class Thread { LIMITED_METHOD_CONTRACT; InterlockedOr((LONG*)&m_State, TS_CoInitialized); - InterlockedAnd((LONG*)&m_ThreadTasks, ~TT_CallCoInitialize); } void ResetCoInitialized() @@ -782,24 +778,6 @@ class Thread } #endif // FEATURE_COMINTEROP - DWORD RequiresCoInitialize() - { - LIMITED_METHOD_CONTRACT; - return (m_ThreadTasks & TT_CallCoInitialize); - } - - void SetRequiresCoInitialize() - { - LIMITED_METHOD_CONTRACT; - InterlockedOr((LONG*)&m_ThreadTasks, TT_CallCoInitialize); - } - - void ResetRequiresCoInitialize() - { - LIMITED_METHOD_CONTRACT; - InterlockedAnd((LONG*)&m_ThreadTasks,~TT_CallCoInitialize); - } - void CleanupCOMState(); #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT diff --git a/src/coreclr/vm/wasm/helpers.cpp b/src/coreclr/vm/wasm/helpers.cpp index e64c7a45e9b56b..33674350e955db 100644 --- a/src/coreclr/vm/wasm/helpers.cpp +++ b/src/coreclr/vm/wasm/helpers.cpp @@ -85,16 +85,6 @@ extern "C" void STDCALL FixupPrecodeCode_End() PORTABILITY_ASSERT("FixupPrecodeCode_End is not implemented on wasm"); } -extern "C" void STDCALL JIT_PatchedCodeLast() -{ - PORTABILITY_ASSERT("JIT_PatchedCodeLast is not implemented on wasm"); -} - -extern "C" void STDCALL JIT_PatchedCodeStart() -{ - PORTABILITY_ASSERT("JIT_PatchedCodeStart is not implemented on wasm"); -} - extern "C" void RhpInitialInterfaceDispatch() { PORTABILITY_ASSERT("RhpInitialInterfaceDispatch is not implemented on wasm"); diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 5d11e46a12f0c1..75ee5a8a27d37a 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -72,7 +72,7 @@ public static partial class PlatformDetection public static bool IsX64Process => RuntimeInformation.ProcessArchitecture == Architecture.X64; public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86; public static bool IsNotX86Process => !IsX86Process; - public static bool IsArgIteratorSupported => IsMonoRuntime || (IsWindows && IsNotArmProcess && !IsNativeAot); + public static bool IsArgIteratorSupported => IsMonoRuntime || (IsWindows && !IsNativeAot); public static bool IsArgIteratorNotSupported => !IsArgIteratorSupported; public static bool Is32BitProcess => IntPtr.Size == 4; public static bool Is64BitProcess => IntPtr.Size == 8; diff --git a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs index a272e40c33db39..065c19d3626247 100644 --- a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs +++ b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs @@ -4,8 +4,6 @@ // Changes to this file must follow the https://aka.ms/api-review process. // ------------------------------------------------------------------------------ -using System.Diagnostics.CodeAnalysis; - namespace System.Reflection.Metadata { public static partial class AssemblyExtensions @@ -13,32 +11,32 @@ public static partial class AssemblyExtensions [System.CLSCompliantAttribute(false)] public unsafe static bool TryGetRawMetadata(this System.Reflection.Assembly assembly, out byte* blob, out int length) { throw null; } } + [System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=true)] + public sealed partial class MetadataUpdateHandlerAttribute : System.Attribute + { + public MetadataUpdateHandlerAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] System.Type handlerType) { } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] + public System.Type HandlerType { get { throw null; } } + } public static partial class MetadataUpdater { - public static void ApplyUpdate(Assembly assembly, ReadOnlySpan metadataDelta, ReadOnlySpan ilDelta, ReadOnlySpan pdbDelta) { throw null; } [System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute("System.Reflection.Metadata.MetadataUpdater.IsSupported")] public static bool IsSupported { get { throw null; } } - } - [System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class MetadataUpdateHandlerAttribute : System.Attribute - { - public MetadataUpdateHandlerAttribute([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] System.Type handlerType) { } - [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicMethods)] - public System.Type HandlerType { get { throw null; } } + public static void ApplyUpdate(System.Reflection.Assembly assembly, System.ReadOnlySpan metadataDelta, System.ReadOnlySpan ilDelta, System.ReadOnlySpan pdbDelta) { } } } namespace System.Runtime.CompilerServices { - [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple = false)] - public sealed class CreateNewOnMetadataUpdateAttribute : System.Attribute + [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=false)] + public sealed partial class CreateNewOnMetadataUpdateAttribute : System.Attribute { + public CreateNewOnMetadataUpdateAttribute() { } } - [AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, - AllowMultiple=false, Inherited=false)] - public class MetadataUpdateOriginalTypeAttribute : Attribute + [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=false, Inherited=false)] + public partial class MetadataUpdateOriginalTypeAttribute : System.Attribute { - public MetadataUpdateOriginalTypeAttribute(Type originalType) { throw null; } - public Type OriginalType { get { throw null; } } + public MetadataUpdateOriginalTypeAttribute(System.Type originalType) { } + public System.Type OriginalType { get { throw null; } } } } namespace System.Runtime.Loader