diff --git a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs index bb8036686d83e6..7c51a6094c0833 100644 --- a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs +++ b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs @@ -3,9 +3,11 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.Versioning; namespace Internal.Runtime.InteropServices { + [UnsupportedOSPlatform("browser")] internal static class ComActivator { /// diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index 03655015fe1e50..e7b548ce1bf075 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -860,10 +860,12 @@ DEFINE_CLASS(CALLCONV_SUPPRESSGCTRANSITION, CompilerServices, CallConvSup DEFINE_CLASS(CALLCONV_MEMBERFUNCTION, CompilerServices, CallConvMemberFunction) DEFINE_CLASS(CALLCONV_SWIFT, CompilerServices, CallConvSwift) +#if !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_CLASS(SWIFT_SELF, Swift, SwiftSelf) DEFINE_CLASS(SWIFT_SELF_T, Swift, SwiftSelf`1) DEFINE_CLASS(SWIFT_ERROR, Swift, SwiftError) DEFINE_CLASS(SWIFT_INDIRECT_RESULT, Swift, SwiftIndirectResult) +#endif // !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_CLASS(SAFE_HANDLE, Interop, SafeHandle) DEFINE_FIELD(SAFE_HANDLE, HANDLE, handle) @@ -1177,7 +1179,9 @@ DEFINE_METHOD(HANDLE_MARSHALER, CONVERT_SAFEHANDLE_TO_NATIVE,ConvertSaf DEFINE_METHOD(HANDLE_MARSHALER, THROW_SAFEHANDLE_FIELD_CHANGED, ThrowSafeHandleFieldChanged, SM_RetVoid) DEFINE_METHOD(HANDLE_MARSHALER, THROW_CRITICALHANDLE_FIELD_CHANGED, ThrowCriticalHandleFieldChanged, SM_RetVoid) +#if !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_CLASS(COMVARIANT, Marshalling, ComVariant) +#endif // !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_CLASS(SZARRAYHELPER, System, SZArrayHelper) // Note: The order of methods here has to match order they are implemented on the interfaces in diff --git a/src/coreclr/vm/rexcep.h b/src/coreclr/vm/rexcep.h index 05983f4edaf2f2..59d277a81bb567 100644 --- a/src/coreclr/vm/rexcep.h +++ b/src/coreclr/vm/rexcep.h @@ -172,7 +172,9 @@ DEFINE_EXCEPTION(g_SystemNS, InvalidCastException, false, C DEFINE_EXCEPTION(g_InteropNS, InvalidComObjectException, false, COR_E_INVALIDCOMOBJECT) #endif //FEATURE_COMINTEROP DEFINE_EXCEPTION(g_ReflectionNS, InvalidFilterCriteriaException, false, COR_E_INVALIDFILTERCRITERIA) +#if !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_EXCEPTION(g_InteropNS, InvalidOleVariantTypeException, false, COR_E_INVALIDOLEVARIANTTYPE) +#endif // !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_EXCEPTION(g_SystemNS, InvalidOperationException, false, COR_E_INVALIDOPERATION) @@ -180,7 +182,9 @@ DEFINE_EXCEPTION(g_SystemNS, InvalidProgramException, false, C DEFINE_EXCEPTION(g_IONS, IOException, false, COR_E_IO, CTL_E_DEVICEIOERROR, STD_CTL_SCODE(31036), STD_CTL_SCODE(31037)) +#if !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_EXCEPTION(g_InteropNS, MarshalDirectiveException, false, COR_E_MARSHALDIRECTIVE) +#endif // !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_EXCEPTION(g_SystemNS, MethodAccessException, false, COR_E_METHODACCESS, META_E_CA_FRIENDS_SN_REQUIRED) DEFINE_EXCEPTION(g_SystemNS, MemberAccessException, false, COR_E_MEMBERACCESS) DEFINE_EXCEPTION(g_SystemNS, MissingFieldException, false, COR_E_MISSINGFIELD) @@ -258,9 +262,13 @@ DEFINE_EXCEPTION(g_SystemNS, UnauthorizedAccessException, true, C DEFINE_EXCEPTION(g_SecurityNS, VerificationException, false, COR_E_VERIFICATION) +#if !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_EXCEPTION(g_InteropNS, COMException, false, E_FAIL) +#ifdef FEATURE_COMINTEROP DEFINE_EXCEPTION(g_InteropNS, ExternalException, false, E_FAIL) +#endif //FEATURE_COMINTEROP DEFINE_EXCEPTION(g_InteropNS, SEHException, false, E_FAIL) +#endif // !defined(TARGET_WASM) || !defined(FOR_ILLINK) DEFINE_EXCEPTION(g_SystemNS, NotImplementedException, false, E_NOTIMPL) DEFINE_EXCEPTION(g_SystemNS, OutOfMemoryException, false, E_OUTOFMEMORY, CTL_E_OUTOFMEMORY, STD_CTL_SCODE(31001)) diff --git a/src/coreclr/vm/wasm/callhelpers-pinvoke.cpp b/src/coreclr/vm/wasm/callhelpers-pinvoke.cpp index aa3deb8cb8b315..3a1d25cab60eff 100644 --- a/src/coreclr/vm/wasm/callhelpers-pinvoke.cpp +++ b/src/coreclr/vm/wasm/callhelpers-pinvoke.cpp @@ -80,6 +80,7 @@ extern "C" { int32_t SystemNative_FSync (void *); int32_t SystemNative_FTruncate (void *, int64_t); int32_t SystemNative_FUTimens (void *, void *); + int32_t SystemNative_FcntlGetIsNonBlocking (void *, void *); int32_t SystemNative_FcntlSetFD (void *, int32_t); int32_t SystemNative_FileSystemSupportsLocking (void *, int32_t, int32_t); void SystemNative_Free (void *); @@ -128,9 +129,11 @@ extern "C" { int64_t SystemNative_PReadV (void *, void *, int32_t, int64_t); int32_t SystemNative_PWrite (void *, void *, int32_t, int64_t); int64_t SystemNative_PWriteV (void *, void *, int32_t, int64_t); + int32_t SystemNative_Pipe (void *, int32_t); int32_t SystemNative_PosixFAdvise (void *, int64_t, int64_t, int32_t); int32_t SystemNative_Read (void *, void *, int32_t); int32_t SystemNative_ReadDir (void *, void *); + int32_t SystemNative_ReadFromNonblocking (void *, void *, int32_t); int32_t SystemNative_ReadLink (void *, void *, int32_t); void * SystemNative_Realloc (void *, void *); int32_t SystemNative_Rename (void *, void *); @@ -147,6 +150,7 @@ extern "C" { int32_t SystemNative_UTimensat (void *, void *); int32_t SystemNative_Unlink (void *); int32_t SystemNative_Write (void *, void *, int32_t); + int32_t SystemNative_WriteToNonblocking (void *, void *, int32_t); } // extern "C" static const Entry s_libSystem_Globalization_Native [] = { @@ -218,6 +222,7 @@ static const Entry s_libSystem_Native [] = { DllImportEntry(SystemNative_FSync) // System.Private.CoreLib DllImportEntry(SystemNative_FTruncate) // System.IO.MemoryMappedFiles, System.Private.CoreLib DllImportEntry(SystemNative_FUTimens) // System.Private.CoreLib + DllImportEntry(SystemNative_FcntlGetIsNonBlocking) // System.Private.CoreLib DllImportEntry(SystemNative_FcntlSetFD) // System.IO.MemoryMappedFiles DllImportEntry(SystemNative_FileSystemSupportsLocking) // System.Private.CoreLib DllImportEntry(SystemNative_Free) // System.Private.CoreLib @@ -266,9 +271,11 @@ static const Entry s_libSystem_Native [] = { DllImportEntry(SystemNative_PReadV) // System.Private.CoreLib DllImportEntry(SystemNative_PWrite) // System.Private.CoreLib DllImportEntry(SystemNative_PWriteV) // System.Private.CoreLib + DllImportEntry(SystemNative_Pipe) // System.Private.CoreLib DllImportEntry(SystemNative_PosixFAdvise) // System.Private.CoreLib DllImportEntry(SystemNative_Read) // System.Private.CoreLib DllImportEntry(SystemNative_ReadDir) // System.Private.CoreLib + DllImportEntry(SystemNative_ReadFromNonblocking) // System.Private.CoreLib DllImportEntry(SystemNative_ReadLink) // System.Private.CoreLib DllImportEntry(SystemNative_Realloc) // System.Private.CoreLib DllImportEntry(SystemNative_Rename) // System.Private.CoreLib @@ -285,6 +292,7 @@ static const Entry s_libSystem_Native [] = { DllImportEntry(SystemNative_UTimensat) // System.Private.CoreLib DllImportEntry(SystemNative_Unlink) // System.IO.MemoryMappedFiles, System.Private.CoreLib DllImportEntry(SystemNative_Write) // System.Console, System.Private.CoreLib + DllImportEntry(SystemNative_WriteToNonblocking) // System.Private.CoreLib }; static const Entry s_libSystem_Native_Browser [] = { @@ -309,7 +317,7 @@ typedef struct PInvokeTable { static PInvokeTable s_PInvokeTables[] = { {"libSystem.Globalization.Native", s_libSystem_Globalization_Native, 33}, {"libSystem.IO.Compression.Native", s_libSystem_IO_Compression_Native, 8}, - {"libSystem.Native", s_libSystem_Native, 88}, + {"libSystem.Native", s_libSystem_Native, 92}, {"libSystem.Native.Browser", s_libSystem_Native_Browser, 1}, {"libSystem.Runtime.InteropServices.JavaScript.Native", s_libSystem_Runtime_InteropServices_JavaScript_Native, 6} }; diff --git a/src/coreclr/vm/wasm/callhelpers-reverse.cpp b/src/coreclr/vm/wasm/callhelpers-reverse.cpp index 38220765ac6532..5da2f1de722c97 100644 --- a/src/coreclr/vm/wasm/callhelpers-reverse.cpp +++ b/src/coreclr/vm/wasm/callhelpers-reverse.cpp @@ -271,22 +271,6 @@ static void Call_System_Private_CoreLib_System_Globalization_CalendarData_EnumCa ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_System_Globalization_CalendarData_EnumCalendarInfoCallback_I32_I32_RetVoid, (int8_t*)args, sizeof(args), nullptr, (PCODE)&Call_System_Private_CoreLib_System_Globalization_CalendarData_EnumCalendarInfoCallback_I32_I32_RetVoid); } -static MethodDesc* MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32 = nullptr; -static int32_t Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32(void * arg0) -{ - int64_t args[1] = { (int64_t)arg0 }; - - // Lazy lookup of MethodDesc for the function export scenario. - if (!MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32) - { - LookupUnmanagedCallersOnlyMethodByName("Internal.Runtime.InteropServices.ComActivator, System.Private.CoreLib", "GetClassFactoryForTypeInternal", &MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32); - } - - int32_t result; - ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32, (int8_t*)args, sizeof(args), (int8_t*)&result, (PCODE)&Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32); - return result; -} - static MethodDesc* MD_System_Private_CoreLib_System_Resolver_GetCodeInfo_I32_I32_I32_I32_I32_I32_RetVoid = nullptr; static void Call_System_Private_CoreLib_System_Resolver_GetCodeInfo_I32_I32_I32_I32_I32_I32_RetVoid(void * arg0, void * arg1, void * arg2, void * arg3, void * arg4, void * arg5) { @@ -622,22 +606,6 @@ static void Call_System_Private_CoreLib_System_AppContext_OnUnhandledException_I ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_System_AppContext_OnUnhandledException_I32_I32_RetVoid, (int8_t*)args, sizeof(args), nullptr, (PCODE)&Call_System_Private_CoreLib_System_AppContext_OnUnhandledException_I32_I32_RetVoid); } -static MethodDesc* MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32 = nullptr; -static int32_t Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32(void * arg0) -{ - int64_t args[1] = { (int64_t)arg0 }; - - // Lazy lookup of MethodDesc for the function export scenario. - if (!MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32) - { - LookupUnmanagedCallersOnlyMethodByName("Internal.Runtime.InteropServices.ComActivator, System.Private.CoreLib", "RegisterClassForTypeInternal", &MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32); - } - - int32_t result; - ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32, (int8_t*)args, sizeof(args), (int8_t*)&result, (PCODE)&Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32); - return result; -} - static MethodDesc* MD_System_Runtime_InteropServices_JavaScript_System_Runtime_InteropServices_JavaScript_JavaScriptExports_ReleaseJSOwnedObjectByGCHandle_I32_RetVoid = nullptr; static void Call_System_Runtime_InteropServices_JavaScript_System_Runtime_InteropServices_JavaScript_JavaScriptExports_ReleaseJSOwnedObjectByGCHandle_I32_RetVoid(void * arg0) { @@ -750,22 +718,6 @@ extern "C" void SystemJS_ExecuteTimerCallback() Call_System_Private_CoreLib_System_Threading_TimerQueue_TimerHandler_Void_RetVoid(); } -static MethodDesc* MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32 = nullptr; -static int32_t Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32(void * arg0) -{ - int64_t args[1] = { (int64_t)arg0 }; - - // Lazy lookup of MethodDesc for the function export scenario. - if (!MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32) - { - LookupUnmanagedCallersOnlyMethodByName("Internal.Runtime.InteropServices.ComActivator, System.Private.CoreLib", "UnregisterClassForTypeInternal", &MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32); - } - - int32_t result; - ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32, (int8_t*)args, sizeof(args), (int8_t*)&result, (PCODE)&Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32); - return result; -} - const ReverseThunkMapEntry g_ReverseThunks[] = { { 3863938719, "g__Callback|72_0#1:System.Private.CoreLib:System:GC", { &MD_System_Private_CoreLib_System_GC__RegisterNoGCRegionCallback_g__Callback_7C_72_0_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_GC__RegisterNoGCRegionCallback_g__Callback_7C_72_0_I32_RetVoid } }, @@ -786,7 +738,6 @@ const ReverseThunkMapEntry g_ReverseThunks[] = { 271519467, "CreateTargetInvocationException#3:System.Private.CoreLib:System:Exception", { &MD_System_Private_CoreLib_System_Exception_CreateTargetInvocationException_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Exception_CreateTargetInvocationException_I32_I32_I32_RetVoid } }, { 3064803797, "CreateTypeInitializationException#4:System.Private.CoreLib:System:Exception", { &MD_System_Private_CoreLib_System_Exception_CreateTypeInitializationException_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Exception_CreateTypeInitializationException_I32_I32_I32_I32_RetVoid } }, { 1196551088, "EnumCalendarInfoCallback#2:System.Private.CoreLib:System.Globalization:CalendarData", { &MD_System_Private_CoreLib_System_Globalization_CalendarData_EnumCalendarInfoCallback_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Globalization_CalendarData_EnumCalendarInfoCallback_I32_I32_RetVoid } }, - { 2613312799, "GetClassFactoryForTypeInternal#1:System.Private.CoreLib:Internal.Runtime.InteropServices:ComActivator", { &MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32, (void*)&Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_GetClassFactoryForTypeInternal_I32_RetI32 } }, { 2605868264, "GetCodeInfo#6:System.Private.CoreLib:System:Resolver", { &MD_System_Private_CoreLib_System_Resolver_GetCodeInfo_I32_I32_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Resolver_GetCodeInfo_I32_I32_I32_I32_I32_I32_RetVoid } }, { 3084636701, "GetCustomMarshalerInstance#5:System.Private.CoreLib:System.StubHelpers:MngdRefCustomMarshaler", { &MD_System_Private_CoreLib_System_StubHelpers_MngdRefCustomMarshaler_GetCustomMarshalerInstance_I32_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_StubHelpers_MngdRefCustomMarshaler_GetCustomMarshalerInstance_I32_I32_I32_I32_I32_RetVoid } }, { 1641343147, "GetEHInfo#5:System.Private.CoreLib:System:Resolver", { &MD_System_Private_CoreLib_System_Resolver_GetEHInfo_I32_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Resolver_GetEHInfo_I32_I32_I32_I32_I32_RetVoid } }, @@ -811,7 +762,6 @@ const ReverseThunkMapEntry g_ReverseThunks[] = { 2158495436, "OnResourceResolve#4:System.Private.CoreLib:System.Runtime.Loader:AssemblyLoadContext", { &MD_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_OnResourceResolve_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_OnResourceResolve_I32_I32_I32_I32_RetVoid } }, { 3572430398, "OnTypeResolve#4:System.Private.CoreLib:System.Runtime.Loader:AssemblyLoadContext", { &MD_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_OnTypeResolve_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_OnTypeResolve_I32_I32_I32_I32_RetVoid } }, { 4206970338, "OnUnhandledException#2:System.Private.CoreLib:System:AppContext", { &MD_System_Private_CoreLib_System_AppContext_OnUnhandledException_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_AppContext_OnUnhandledException_I32_I32_RetVoid } }, - { 4239234100, "RegisterClassForTypeInternal#1:System.Private.CoreLib:Internal.Runtime.InteropServices:ComActivator", { &MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32, (void*)&Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_RegisterClassForTypeInternal_I32_RetI32 } }, { 1403522766, "ReleaseJSOwnedObjectByGCHandle#1:System.Runtime.InteropServices.JavaScript:System.Runtime.InteropServices.JavaScript:JavaScriptExports", { &MD_System_Runtime_InteropServices_JavaScript_System_Runtime_InteropServices_JavaScript_JavaScriptExports_ReleaseJSOwnedObjectByGCHandle_I32_RetVoid, (void*)&Call_System_Runtime_InteropServices_JavaScript_System_Runtime_InteropServices_JavaScript_JavaScriptExports_ReleaseJSOwnedObjectByGCHandle_I32_RetVoid } }, { 225437511, "Resolve#4:System.Private.CoreLib:System.Runtime.Loader:AssemblyLoadContext", { &MD_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_Resolve_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_Resolve_I32_I32_I32_I32_RetVoid } }, { 260403842, "ResolveSatelliteAssembly#4:System.Private.CoreLib:System.Runtime.Loader:AssemblyLoadContext", { &MD_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_ResolveSatelliteAssembly_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_ResolveSatelliteAssembly_I32_I32_I32_I32_RetVoid } }, @@ -819,8 +769,7 @@ const ReverseThunkMapEntry g_ReverseThunks[] = { 2988924914, "ResolveToken#6:System.Private.CoreLib:System:Resolver", { &MD_System_Private_CoreLib_System_Resolver_ResolveToken_I32_I32_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Resolver_ResolveToken_I32_I32_I32_I32_I32_I32_RetVoid } }, { 2533042349, "ResolveUsingEvent#4:System.Private.CoreLib:System.Runtime.Loader:AssemblyLoadContext", { &MD_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_ResolveUsingEvent_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Runtime_Loader_AssemblyLoadContext_ResolveUsingEvent_I32_I32_I32_I32_RetVoid } }, { 1963568864, "Setup#4:System.Private.CoreLib:System:AppContext", { &MD_System_Private_CoreLib_System_AppContext_Setup_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_AppContext_Setup_I32_I32_I32_I32_RetVoid } }, - { 167179540, "TimerHandler#0:System.Private.CoreLib:System.Threading:TimerQueue", { &MD_System_Private_CoreLib_System_Threading_TimerQueue_TimerHandler_Void_RetVoid, (void*)&Call_System_Private_CoreLib_System_Threading_TimerQueue_TimerHandler_Void_RetVoid } }, - { 2150642223, "UnregisterClassForTypeInternal#1:System.Private.CoreLib:Internal.Runtime.InteropServices:ComActivator", { &MD_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32, (void*)&Call_System_Private_CoreLib_Internal_Runtime_InteropServices_ComActivator_UnregisterClassForTypeInternal_I32_RetI32 } } + { 167179540, "TimerHandler#0:System.Private.CoreLib:System.Threading:TimerQueue", { &MD_System_Private_CoreLib_System_Threading_TimerQueue_TimerHandler_Void_RetVoid, (void*)&Call_System_Private_CoreLib_System_Threading_TimerQueue_TimerHandler_Void_RetVoid } } }; const size_t g_ReverseThunksCount = sizeof(g_ReverseThunks) / sizeof(g_ReverseThunks[0]); diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml index f7e6fd1f2f0606..5afa9dc298b765 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml @@ -21,7 +21,7 @@ - + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOnAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOnAttribute.cs index 3ea457e7c5f3a4..f965d3c1f9f12a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOnAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOnAttribute.cs @@ -8,8 +8,8 @@ namespace System.Runtime.CompilerServices // Use this attribute to indicate that a function should only be compiled into a Ready2Run // binary if the associated type will always have a well defined value for its IsSupported property [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = true, Inherited = false)] -#if MONO - [Conditional("unnecessary")] // Mono doesn't use Ready2Run so we can remove this attribute to reduce size +#if MONO || TARGET_BROWSER || TARGET_WASI + [Conditional("unnecessary")] // These platforms don't use Ready2Run so we can remove this attribute to reduce size #endif internal sealed class CompExactlyDependsOnAttribute : Attribute { diff --git a/src/tasks/WasmAppBuilder/coreclr/PInvokeCollector.cs b/src/tasks/WasmAppBuilder/coreclr/PInvokeCollector.cs index a16b489a78e6ff..d99d52b55781f1 100644 --- a/src/tasks/WasmAppBuilder/coreclr/PInvokeCollector.cs +++ b/src/tasks/WasmAppBuilder/coreclr/PInvokeCollector.cs @@ -124,6 +124,9 @@ bool DoesMethodHaveCallbacks(MethodInfo method, LogAdapter log) if (!MethodHasCallbackAttributes(method)) return false; + if (IsUnsupportedOnBrowser(method.DeclaringType)) + return false; + if (TryIsMethodGetParametersUnsupported(method, out string? reason)) { Log.Warning("WASM0001", $"Skipping callback '{method.DeclaringType!.FullName}::{method.Name}' because '{reason}'."); @@ -168,6 +171,31 @@ static bool MethodHasCallbackAttributes(MethodInfo method) return false; } + + static bool IsUnsupportedOnBrowser(Type? type) + { + if (type is null) + return false; + + foreach (CustomAttributeData cattr in CustomAttributeData.GetCustomAttributes(type)) + { + try + { + if (cattr.AttributeType.FullName == "System.Runtime.Versioning.UnsupportedOSPlatformAttribute" && + cattr.ConstructorArguments.Count > 0 && + cattr.ConstructorArguments[0].Value?.ToString() == "browser") + { + return true; + } + } + catch + { + // Assembly not found, ignore + } + } + + return false; + } } public static bool IsBlittable(Type type, LogAdapter log) => PInvokeTableGenerator.IsBlittable(type, log);