From ece6d6a71c61dbd244ffeac02f3d323a92f144b9 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 1 Dec 2026 16:56:20 -0800 Subject: [PATCH 1/9] Bind WASM R2R direct P/Invokes to native symbols Direct P/Invokes in WASM ReadyToRun images are now emitted as 'webcil' function imports called directly, instead of going through the build-time generated P/Invoke lookup table. The host resolves these imports against the native runtime's wasmExports, and crossgen2's call-helper generator emits callhelpers-exports.txt so link steps export the needed symbols. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/coreclr/hosts/corerun/CMakeLists.txt | 15 +- src/coreclr/hosts/corerun/wasm/libCorerun.js | 32 +- src/coreclr/jit/lower.cpp | 12 + .../TestCases/R2RTestSuites.cs | 19 +- .../TestCasesRunner/WasmR2RAssert.cs | 44 +- .../WasmArgumentLayoutTests.cs | 8 + .../ReadyToRunSymbolNodeFactory.cs | 22 + .../JitInterface/CorInfoImpl.ReadyToRun.cs | 16 + .../PInvokeTableGenerator.cs | 24 + .../PortableCallHelpersGenerator.cs | 9 + .../vm/wasm/browser/callhelpers-exports.txt | 641 +++++++++++++++ .../vm/wasm/generate-coreclr-helpers.md | 5 +- .../vm/wasm/generate-coreclr-helpers.proj | 3 + .../vm/wasm/wasi/callhelpers-exports.txt | 731 ++++++++++++++++++ .../build/BrowserWasmApp.CoreCLR.targets | 17 +- src/mono/wasi/build/WasiApp.CoreCLR.targets | 9 +- .../corehost/browserhost/browserhost.proj | 2 + .../libs/Common/JavaScript/host/assets.ts | 22 + 18 files changed, 1602 insertions(+), 29 deletions(-) create mode 100644 src/coreclr/vm/wasm/browser/callhelpers-exports.txt create mode 100644 src/coreclr/vm/wasm/wasi/callhelpers-exports.txt diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 54a29890c21c65..b1c64f73efd792 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -123,6 +123,11 @@ else() # Add Node.js host file system support. list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sNODERAWFS=1 -lnodefs.js) endif() + # R2R images import direct P/Invoke targets by native symbol, so the module has to export them. + set(CORERUN_DIRECT_PINVOKE_EXPORTS_FILE "${CLR_DIR}/vm/wasm/browser/callhelpers-exports.txt") + file(STRINGS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}" CORERUN_DIRECT_PINVOKE_EXPORTS) + list(TRANSFORM CORERUN_DIRECT_PINVOKE_EXPORTS PREPEND "_") + list(JOIN CORERUN_DIRECT_PINVOKE_EXPORTS "," CORERUN_DIRECT_PINVOKE_EXPORTS) list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sINITIAL_MEMORY=134217728 -sMAXIMUM_MEMORY=4294967296 @@ -134,12 +139,13 @@ else() -sEXPORT_ES6=1 -sEXIT_RUNTIME=1 -sEXPORTED_RUNTIME_METHODS=CORERUN,ENV,${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS} - -sEXPORTED_FUNCTIONS=_main,${CMAKE_EMCC_EXPORTED_FUNCTIONS} + -sEXPORTED_FUNCTIONS=_main,${CMAKE_EMCC_EXPORTED_FUNCTIONS},${CORERUN_DIRECT_PINVOKE_EXPORTS} -sEXPORT_NAME=createDotnetRuntime -sENVIRONMENT=node,shell,web -lexports.js -Wl,--error-limit=0) target_link_options(corerun PRIVATE ${CORERUN_BROWSER_LINK_OPTIONS}) + set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") # Export everything a runtime test needs to re-link corerun with its # own native library and generated call tables. @@ -166,6 +172,13 @@ else() -Wl,--export=GetDotNetRuntimeContractDescriptor -Wl,--export=__async_continuation) + # R2R images import direct P/Invoke targets by native symbol, so the module has to export them. + set(CORERUN_DIRECT_PINVOKE_EXPORTS_FILE "${CLR_DIR}/vm/wasm/wasi/callhelpers-exports.txt") + file(STRINGS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}" CORERUN_DIRECT_PINVOKE_EXPORTS) + list(TRANSFORM CORERUN_DIRECT_PINVOKE_EXPORTS PREPEND "-Wl,--export-if-defined=") + list(APPEND CORERUN_WASI_LINK_OPTIONS ${CORERUN_DIRECT_PINVOKE_EXPORTS}) + set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") + if (CORERUN_WASI_COMPOSITE_R2R) list(APPEND CORERUN_WASI_LINK_OPTIONS -Wl,--table-base=${CORERUN_WASI_R2R_TABLE_BASE} diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index 59218d8b64dc38..271947548c6370 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -268,18 +268,28 @@ function libCoreRunFactory() { throw new Error("__async_continuation was not preserved by the linker or optimizer"); } payloadPtr = HEAPU32[ptrPtr >>> 2 >>> 0]; - wasmInstance = new WebAssembly.Instance(wasmModule, { - webcil: { - memory: wasmMemory, - __stack_pointer: wasmExports.__stack_pointer, - __coreclr_wasm_rtlrestorecontext_tag: wasmExports.__coreclr_wasm_rtlrestorecontext_tag, - __indirect_function_table: wasmTable, - __table_base: new WebAssembly.Global({ value: "i32", mutable: false }, tableStartIndex), - __memory_base: new WebAssembly.Global({ value: "i32", mutable: false }, payloadPtr), - // Runtime-async continuation return value, shared with the runtime module. - __async_continuation: wasmExports.__async_continuation + const webcilImports = { + memory: wasmMemory, + __stack_pointer: wasmExports.__stack_pointer, + __coreclr_wasm_rtlrestorecontext_tag: wasmExports.__coreclr_wasm_rtlrestorecontext_tag, + __indirect_function_table: wasmTable, + __table_base: new WebAssembly.Global({ value: "i32", mutable: false }, tableStartIndex), + __memory_base: new WebAssembly.Global({ value: "i32", mutable: false }, payloadPtr), + // Runtime-async continuation return value, shared with the runtime module. + __async_continuation: wasmExports.__async_continuation + }; + // Direct P/Invoke and FCall targets are imported by their native symbol, which the runtime + // module exports. A missing export fails when called, matching lazy P/Invoke binding. + for (const imp of WebAssembly.Module.imports(wasmModule)) { + if (imp.module !== "webcil" || imp.kind !== "function" || imp.name in webcilImports) { + continue; } - }); + const name = imp.name; + webcilImports[name] = typeof (wasmExports[name]) === "function" + ? wasmExports[name] + : () => { throw new Error(`Native symbol '${name}' imported by a ReadyToRun image is not exported by the runtime module`); }; + } + wasmInstance = new WebAssembly.Instance(wasmModule, { webcil: webcilImports }); } catch (e) { const errorMessage = e instanceof Error ? e.message : String(e); console.error("Failed to construct WebAssembly instance for Webcil image:", { wasmPath, errorMessage }); diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 076bb83bc89807..9339ae69973909 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -7308,6 +7308,18 @@ GenTree* Lowering::LowerNonvirtPinvokeCall(GenTreeCall* call) switch (lookup.accessType) { case IAT_VALUE: +#ifdef TARGET_WASMARCH + if (m_compiler->IsReadyToRun()) + { + // IAT_VALUE identifies a native function imported by symbol, which is called directly. + call->gtDirectCallAddress = addr; +#ifdef FEATURE_READYTORUN + call->gtEntryPoint.addr = nullptr; + call->gtEntryPoint.accessType = IAT_VALUE; +#endif + break; + } +#endif // IsCallTargetInRange always return true on x64. It wants to use rip-based addressing // for this call. Unfortunately, in case of already resolved pinvokes to external libs, // which are identified via accessType: IAT_VALUE, the relative offset is unlikely to diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs index 5f7debb1024cb3..ae99cb7c5f88f4 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs @@ -123,8 +123,20 @@ void Validate(ReadyToRunReader reader) } } } - Assert.NotEmpty(globalizationTargets); - Assert.Equal(directModule, globalizationTargets.Contains(true)); + // Direct P/Invokes bind to the native symbol through a "webcil" function import rather than a fixup. + WebcilImageReader webcilReader = Assert.IsType(reader.CompositeReader); + List globalizationImports = WasmR2RAssert.GetWasmFunctionImportNames(webcilReader, "webcil") + .FindAll(name => name.StartsWith("GlobalizationNative_", StringComparison.Ordinal)); + Assert.DoesNotContain(true, globalizationTargets); + if (directModule) + { + Assert.NotEmpty(globalizationImports); + } + else + { + Assert.NotEmpty(globalizationTargets); + Assert.Empty(globalizationImports); + } } } @@ -184,6 +196,9 @@ void Validate(ReadyToRunReader reader) uint tableIndex = checked(reader.WasmMinFunctionTableIndex + (uint)callee.EntryPointRuntimeFunctionId); int functionIndex = webcilReader.GetFunctionIndexFromTableIndex(tableIndex); Assert.True(functionIndex >= 0); + // GetFunctionIndexFromTableIndex returns a defined-function index; call operands index + // the whole function space, which starts with the imported functions. + functionIndex += WasmR2RAssert.GetWasmFunctionImportCount(webcilReader); Span pattern = stackalloc byte[12]; int length = 0; pattern[length++] = 0x41; // i32.const diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCasesRunner/WasmR2RAssert.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCasesRunner/WasmR2RAssert.cs index 8fb276fca9755e..ad245a9babea73 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCasesRunner/WasmR2RAssert.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCasesRunner/WasmR2RAssert.cs @@ -482,7 +482,13 @@ public static bool WasmIndexSpacesHaveExpectedEntries(WebcilImageReader reader, uint importedGlobalCount = CountWasmImports(imports, WasmImportKind.Global); uint importedTagCount = CountWasmImports(imports, WasmImportKind.Tag); - CheckImportCount(WasmImportKind.Function, importedFunctionCount, 0, failures); + // Function imports are native symbols (for example direct P/Invoke targets) resolved by the host. + foreach (((string module, string name), WasmImportIndex import) in imports) + { + if (import.Kind == WasmImportKind.Function && module != "webcil") + failures.Add($"Function import '{module}.{name}' must come from the 'webcil' module."); + } + CheckImportCount(WasmImportKind.Table, importedTableCount, 1, failures); CheckImportCount(WasmImportKind.Memory, importedMemoryCount, 1, failures); CheckImportCount(WasmImportKind.Global, importedGlobalCount, 4, failures); @@ -603,8 +609,8 @@ private static void CheckFunctionExports( } /// - /// Verifies the name custom section names every defined function, since it is the only - /// record of function names once they are no longer carried by the export table. + /// Verifies the name custom section names every function, imported and defined, since it is + /// the only record of function names once they are no longer carried by the export table. /// private static void CheckFunctionNames( WebcilImageReader reader, @@ -620,9 +626,11 @@ private static void CheckFunctionNames( } uint count = ReadWasmUleb32(image, ref offset, subsectionEnd); - if (count != definedFunctionCount) + if (count != importedFunctionCount + definedFunctionCount) { - failures.Add($"Name section names {count} functions for {definedFunctionCount} function-section entries."); + failures.Add( + $"Name section names {count} functions for {importedFunctionCount} function imports and " + + $"{definedFunctionCount} function-section entries."); return; } @@ -632,15 +640,14 @@ private static void CheckFunctionNames( uint index = ReadWasmUleb32(image, ref offset, subsectionEnd); string name = ReadWasmName(image, ref offset, subsectionEnd); - // Names must cover the defined-function range exactly. Checking only the ordering and - // the lower bound would accept a uniformly shifted map, which is precisely the - // off-by-one this section has to be trusted not to have. - uint expectedIndex = importedFunctionCount + i; + // Names must cover the whole function index space, imports included, exactly. Checking + // only the ordering and the lower bound would accept a uniformly shifted map, which is + // precisely the off-by-one this section has to be trusted not to have. + uint expectedIndex = i; if (index != expectedIndex) { failures.Add( - $"Name section entry {i} names function index {index}; expected {expectedIndex} " + - $"after {importedFunctionCount} function imports."); + $"Name section entry {i} names function index {index}; expected {expectedIndex}."); return; } @@ -716,6 +723,21 @@ private static bool TryGetWasmFunctionNameSubsection( return false; } + public static int GetWasmFunctionImportCount(WebcilImageReader reader) + => ReadWasmImports(reader).Values.Count(import => import.Kind == WasmImportKind.Function); + + public static List GetWasmFunctionImportNames(WebcilImageReader reader, string module) + { + List names = new(); + foreach (((string importModule, string name), WasmImportIndex import) in ReadWasmImports(reader)) + { + if (import.Kind == WasmImportKind.Function && importModule == module) + names.Add(name); + } + + return names; + } + private static Dictionary<(string Module, string Name), WasmImportIndex> ReadWasmImports(WebcilImageReader reader) { ReadOnlySpan image = reader.GetEntireImage().AsSpan(); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs index d0205c84419b76..811666e2241109 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs @@ -1404,6 +1404,14 @@ public UnsupportedOSPlatformAttribute(string platform) { } int repeatExitCode = PortableCallHelpersGenerator.Run(context, options, new Logger(log, isVerbose: false)); Assert.True(repeatExitCode == 0, log.ToString()); Assert.Equal(table, File.ReadAllText(Path.Combine(options.OutputDirectory, "callhelpers-pinvoke.cpp"))); + + // R2R images import direct P/Invoke targets by these names, so the native module must export them. + string[] exports = File.ReadAllLines(Path.Combine(options.OutputDirectory, PortableCallHelpersGenerator.PInvokeExportsFileName)); + Assert.Contains("Native_Test", exports); + Assert.Single(exports, e => e == "QCall_Test"); + Assert.DoesNotContain("QCall_Unavailable", exports); + Assert.Contains(targetOS == "browser" ? "QCall_memmove" : "memmove", exports); + Assert.Contains(targetOS == "browser" ? "QCall_memset" : "memset", exports); } finally { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs index 536a08f352d074..7a2e8224c9e75a 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs @@ -2,8 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Collections.Generic; using ILCompiler.DependencyAnalysis.ReadyToRun; +using Internal.IL; using Internal.JitInterface; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -823,6 +825,26 @@ public Import GetPInvokeTargetNode(MethodWithToken methodWithToken) return _pInvokeTargetNodes.GetOrAdd(new PInvokeTargetKey(methodWithToken, isIndirect: false)); } + private readonly Dictionary _directWasmPInvokeTargets = new(); + + /// + /// A native function the runtime module exports, which a Wasm image imports from the "webcil" module and calls directly. + /// + public ExternFunctionSymbolNode GetDirectWasmPInvokeTargetNode(string nativeSymbol, MethodSignature signature) + { + Utf8String name = new Utf8String(nativeSymbol); + lock (_directWasmPInvokeTargets) + { + if (!_directWasmPInvokeTargets.TryGetValue(name, out ExternFunctionSymbolNode node)) + { + node = new ExternFunctionSymbolNode(name, signature, isUnmanagedCallersOnly: true, isAsyncCall: false, hasGenericContextArg: false, + new WasmLinkageMetadata(name, new Utf8String("webcil"))); + _directWasmPInvokeTargets.Add(name, node); + } + return node; + } + } + internal Import ResumptionStubEntryPoint(MethodWithGCInfo resumptionStub) { return _resumptionStubEntryPointFixups.GetOrAdd(resumptionStub); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 86a53d2f556482..376a2e8f339ce8 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -3659,10 +3659,26 @@ private unsafe HRESULT allocPgoInstrumentationBySchema(CORINFO_METHOD_STRUCT_* f private void getAddressOfPInvokeTarget(CORINFO_METHOD_STRUCT_* method, ref CORINFO_CONST_LOOKUP pLookup) { MethodDesc methodDesc = HandleToObject(method); + MethodSignature nativeSignature = methodDesc.Signature; if (methodDesc is IL.Stubs.PInvokeTargetNativeMethod rawPInvoke) methodDesc = rawPInvoke.Target; Debug.Assert(_compilation.CompilationModuleGroup.VersionsWithMethodBody(methodDesc)); EcmaMethod ecmaMethod = (EcmaMethod)methodDesc; + + if (_compilation.NodeFactory.Target.IsWasm + && _compilation.CompilationModuleGroup.IsDirectPInvoke(ecmaMethod) + && !ecmaMethod.HasCustomAttribute("System.Runtime.InteropServices", "WasmImportLinkageAttribute")) + { + // Statically linked P/Invokes bind to the native symbol the runtime module exports: the image imports + // it from the "webcil" module and calls it directly, without a fixup or the generated P/Invoke table. + PInvokeMetadata metadata = ecmaMethod.GetPInvokeMethodMetadata(); + string nativeSymbol = ILCompiler.PortableCallHelpers.PInvokeTableGenerator.GetDirectPInvokeSymbolName( + _compilation.NodeFactory.Target.OperatingSystem, metadata.Module, metadata.Name ?? ecmaMethod.GetName()); + pLookup.addr = (void*)ObjectToHandle(_compilation.SymbolNodeFactory.GetDirectWasmPInvokeTargetNode(nativeSymbol, nativeSignature)); + pLookup.accessType = InfoAccessType.IAT_VALUE; + return; + } + ModuleToken moduleToken = new ModuleToken(ecmaMethod.Module, ecmaMethod.Handle); MethodWithToken methodWithToken = new MethodWithToken(ecmaMethod, moduleToken, constrainedType: null, unboxing: false, genericContextObject: null); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs index da8eb4b3cf6384..114f7885d4d16e 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs @@ -20,6 +20,25 @@ namespace ILCompiler.PortableCallHelpers /// internal sealed class PInvokeTableGenerator(InteropLogger log) { + private readonly SortedSet _directPInvokeExports = new(StringComparer.Ordinal); + + /// + /// The native symbols of the statically linked P/Invokes and QCalls the emitted tables bind, which + /// ReadyToRun code imports directly. See . + /// + public IReadOnlyCollection DirectPInvokeExports => _directPInvokeExports; + + /// + /// The native symbol a statically linked P/Invoke or QCall binds to, as declared in the generated table. + /// + public static string GetDirectPInvokeSymbolName(TargetOS targetOS, string module, string entryPoint) + { + if (module == "QCall" && entryPoint is ("memmove" or "memset")) + return targetOS == TargetOS.Browser ? $"QCall_{entryPoint}" : entryPoint; + + return FixupSymbolName(entryPoint); + } + public void EmitPInvokeTable(TextWriter w, TargetDetails target, ModuleDesc systemModule, IEnumerable pinvokeModules, List pinvokes, IEnumerable pinvokeModuleLists = null) { var linked = new DirectPInvokeSet(target, pinvokeModules, pinvokeModuleLists ?? []); @@ -132,7 +151,10 @@ public void EmitPInvokeTable(TextWriter w, TargetDetails target, ModuleDesc syst PInvokeInfo linkedEntryPoint = candidates.FirstOrDefault(c => !c.WasmLinkage); if (linkedEntryPoint is not null) + { linkedDecls.Add(GenPInvokeDecl(linkedEntryPoint, CEntryPoint(linkedEntryPoint))); + _directPInvokeExports.Add(CEntryPoint(linkedEntryPoint)); + } } w.Write( @@ -298,6 +320,8 @@ private void EmitQCallTable(TextWriter w, TargetDetails target, List generator.EmitPInvokeTable(w, context.Target, context.SystemModule, options.PInvokeModules, pinvokes, options.PInvokeModuleLists)); + // ReadyToRun code imports direct P/Invoke targets by native symbol, so the native module has to export them. + WriteIfDifferent(Path.Combine(options.OutputDirectory, PInvokeExportsFileName), log, + w => + { + foreach (string symbol in generator.DirectPInvokeExports) + w.WriteLine(symbol); + }); + WriteIfDifferent(Path.Combine(options.OutputDirectory, ReversePInvokeFileName), log, w => generator.EmitNativeToInterp(w, callbacks)); diff --git a/src/coreclr/vm/wasm/browser/callhelpers-exports.txt b/src/coreclr/vm/wasm/browser/callhelpers-exports.txt new file mode 100644 index 00000000000000..e7f0dcbe11bccc --- /dev/null +++ b/src/coreclr/vm/wasm/browser/callhelpers-exports.txt @@ -0,0 +1,641 @@ +AppContext_SetFirstChanceExceptionHandler +AppContext_TryGetHostPropertyValue +AppDomain_CreateDynamicAssembly +AppendExceptionStackFrame +Array_CreateInstance +Array_Ctor +Array_GetCorElementTypeOfElementType +Array_GetElementConstructorEntrypoint +AssemblyHandle_GetManifestModuleSlow +AssemblyLoadContext_IsTracingEnabled +AssemblyName_InitializeAssemblySpec +AssemblyNative_ApplyUpdate +AssemblyNative_GetAssemblyFromHandle +AssemblyNative_GetCodeBase +AssemblyNative_GetEntryAssembly +AssemblyNative_GetEntryPoint +AssemblyNative_GetExecutingAssembly +AssemblyNative_GetExportedTypes +AssemblyNative_GetFlags +AssemblyNative_GetForwardedType +AssemblyNative_GetFullName +AssemblyNative_GetHashAlgorithm +AssemblyNative_GetImageRuntimeVersion +AssemblyNative_GetLoadContextForAssembly +AssemblyNative_GetLoadedAssemblies +AssemblyNative_GetLocale +AssemblyNative_GetLocation +AssemblyNative_GetManifestResourceInfo +AssemblyNative_GetManifestResourceNames +AssemblyNative_GetModule +AssemblyNative_GetModules +AssemblyNative_GetPublicKey +AssemblyNative_GetReferencedAssemblies +AssemblyNative_GetResource +AssemblyNative_GetSimpleName +AssemblyNative_GetTypeCore +AssemblyNative_GetTypeCoreIgnoreCase +AssemblyNative_GetVersion +AssemblyNative_InitializeAssemblyLoadContext +AssemblyNative_InternalLoad +AssemblyNative_InternalTryGetRawMetadata +AssemblyNative_IsApplyUpdateSupported +AssemblyNative_LoadFromPath +AssemblyNative_LoadFromStream +AssemblyNative_PrepareForAssemblyLoadContextRelease +AssemblyNative_TraceAssemblyLoadFromResolveHandlerInvoked +AssemblyNative_TraceAssemblyResolveHandlerInvoked +AssemblyNative_TraceResolvingHandlerInvoked +AsyncHelpers_AddContinuationToExInternal +AsyncHelpers_ResumeInterpreterContinuation +Buffer_BulkMoveWithWriteBarrierInternal +CallFilterFunclet +CompressionNative_Crc32 +CompressionNative_Deflate +CompressionNative_DeflateEnd +CompressionNative_DeflateInit2_ +CompressionNative_DeflateReset +CompressionNative_Inflate +CompressionNative_InflateEnd +CompressionNative_InflateInit2_ +CompressionNative_InflateReset2_ +CustomAttribute_ParseAttributeUsageAttribute +DebugDebugger_Break +DebugDebugger_CustomNotification +DebugDebugger_IsLoggingHelper +DebugDebugger_IsManagedDebuggerAttached +DebugDebugger_Launch +DebugDebugger_Log +DebugDebugger_PrepareFuncEvalResult +DebugDebugger_ReadFuncEvalPrimitiveRegister +DebugDebugger_WriteFuncEvalObjectRegister +DebugDebugger_WriteFuncEvalRegister +Delegate_AdjustTarget +Delegate_BindToMethodInfo +Delegate_BindToMethodName +Delegate_Construct +Delegate_CreateMethodInfo +Delegate_GetInvokeMethod +Delegate_GetMethodDesc +Delegate_GetMulticastInvoke +Delegate_GetMulticastInvokeSlow +Delegate_InitializeVirtualCallStub +DependentHandle_InternalAlloc +DependentHandle_InternalAllocWithGCTransition +DependentHandle_InternalFree +DependentHandle_InternalFreeWithGCTransition +DependentHandle_InternalGetDependent +DependentHandle_InternalGetTargetAndDependent +DependentHandle_InternalGetTargetWithDebugValidation +DependentHandle_InternalSetDependent +DependentHandle_InternalSetTargetToNull +EHEnumInitFromStackFrameIterator +EHEnumNext +Enum_GetValuesAndNames +Environment_Exit +Environment_FailFast +Environment_GetEnviron +Environment_GetEnvironmentVariable +Environment_SetEnvironmentVariable +Environment_get_ExitCode +Environment_set_ExitCode +EventPipeInternal_CreateProvider +EventPipeInternal_DefineEvent +EventPipeInternal_DeleteProvider +EventPipeInternal_Disable +EventPipeInternal_Enable +EventPipeInternal_EventActivityIdControl +EventPipeInternal_GetNextEvent +EventPipeInternal_GetProvider +EventPipeInternal_GetSessionInfo +EventPipeInternal_SignalSession +EventPipeInternal_WriteEventData +ExceptionNative_GetFrozenStackTrace +ExceptionNative_GetMessageFromNativeResources +ExceptionNative_GetMethodFromStackTrace +ExceptionNative_ThrowAmbiguousResolutionException +ExceptionNative_ThrowClassAccessException +ExceptionNative_ThrowEntryPointNotFoundException +ExceptionNative_ThrowFieldAccessException +ExceptionNative_ThrowMethodAccessException +Exception_IsImmutableException +Exception_PrepareForForeignExceptionRaise +FileLoadException_GetMessageForHR +GCFrameRegistration_RegisterForGCReporting +GCFrameRegistration_UnregisterForGCReporting +GCHandle_InternalAllocWithGCTransition +GCHandle_InternalCompareExchange +GCHandle_InternalFreeWithGCTransition +GCHandle_InternalGetWithDebugValidation +GCHandle_InternalSet +GCHandle__InternalAlloc +GCHandle__InternalFree +GCInterface_AllocateNewArray +GCInterface_Collect +GCInterface_EnableNoGCRegionCallback +GCInterface_EndNoGCRegion +GCInterface_EnumerateConfigurationValues +GCInterface_GetNextFinalizableObject +GCInterface_GetTotalAllocatedBytesPrecise +GCInterface_GetTotalMemory +GCInterface_ReRegisterForFinalize +GCInterface_RefreshMemoryLimit +GCInterface_RegisterFrozenSegment +GCInterface_StartNoGCRegion +GCInterface_UnregisterFrozenSegment +GCInterface_WaitForFullGCApproach +GCInterface_WaitForFullGCComplete +GCInterface_WaitForPendingFinalizers +GCSettings_GetGCLatencyMode +GCSettings_GetLOHCompactionMode +GCSettings_SetGCLatencyMode +GCSettings_SetLOHCompactionMode +GCSettings_get_IsServerGC +GC_GetAllocatedBytesForCurrentThread +GC_GetCurrentObjSize +GC_GetGCNow +GC_GetGenerationInternal +GC_GetLastGCDuration +GC_GetLastGCStartTime +GC_GetMaxGeneration +GC_GetMemoryInfo +GC_GetSegmentSize +GC_GetTotalAllocatedBytesApproximate +GC_SuppressFinalizeInternal +GC__CancelFullGCNotification +GC__CollectionCount +GC__GetTotalPauseDuration +GC__RegisterForFullGCNotification +GenericHandleWorker +GetCurrentExInfo +GetFileLoadExceptionMessage +GetTypeLoadExceptionMessage +GlobalizationNative_ChangeCase +GlobalizationNative_ChangeCaseInvariant +GlobalizationNative_ChangeCaseTurkish +GlobalizationNative_CloseSortHandle +GlobalizationNative_CompareString +GlobalizationNative_EndsWith +GlobalizationNative_EnumCalendarInfo +GlobalizationNative_GetCalendarInfo +GlobalizationNative_GetCalendars +GlobalizationNative_GetDefaultLocaleName +GlobalizationNative_GetICUVersion +GlobalizationNative_GetJapaneseEraStartDate +GlobalizationNative_GetLatestJapaneseEra +GlobalizationNative_GetLocaleInfoGroupingSizes +GlobalizationNative_GetLocaleInfoInt +GlobalizationNative_GetLocaleInfoString +GlobalizationNative_GetLocaleName +GlobalizationNative_GetLocaleTimeFormat +GlobalizationNative_GetLocales +GlobalizationNative_GetSortHandle +GlobalizationNative_GetSortKey +GlobalizationNative_GetSortVersion +GlobalizationNative_IndexOf +GlobalizationNative_InitICUFunctions +GlobalizationNative_InitOrdinalCasingPage +GlobalizationNative_InitOrdinalLowerCasingPage +GlobalizationNative_IsNormalized +GlobalizationNative_IsPredefinedLocale +GlobalizationNative_LastIndexOf +GlobalizationNative_LoadICU +GlobalizationNative_NormalizeString +GlobalizationNative_StartsWith +GlobalizationNative_ToAscii +GlobalizationNative_ToUnicode +InitClassHelper +Interlocked_CompareExchange32 +Interlocked_CompareExchange32Pointer +Interlocked_CompareExchange64 +Interlocked_CompareExchangeObject +Interlocked_Exchange32 +Interlocked_Exchange64 +Interlocked_ExchangeAdd32 +Interlocked_ExchangeAdd64 +Interlocked_ExchangeObject +Interlocked_MemoryBarrierProcessWide +IsInstanceOf_NoCacheLookup +JitInfo_GetCompilationTimeInTicks +JitInfo_GetCompiledILBytes +JitInfo_GetCompiledMethodCount +LoaderAllocator_Destroy +MarshalNative_GetDelegateForFunctionPointerInternal +MarshalNative_GetExceptionForHR +MarshalNative_GetFunctionPointerForDelegateInternal +MarshalNative_GetIsInCooperativeGCModeFunctionPointer +MarshalNative_HasLayout +MarshalNative_OffsetOf +MarshalNative_Prelink +MarshalNative_SizeOfHelper +Marshal_GetExceptionCode +Marshal_GetExceptionPointers +Marshal_GetLastPInvokeError +Marshal_SetLastPInvokeError +MathF_Acos +MathF_Acosh +MathF_Asin +MathF_Asinh +MathF_Atan +MathF_Atan2 +MathF_Atanh +MathF_Cbrt +MathF_Ceiling +MathF_Cos +MathF_Cosh +MathF_Exp +MathF_Floor +MathF_FusedMultiplyAdd +MathF_Log +MathF_Log10 +MathF_Log2 +MathF_ModF +MathF_Pow +MathF_Sin +MathF_SinCos +MathF_Sinh +MathF_Sqrt +MathF_Tan +MathF_Tanh +Math_Acos +Math_Acosh +Math_Asin +Math_Asinh +Math_Atan +Math_Atan2 +Math_Atanh +Math_Cbrt +Math_Ceiling +Math_Cos +Math_Cosh +Math_DivInt32Internal +Math_DivInt64Internal +Math_DivUInt32Internal +Math_DivUInt64Internal +Math_Exp +Math_Floor +Math_FusedMultiplyAdd +Math_Log +Math_Log10 +Math_Log2 +Math_ModF +Math_ModInt32Internal +Math_ModInt64Internal +Math_ModUInt32Internal +Math_ModUInt64Internal +Math_Pow +Math_Sin +Math_SinCos +Math_Sinh +Math_Sqrt +Math_Tan +Math_Tanh +MdUtf8String_EqualsCaseInsensitive +MetadataImport_Enum +MetadataImport_GetClassLayout +MetadataImport_GetCustomAttributeProps +MetadataImport_GetDefaultValue +MetadataImport_GetEventProps +MetadataImport_GetFieldDefProps +MetadataImport_GetFieldMarshal +MetadataImport_GetFieldOffset +MetadataImport_GetGenericParamProps +MetadataImport_GetMarshalAs +MetadataImport_GetMemberRefProps +MetadataImport_GetMetadataImport +MetadataImport_GetName +MetadataImport_GetNamespace +MetadataImport_GetPInvokeMap +MetadataImport_GetParamDefProps +MetadataImport_GetParentToken +MetadataImport_GetPropertyProps +MetadataImport_GetScopeProps +MetadataImport_GetSigOfFieldDef +MetadataImport_GetSigOfMethodDef +MetadataImport_GetSignatureFromToken +MetadataImport_GetUserString +MetadataImport_IsValidToken +MethodBase_GetCurrentMethod +MethodTable_CanCompareBitsOrUseFastGetHashCode +MethodTable_GetLoaderAllocatorHandle +MethodTable_GetMethodTableMatchingParentClass +MethodTable_GetNumInstanceFieldBytes +MethodTable_GetPrimitiveCorElementType +ModuleBuilder_GetArrayMethodToken +ModuleBuilder_GetMemberRef +ModuleBuilder_GetMemberRefFromSignature +ModuleBuilder_GetMemberRefOfFieldInfo +ModuleBuilder_GetMemberRefOfMethodInfo +ModuleBuilder_GetStringConstant +ModuleBuilder_GetTokenFromTypeSpec +ModuleBuilder_GetTypeRef +ModuleBuilder_SetFieldRVAContent +ModuleHandle_GetDynamicMethod +ModuleHandle_GetMDStreamVersion +ModuleHandle_GetModuleType +ModuleHandle_GetPEKind +ModuleHandle_GetToken +ModuleHandle_ResolveField +ModuleHandle_ResolveMethod +ModuleHandle_ResolveType +NativeLibrary_LoadByName +NativeRuntimeEventSource_LogContentionLockCreated +NativeRuntimeEventSource_LogContentionStart +NativeRuntimeEventSource_LogContentionStop +NativeRuntimeEventSource_LogDecreaseMemoryPressure +NativeRuntimeEventSource_LogIncreaseMemoryPressure +NativeRuntimeEventSource_LogThreadPoolIODequeue +NativeRuntimeEventSource_LogThreadPoolIOEnqueue +NativeRuntimeEventSource_LogThreadPoolIOPack +NativeRuntimeEventSource_LogThreadPoolMinMaxThreads +NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment +NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample +NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats +NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart +NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop +NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait +NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount +NativeRuntimeEventSource_LogWaitHandleWaitStart +NativeRuntimeEventSource_LogWaitHandleWaitStop +ObjectHeader_GetLockHandleIfExists +ObjectHeader_GetOrCreateLockObject +ObjectNative_AllocateUninitializedClone +ObjectNative_GetHashCodeSlow +QCall_FreeGCHandleForTypeHandle +QCall_GetGCHandleForTypeHandle +QCall_memmove +QCall_memset +ReflectionInvocation_CompileMethod +ReflectionInvocation_GetBoxInfo +ReflectionInvocation_GetGuid +ReflectionInvocation_PrepareDelegate +ReflectionInvocation_PrepareMethod +ReflectionInvocation_RunClassConstructor +ReflectionInvocation_RunModuleConstructor +ReflectionInvocation_SizeOf +ReflectionSerialization_GetCreateUninitializedObjectInfo +ResolveVirtualFunctionPointer +RuntimeAssembly_GetIsCollectible +RuntimeAssembly_GetIsDynamic +RuntimeAssembly_GetManifestModule +RuntimeAssembly_GetTokenInternal +RuntimeFieldHandle_AcquiresContextFromThis +RuntimeFieldHandle_GetApproxDeclaringMethodTable +RuntimeFieldHandle_GetAttributes +RuntimeFieldHandle_GetEnCFieldAddr +RuntimeFieldHandle_GetFieldDataReference +RuntimeFieldHandle_GetInstanceFieldOffset +RuntimeFieldHandle_GetLoaderAllocatorInternal +RuntimeFieldHandle_GetRVAFieldInfo +RuntimeFieldHandle_GetStaticFieldAddress +RuntimeFieldHandle_GetStaticFieldForGenericType +RuntimeFieldHandle_GetToken +RuntimeFieldHandle_GetUtf8NameInternal +RuntimeFieldHandle_GetValue +RuntimeFieldHandle_GetValueDirect +RuntimeFieldHandle_IsFastPathSupported +RuntimeFieldHandle_SetValue +RuntimeFieldHandle_SetValueDirect +RuntimeHelpers_ContentEquals +RuntimeHelpers_GetTailCallArgBuffer +RuntimeHelpers_GetTailCallInfo +RuntimeHelpers_TryEnsureSufficientExecutionStack +RuntimeHelpers_TryGetHashCode +RuntimeMethodHandle_ConstructInstantiation +RuntimeMethodHandle_Destroy +RuntimeMethodHandle_GetAttributes +RuntimeMethodHandle_GetDiagnosticCodeStart +RuntimeMethodHandle_GetFunctionPointer +RuntimeMethodHandle_GetGenericParameterCount +RuntimeMethodHandle_GetImplAttributes +RuntimeMethodHandle_GetLoaderAllocatorInternal +RuntimeMethodHandle_GetMethodBody +RuntimeMethodHandle_GetMethodDef +RuntimeMethodHandle_GetMethodFromCanonical +RuntimeMethodHandle_GetMethodInstantiation +RuntimeMethodHandle_GetMethodTable +RuntimeMethodHandle_GetResolver +RuntimeMethodHandle_GetSlot +RuntimeMethodHandle_GetStubIfNeededInternal +RuntimeMethodHandle_GetStubIfNeededSlow +RuntimeMethodHandle_GetTypicalMethodDefinition +RuntimeMethodHandle_GetUtf8NameInternal +RuntimeMethodHandle_GetVirtualFunctionPointer +RuntimeMethodHandle_HasMethodInstantiation +RuntimeMethodHandle_IsAsyncMethod +RuntimeMethodHandle_IsCAVisibleFromDecoratedType +RuntimeMethodHandle_IsCollectible +RuntimeMethodHandle_IsConstructor +RuntimeMethodHandle_IsDynamicMethod +RuntimeMethodHandle_IsGenericMethodDefinition +RuntimeMethodHandle_IsTypicalMethodDefinition +RuntimeMethodHandle_StripMethodInstantiation +RuntimeModule_GetFullyQualifiedName +RuntimeModule_GetScopeName +RuntimeModule_GetTypes +RuntimeTypeHandle_AllocateTypeAssociatedMemory +RuntimeTypeHandle_AllocateTypeAssociatedMemoryAligned +RuntimeTypeHandle_CompareCanonicalHandles +RuntimeTypeHandle_ConstructName +RuntimeTypeHandle_ContainsGenericVariables +RuntimeTypeHandle_CreateInstanceForAnotherGenericParameter +RuntimeTypeHandle_GetActivationInfo +RuntimeTypeHandle_GetArgumentTypesFromFunctionPointer +RuntimeTypeHandle_GetArrayRank +RuntimeTypeHandle_GetAssemblyIfExists +RuntimeTypeHandle_GetAssemblySlow +RuntimeTypeHandle_GetAttributes +RuntimeTypeHandle_GetConstraints +RuntimeTypeHandle_GetDeclaringMethodForGenericParameter +RuntimeTypeHandle_GetDeclaringTypeHandle +RuntimeTypeHandle_GetDeclaringTypeHandleForGenericVariable +RuntimeTypeHandle_GetElementTypeHandle +RuntimeTypeHandle_GetFields +RuntimeTypeHandle_GetFirstIntroducedMethod +RuntimeTypeHandle_GetGenericTypeDefinition +RuntimeTypeHandle_GetGenericVariableIndex +RuntimeTypeHandle_GetInstantiation +RuntimeTypeHandle_GetInterfaceMethodImplementation +RuntimeTypeHandle_GetInterfaces +RuntimeTypeHandle_GetMethodAt +RuntimeTypeHandle_GetModuleIfExists +RuntimeTypeHandle_GetModuleSlow +RuntimeTypeHandle_GetNextIntroducedMethod +RuntimeTypeHandle_GetNumVirtuals +RuntimeTypeHandle_GetNumVirtualsAndStaticVirtuals +RuntimeTypeHandle_GetRuntimeTypeFromHandleSlow +RuntimeTypeHandle_GetToken +RuntimeTypeHandle_GetUtf8NameInternal +RuntimeTypeHandle_Instantiate +RuntimeTypeHandle_InternalAlloc +RuntimeTypeHandle_InternalAllocNoChecks +RuntimeTypeHandle_InternalAllocNoChecks_FastPath +RuntimeTypeHandle_IsGenericVariable +RuntimeTypeHandle_IsUnmanagedFunctionPointer +RuntimeTypeHandle_IsVisible +RuntimeTypeHandle_MakeArray +RuntimeTypeHandle_MakeByRef +RuntimeTypeHandle_MakeFunctionPointer +RuntimeTypeHandle_MakePointer +RuntimeTypeHandle_MakeSZArray +RuntimeTypeHandle_RegisterCollectibleTypeDependency +RuntimeTypeHandle_SatisfiesConstraints +RuntimeTypeHandle_VerifyInterfaceIsImplemented +SfiInit +SfiNext +Signature_AreEqual +Signature_GetCallingConventionFromFunctionPointerAtOffsetInternal +Signature_GetCustomModifiersAtOffset +Signature_GetParameterOffsetInternal +Signature_GetTypeParameterOffsetInternal +Signature_Init +StackFrame_GetMethodDescFromNativeIP +StackTrace_GetStackFramesInternal +Stream_HasOverriddenSlow +String_Intern +String_IsInterned +StubHelpers_ClearLastError +StubHelpers_CreateCustomMarshaler +StubHelpers_CreateLayoutClassMarshalStubs +StubHelpers_LogPinnedArgument +StubHelpers_MulticastDebuggerTraceHelper +StubHelpers_SetLastError +StubHelpers_ThrowInteropException +StubHelpers_ThrowInteropParamException +StubHelpers_ValidateByref +StubHelpers_ValidateObject +SystemInteropJS_BindJSImportST +SystemInteropJS_CancelPromise +SystemInteropJS_InvokeJSFunction +SystemInteropJS_InvokeJSImportST +SystemInteropJS_ReleaseCSOwnedObject +SystemInteropJS_ResolveOrRejectPromise +SystemJS_GetLocaleInfo +SystemJS_MarkAsyncMain +SystemJS_RejectMainPromise +SystemJS_ResolveMainPromise +SystemJS_ScheduleBackgroundJob +SystemJS_ScheduleTimer +SystemNative_Access +SystemNative_AlignedAlloc +SystemNative_AlignedFree +SystemNative_AlignedRealloc +SystemNative_Calloc +SystemNative_CanGetHiddenFlag +SystemNative_ChDir +SystemNative_ChMod +SystemNative_Close +SystemNative_CloseDir +SystemNative_ConvertErrorPalToPlatform +SystemNative_ConvertErrorPlatformToPal +SystemNative_CopyFile +SystemNative_FAllocate +SystemNative_FChMod +SystemNative_FChflags +SystemNative_FLock +SystemNative_FStat +SystemNative_FSync +SystemNative_FTruncate +SystemNative_FUTimens +SystemNative_FcntlGetIsNonBlocking +SystemNative_FcntlSetFD +SystemNative_FileSystemSupportsLocking +SystemNative_Free +SystemNative_FreeLibrary +SystemNative_GetCommandLine +SystemNative_GetCpuUtilization +SystemNative_GetCryptographicallySecureRandomBytes +SystemNative_GetCwd +SystemNative_GetDefaultSearchOrderPseudoHandle +SystemNative_GetErrNo +SystemNative_GetLoadLibraryError +SystemNative_GetLowResolutionTimestamp +SystemNative_GetNonCryptographicallySecureRandomBytes +SystemNative_GetProcAddress +SystemNative_GetSystemTimeAsTicks +SystemNative_GetTimeZoneData +SystemNative_GetTimestamp +SystemNative_IsMemfdSupported +SystemNative_LChflags +SystemNative_LChflagsCanSetHiddenFlag +SystemNative_LSeek +SystemNative_LStat +SystemNative_Link +SystemNative_LoadLibrary +SystemNative_LockFileRegion +SystemNative_Log +SystemNative_LogError +SystemNative_MAdvise +SystemNative_MMap +SystemNative_MSync +SystemNative_MUnmap +SystemNative_Malloc +SystemNative_MemfdCreate +SystemNative_MkDir +SystemNative_MkdTemp +SystemNative_MksTemps +SystemNative_Open +SystemNative_OpenDir +SystemNative_PRead +SystemNative_PReadV +SystemNative_PWrite +SystemNative_PWriteV +SystemNative_Pipe +SystemNative_PosixFAdvise +SystemNative_Read +SystemNative_ReadDir +SystemNative_ReadFromNonblocking +SystemNative_ReadLink +SystemNative_ReadV +SystemNative_Realloc +SystemNative_Rename +SystemNative_RmDir +SystemNative_SetErrNo +SystemNative_ShmOpen +SystemNative_ShmUnlink +SystemNative_Stat +SystemNative_StrErrorR +SystemNative_SymLink +SystemNative_SysConf +SystemNative_SysLog +SystemNative_ThreadSleep +SystemNative_UTimensat +SystemNative_Unlink +SystemNative_Write +SystemNative_WriteToNonblocking +SystemNative_WriteV +TailCallHelp_AllocTailCallArgBufferInternal +ThreadNative_Abort +ThreadNative_GetQCallSpecialException +ThreadNative_GetThreadState +ThreadNative_ResetAbort +ThrowInvalidCastException +TypeBuilder_AddInterfaceImpl +TypeBuilder_DefineCustomAttribute +TypeBuilder_DefineEvent +TypeBuilder_DefineField +TypeBuilder_DefineGenericParam +TypeBuilder_DefineMethod +TypeBuilder_DefineMethodImpl +TypeBuilder_DefineMethodSemantics +TypeBuilder_DefineMethodSpec +TypeBuilder_DefineProperty +TypeBuilder_DefineType +TypeBuilder_GetTokenFromSig +TypeBuilder_SetClassLayout +TypeBuilder_SetConstantValue +TypeBuilder_SetFieldLayoutOffset +TypeBuilder_SetMethodIL +TypeBuilder_SetMethodImpl +TypeBuilder_SetPInvokeData +TypeBuilder_SetParamInfo +TypeBuilder_SetParentType +TypeBuilder_TermCreateClass +TypeHandle_CanCastTo_NoCacheLookup +TypeHandle_GetCorElementType +TypeMapLazyDictionary_FindPrecachedExternalTypeMapEntry +TypeMapLazyDictionary_FindPrecachedProxyTypeMapEntry +TypeMapLazyDictionary_ProcessAttributes +UnsafeAccessors_ResolveGenericParamToTypeHandle +ValueType_GetHashCodeStrategy +VersionResilientHashCode_TypeHashCode diff --git a/src/coreclr/vm/wasm/generate-coreclr-helpers.md b/src/coreclr/vm/wasm/generate-coreclr-helpers.md index 5b1e42b06bf141..43dfd399734bb5 100644 --- a/src/coreclr/vm/wasm/generate-coreclr-helpers.md +++ b/src/coreclr/vm/wasm/generate-coreclr-helpers.md @@ -28,11 +28,14 @@ By default the scripts generate **both** WebAssembly variations; pass `--target- | `browser` | `src/coreclr/vm/wasm/browser/` | `artifacts/bin/testhost/net12.0-browser--wasm/shared/Microsoft.NETCore.App/12.0.0/` | | `wasi` | `src/coreclr/vm/wasm/wasi/` | `artifacts/bin/testhost/net12.0-wasi--wasm/shared/Microsoft.NETCore.App/12.0.0/` | -Each run emits three files into the output directory: +Each run emits four files into the output directory: - `callhelpers-pinvoke.cpp` - `callhelpers-reverse.cpp` - `callhelpers-interp-to-managed.cpp` +- `callhelpers-exports.txt` + +`callhelpers-exports.txt` lists the native symbols of the statically linked P/Invokes, QCalls and FCalls in `callhelpers-pinvoke.cpp`, one per line. The native module exports them, because ReadyToRun code imports these targets by symbol instead of resolving them through the table. ## The shared QCall/FCall table diff --git a/src/coreclr/vm/wasm/generate-coreclr-helpers.proj b/src/coreclr/vm/wasm/generate-coreclr-helpers.proj index 627b095bb5f19f..5222805423edb2 100644 --- a/src/coreclr/vm/wasm/generate-coreclr-helpers.proj +++ b/src/coreclr/vm/wasm/generate-coreclr-helpers.proj @@ -152,6 +152,9 @@ + + + diff --git a/src/coreclr/vm/wasm/wasi/callhelpers-exports.txt b/src/coreclr/vm/wasm/wasi/callhelpers-exports.txt new file mode 100644 index 00000000000000..47fc430e89d7e3 --- /dev/null +++ b/src/coreclr/vm/wasm/wasi/callhelpers-exports.txt @@ -0,0 +1,731 @@ +AppContext_SetFirstChanceExceptionHandler +AppContext_TryGetHostPropertyValue +AppDomain_CreateDynamicAssembly +AppendExceptionStackFrame +Array_CreateInstance +Array_Ctor +Array_GetCorElementTypeOfElementType +Array_GetElementConstructorEntrypoint +AssemblyHandle_GetManifestModuleSlow +AssemblyLoadContext_IsTracingEnabled +AssemblyName_InitializeAssemblySpec +AssemblyNative_ApplyUpdate +AssemblyNative_GetAssemblyCount +AssemblyNative_GetAssemblyFromHandle +AssemblyNative_GetCodeBase +AssemblyNative_GetEntryAssembly +AssemblyNative_GetEntryPoint +AssemblyNative_GetExecutingAssembly +AssemblyNative_GetExportedTypes +AssemblyNative_GetFlags +AssemblyNative_GetForwardedType +AssemblyNative_GetFullName +AssemblyNative_GetHashAlgorithm +AssemblyNative_GetImageRuntimeVersion +AssemblyNative_GetLoadContextForAssembly +AssemblyNative_GetLoadedAssemblies +AssemblyNative_GetLocale +AssemblyNative_GetLocation +AssemblyNative_GetManifestResourceInfo +AssemblyNative_GetManifestResourceNames +AssemblyNative_GetModule +AssemblyNative_GetModules +AssemblyNative_GetPublicKey +AssemblyNative_GetReferencedAssemblies +AssemblyNative_GetResource +AssemblyNative_GetSimpleName +AssemblyNative_GetTypeCore +AssemblyNative_GetTypeCoreIgnoreCase +AssemblyNative_GetVersion +AssemblyNative_InitializeAssemblyLoadContext +AssemblyNative_InternalLoad +AssemblyNative_InternalTryGetRawMetadata +AssemblyNative_IsApplyUpdateSupported +AssemblyNative_LoadFromPath +AssemblyNative_LoadFromStream +AssemblyNative_PrepareForAssemblyLoadContextRelease +AssemblyNative_TraceAssemblyLoadFromResolveHandlerInvoked +AssemblyNative_TraceAssemblyResolveHandlerInvoked +AssemblyNative_TraceResolvingHandlerInvoked +AssemblyNative_TraceSatelliteSubdirectoryPathProbed +AsyncHelpers_AddContinuationToExInternal +AsyncHelpers_ResumeInterpreterContinuation +BrotliDecoderCreateInstance +BrotliDecoderDecompress +BrotliDecoderDecompressStream +BrotliDecoderDestroyInstance +BrotliDecoderIsFinished +BrotliDecoderSetParameter +BrotliEncoderCompress +BrotliEncoderCompressStream +BrotliEncoderCreateInstance +BrotliEncoderDestroyInstance +BrotliEncoderHasMoreOutput +BrotliEncoderMaxCompressedSize +BrotliEncoderSetParameter +Buffer_BulkMoveWithWriteBarrierInternal +CallFilterFunclet +CompressionNative_Crc32 +CompressionNative_Deflate +CompressionNative_DeflateEnd +CompressionNative_DeflateInit2_ +CompressionNative_DeflateReset +CompressionNative_Inflate +CompressionNative_InflateEnd +CompressionNative_InflateInit2_ +CompressionNative_InflateReset2_ +CustomAttribute_ParseAttributeUsageAttribute +DebugDebugger_Break +DebugDebugger_CustomNotification +DebugDebugger_IsLoggingHelper +DebugDebugger_IsManagedDebuggerAttached +DebugDebugger_Launch +DebugDebugger_Log +DebugDebugger_PrepareFuncEvalResult +DebugDebugger_ReadFuncEvalPrimitiveRegister +DebugDebugger_WriteFuncEvalObjectRegister +DebugDebugger_WriteFuncEvalRegister +Delegate_AdjustTarget +Delegate_BindToMethodInfo +Delegate_BindToMethodName +Delegate_Construct +Delegate_CreateMethodInfo +Delegate_GetInvokeMethod +Delegate_GetMethodDesc +Delegate_GetMulticastInvoke +Delegate_GetMulticastInvokeSlow +Delegate_InitializeVirtualCallStub +DependentHandle_InternalAlloc +DependentHandle_InternalAllocWithGCTransition +DependentHandle_InternalFree +DependentHandle_InternalFreeWithGCTransition +DependentHandle_InternalGetDependent +DependentHandle_InternalGetTargetAndDependent +DependentHandle_InternalGetTargetWithDebugValidation +DependentHandle_InternalSetDependent +DependentHandle_InternalSetTargetToNull +EHEnumInitFromStackFrameIterator +EHEnumNext +Enum_GetValuesAndNames +Environment_Exit +Environment_FailFast +Environment_GetEnviron +Environment_GetEnvironmentVariable +Environment_SetEnvironmentVariable +Environment_get_ExitCode +Environment_set_ExitCode +EventPipeInternal_CreateProvider +EventPipeInternal_DefineEvent +EventPipeInternal_DeleteProvider +EventPipeInternal_Disable +EventPipeInternal_Enable +EventPipeInternal_EventActivityIdControl +EventPipeInternal_GetNextEvent +EventPipeInternal_GetProvider +EventPipeInternal_GetSessionInfo +EventPipeInternal_SignalSession +EventPipeInternal_WasiRunJobs +EventPipeInternal_WriteEventData +ExceptionNative_GetFrozenStackTrace +ExceptionNative_GetMessageFromNativeResources +ExceptionNative_GetMethodFromStackTrace +ExceptionNative_ThrowAmbiguousResolutionException +ExceptionNative_ThrowClassAccessException +ExceptionNative_ThrowEntryPointNotFoundException +ExceptionNative_ThrowFieldAccessException +ExceptionNative_ThrowMethodAccessException +Exception_GetExceptionCount +Exception_IsImmutableException +Exception_PrepareForForeignExceptionRaise +FileLoadException_GetMessageForHR +GCFrameRegistration_RegisterForGCReporting +GCFrameRegistration_UnregisterForGCReporting +GCHandle_InternalAllocWithGCTransition +GCHandle_InternalCompareExchange +GCHandle_InternalFreeWithGCTransition +GCHandle_InternalGetWithDebugValidation +GCHandle_InternalSet +GCHandle__InternalAlloc +GCHandle__InternalFree +GCInterface_AllocateNewArray +GCInterface_Collect +GCInterface_EnableNoGCRegionCallback +GCInterface_EndNoGCRegion +GCInterface_EnumerateConfigurationValues +GCInterface_GetGenerationBudget +GCInterface_GetNextFinalizableObject +GCInterface_GetTotalAllocatedBytesPrecise +GCInterface_GetTotalMemory +GCInterface_ReRegisterForFinalize +GCInterface_RefreshMemoryLimit +GCInterface_RegisterFrozenSegment +GCInterface_StartNoGCRegion +GCInterface_UnregisterFrozenSegment +GCInterface_WaitForFullGCApproach +GCInterface_WaitForFullGCComplete +GCInterface_WaitForPendingFinalizers +GCSettings_GetGCLatencyMode +GCSettings_GetLOHCompactionMode +GCSettings_SetGCLatencyMode +GCSettings_SetLOHCompactionMode +GCSettings_get_IsServerGC +GC_GetAllocatedBytesForCurrentThread +GC_GetCurrentObjSize +GC_GetGCNow +GC_GetGenerationInternal +GC_GetGenerationSize +GC_GetLastGCDuration +GC_GetLastGCPercentTimeInGC +GC_GetLastGCStartTime +GC_GetMaxGeneration +GC_GetMemoryInfo +GC_GetSegmentSize +GC_GetTotalAllocatedBytesApproximate +GC_SuppressFinalizeInternal +GC__CancelFullGCNotification +GC__CollectionCount +GC__GetTotalPauseDuration +GC__RegisterForFullGCNotification +GenericHandleWorker +GetCurrentExInfo +GetFileLoadExceptionMessage +GetTypeLoadExceptionMessage +GlobalizationNative_ChangeCase +GlobalizationNative_ChangeCaseInvariant +GlobalizationNative_ChangeCaseTurkish +GlobalizationNative_CloseSortHandle +GlobalizationNative_CompareString +GlobalizationNative_EndsWith +GlobalizationNative_EnumCalendarInfo +GlobalizationNative_GetCalendarInfo +GlobalizationNative_GetCalendars +GlobalizationNative_GetDefaultLocaleName +GlobalizationNative_GetICUVersion +GlobalizationNative_GetJapaneseEraStartDate +GlobalizationNative_GetLatestJapaneseEra +GlobalizationNative_GetLocaleInfoGroupingSizes +GlobalizationNative_GetLocaleInfoInt +GlobalizationNative_GetLocaleInfoString +GlobalizationNative_GetLocaleName +GlobalizationNative_GetLocaleTimeFormat +GlobalizationNative_GetLocales +GlobalizationNative_GetSortHandle +GlobalizationNative_GetSortKey +GlobalizationNative_GetSortVersion +GlobalizationNative_IndexOf +GlobalizationNative_InitICUFunctions +GlobalizationNative_InitOrdinalCasingPage +GlobalizationNative_InitOrdinalLowerCasingPage +GlobalizationNative_IsNormalized +GlobalizationNative_IsPredefinedLocale +GlobalizationNative_LastIndexOf +GlobalizationNative_LoadICU +GlobalizationNative_NormalizeString +GlobalizationNative_StartsWith +GlobalizationNative_ToAscii +GlobalizationNative_ToUnicode +InitClassHelper +Interlocked_CompareExchange32 +Interlocked_CompareExchange32Pointer +Interlocked_CompareExchange64 +Interlocked_CompareExchangeObject +Interlocked_Exchange32 +Interlocked_Exchange64 +Interlocked_ExchangeAdd32 +Interlocked_ExchangeAdd64 +Interlocked_ExchangeObject +Interlocked_MemoryBarrierProcessWide +IsInstanceOf_NoCacheLookup +JitInfo_GetCompilationTimeInTicks +JitInfo_GetCompiledILBytes +JitInfo_GetCompiledMethodCount +LoaderAllocator_Destroy +MarshalNative_GetDelegateForFunctionPointerInternal +MarshalNative_GetExceptionForHR +MarshalNative_GetFunctionPointerForDelegateInternal +MarshalNative_GetIsInCooperativeGCModeFunctionPointer +MarshalNative_HasLayout +MarshalNative_OffsetOf +MarshalNative_Prelink +MarshalNative_SizeOfHelper +Marshal_GetExceptionCode +Marshal_GetExceptionPointers +Marshal_GetLastPInvokeError +Marshal_SetLastPInvokeError +MathF_Acos +MathF_Acosh +MathF_Asin +MathF_Asinh +MathF_Atan +MathF_Atan2 +MathF_Atanh +MathF_Cbrt +MathF_Ceiling +MathF_Cos +MathF_Cosh +MathF_Exp +MathF_Floor +MathF_FusedMultiplyAdd +MathF_Log +MathF_Log10 +MathF_Log2 +MathF_ModF +MathF_Pow +MathF_Sin +MathF_SinCos +MathF_Sinh +MathF_Sqrt +MathF_Tan +MathF_Tanh +Math_Acos +Math_Acosh +Math_Asin +Math_Asinh +Math_Atan +Math_Atan2 +Math_Atanh +Math_Cbrt +Math_Ceiling +Math_Cos +Math_Cosh +Math_DivInt32Internal +Math_DivInt64Internal +Math_DivUInt32Internal +Math_DivUInt64Internal +Math_Exp +Math_Floor +Math_FusedMultiplyAdd +Math_Log +Math_Log10 +Math_Log2 +Math_ModF +Math_ModInt32Internal +Math_ModInt64Internal +Math_ModUInt32Internal +Math_ModUInt64Internal +Math_Pow +Math_Sin +Math_SinCos +Math_Sinh +Math_Sqrt +Math_Tan +Math_Tanh +MdUtf8String_EqualsCaseInsensitive +MetadataImport_Enum +MetadataImport_GetClassLayout +MetadataImport_GetCustomAttributeProps +MetadataImport_GetDefaultValue +MetadataImport_GetEventProps +MetadataImport_GetFieldDefProps +MetadataImport_GetFieldMarshal +MetadataImport_GetFieldOffset +MetadataImport_GetGenericParamProps +MetadataImport_GetMarshalAs +MetadataImport_GetMemberRefProps +MetadataImport_GetMetadataImport +MetadataImport_GetName +MetadataImport_GetNamespace +MetadataImport_GetPInvokeMap +MetadataImport_GetParamDefProps +MetadataImport_GetParentToken +MetadataImport_GetPropertyProps +MetadataImport_GetScopeProps +MetadataImport_GetSigOfFieldDef +MetadataImport_GetSigOfMethodDef +MetadataImport_GetSignatureFromToken +MetadataImport_GetUserString +MetadataImport_IsValidToken +MethodBase_GetCurrentMethod +MethodTable_CanCompareBitsOrUseFastGetHashCode +MethodTable_GetLoaderAllocatorHandle +MethodTable_GetMethodTableMatchingParentClass +MethodTable_GetNumInstanceFieldBytes +MethodTable_GetPrimitiveCorElementType +ModuleBuilder_GetArrayMethodToken +ModuleBuilder_GetMemberRef +ModuleBuilder_GetMemberRefFromSignature +ModuleBuilder_GetMemberRefOfFieldInfo +ModuleBuilder_GetMemberRefOfMethodInfo +ModuleBuilder_GetStringConstant +ModuleBuilder_GetTokenFromTypeSpec +ModuleBuilder_GetTypeRef +ModuleBuilder_SetFieldRVAContent +ModuleHandle_GetDynamicMethod +ModuleHandle_GetMDStreamVersion +ModuleHandle_GetModuleType +ModuleHandle_GetPEKind +ModuleHandle_GetToken +ModuleHandle_ResolveField +ModuleHandle_ResolveMethod +ModuleHandle_ResolveType +NativeLibrary_LoadByName +NativeRuntimeEventSource_LogContentionLockCreated +NativeRuntimeEventSource_LogContentionStart +NativeRuntimeEventSource_LogContentionStop +NativeRuntimeEventSource_LogDecreaseMemoryPressure +NativeRuntimeEventSource_LogIncreaseMemoryPressure +NativeRuntimeEventSource_LogThreadPoolIODequeue +NativeRuntimeEventSource_LogThreadPoolIOEnqueue +NativeRuntimeEventSource_LogThreadPoolIOPack +NativeRuntimeEventSource_LogThreadPoolMinMaxThreads +NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment +NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample +NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats +NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart +NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop +NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait +NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount +NativeRuntimeEventSource_LogWaitHandleWaitStart +NativeRuntimeEventSource_LogWaitHandleWaitStop +ObjectHeader_GetLockHandleIfExists +ObjectHeader_GetOrCreateLockObject +ObjectNative_AllocateUninitializedClone +ObjectNative_GetHashCodeSlow +QCall_FreeGCHandleForTypeHandle +QCall_GetGCHandleForTypeHandle +ReflectionInvocation_CompileMethod +ReflectionInvocation_GetBoxInfo +ReflectionInvocation_GetGuid +ReflectionInvocation_PrepareDelegate +ReflectionInvocation_PrepareMethod +ReflectionInvocation_RunClassConstructor +ReflectionInvocation_RunModuleConstructor +ReflectionInvocation_SizeOf +ReflectionSerialization_GetCreateUninitializedObjectInfo +ResolveVirtualFunctionPointer +RuntimeAssembly_GetIsCollectible +RuntimeAssembly_GetIsDynamic +RuntimeAssembly_GetManifestModule +RuntimeAssembly_GetTokenInternal +RuntimeFieldHandle_AcquiresContextFromThis +RuntimeFieldHandle_GetApproxDeclaringMethodTable +RuntimeFieldHandle_GetAttributes +RuntimeFieldHandle_GetEnCFieldAddr +RuntimeFieldHandle_GetFieldDataReference +RuntimeFieldHandle_GetInstanceFieldOffset +RuntimeFieldHandle_GetLoaderAllocatorInternal +RuntimeFieldHandle_GetRVAFieldInfo +RuntimeFieldHandle_GetStaticFieldAddress +RuntimeFieldHandle_GetStaticFieldForGenericType +RuntimeFieldHandle_GetToken +RuntimeFieldHandle_GetUtf8NameInternal +RuntimeFieldHandle_GetValue +RuntimeFieldHandle_GetValueDirect +RuntimeFieldHandle_IsFastPathSupported +RuntimeFieldHandle_SetValue +RuntimeFieldHandle_SetValueDirect +RuntimeHelpers_ContentEquals +RuntimeHelpers_GetTailCallArgBuffer +RuntimeHelpers_GetTailCallInfo +RuntimeHelpers_TryEnsureSufficientExecutionStack +RuntimeHelpers_TryGetHashCode +RuntimeMethodHandle_ConstructInstantiation +RuntimeMethodHandle_Destroy +RuntimeMethodHandle_GetAttributes +RuntimeMethodHandle_GetDiagnosticCodeStart +RuntimeMethodHandle_GetFunctionPointer +RuntimeMethodHandle_GetGenericParameterCount +RuntimeMethodHandle_GetImplAttributes +RuntimeMethodHandle_GetLoaderAllocatorInternal +RuntimeMethodHandle_GetMethodBody +RuntimeMethodHandle_GetMethodDef +RuntimeMethodHandle_GetMethodFromCanonical +RuntimeMethodHandle_GetMethodInstantiation +RuntimeMethodHandle_GetMethodTable +RuntimeMethodHandle_GetResolver +RuntimeMethodHandle_GetSlot +RuntimeMethodHandle_GetStubIfNeededInternal +RuntimeMethodHandle_GetStubIfNeededSlow +RuntimeMethodHandle_GetTypicalMethodDefinition +RuntimeMethodHandle_GetUtf8NameInternal +RuntimeMethodHandle_GetVirtualFunctionPointer +RuntimeMethodHandle_HasMethodInstantiation +RuntimeMethodHandle_IsAsyncMethod +RuntimeMethodHandle_IsCAVisibleFromDecoratedType +RuntimeMethodHandle_IsCollectible +RuntimeMethodHandle_IsConstructor +RuntimeMethodHandle_IsDynamicMethod +RuntimeMethodHandle_IsGenericMethodDefinition +RuntimeMethodHandle_IsTypicalMethodDefinition +RuntimeMethodHandle_StripMethodInstantiation +RuntimeModule_GetFullyQualifiedName +RuntimeModule_GetScopeName +RuntimeModule_GetTypes +RuntimeTypeHandle_AllocateTypeAssociatedMemory +RuntimeTypeHandle_AllocateTypeAssociatedMemoryAligned +RuntimeTypeHandle_CompareCanonicalHandles +RuntimeTypeHandle_ConstructName +RuntimeTypeHandle_ContainsGenericVariables +RuntimeTypeHandle_CreateInstanceForAnotherGenericParameter +RuntimeTypeHandle_GetActivationInfo +RuntimeTypeHandle_GetArgumentTypesFromFunctionPointer +RuntimeTypeHandle_GetArrayRank +RuntimeTypeHandle_GetAssemblyIfExists +RuntimeTypeHandle_GetAssemblySlow +RuntimeTypeHandle_GetAttributes +RuntimeTypeHandle_GetConstraints +RuntimeTypeHandle_GetDeclaringMethodForGenericParameter +RuntimeTypeHandle_GetDeclaringTypeHandle +RuntimeTypeHandle_GetDeclaringTypeHandleForGenericVariable +RuntimeTypeHandle_GetElementTypeHandle +RuntimeTypeHandle_GetFields +RuntimeTypeHandle_GetFirstIntroducedMethod +RuntimeTypeHandle_GetGenericTypeDefinition +RuntimeTypeHandle_GetGenericVariableIndex +RuntimeTypeHandle_GetInstantiation +RuntimeTypeHandle_GetInterfaceMethodImplementation +RuntimeTypeHandle_GetInterfaces +RuntimeTypeHandle_GetMethodAt +RuntimeTypeHandle_GetModuleIfExists +RuntimeTypeHandle_GetModuleSlow +RuntimeTypeHandle_GetNextIntroducedMethod +RuntimeTypeHandle_GetNumVirtuals +RuntimeTypeHandle_GetNumVirtualsAndStaticVirtuals +RuntimeTypeHandle_GetRuntimeTypeFromHandleSlow +RuntimeTypeHandle_GetToken +RuntimeTypeHandle_GetUtf8NameInternal +RuntimeTypeHandle_Instantiate +RuntimeTypeHandle_InternalAlloc +RuntimeTypeHandle_InternalAllocNoChecks +RuntimeTypeHandle_InternalAllocNoChecks_FastPath +RuntimeTypeHandle_IsGenericVariable +RuntimeTypeHandle_IsUnmanagedFunctionPointer +RuntimeTypeHandle_IsVisible +RuntimeTypeHandle_MakeArray +RuntimeTypeHandle_MakeByRef +RuntimeTypeHandle_MakeFunctionPointer +RuntimeTypeHandle_MakePointer +RuntimeTypeHandle_MakeSZArray +RuntimeTypeHandle_RegisterCollectibleTypeDependency +RuntimeTypeHandle_SatisfiesConstraints +RuntimeTypeHandle_VerifyInterfaceIsImplemented +SfiInit +SfiNext +Signature_AreEqual +Signature_GetCallingConventionFromFunctionPointerAtOffsetInternal +Signature_GetCustomModifiersAtOffset +Signature_GetParameterOffsetInternal +Signature_GetTypeParameterOffsetInternal +Signature_Init +StackFrame_GetMethodDescFromNativeIP +StackTrace_GetStackFramesInternal +Stream_HasOverriddenSlow +String_Intern +String_IsInterned +StubHelpers_ClearLastError +StubHelpers_CreateCustomMarshaler +StubHelpers_CreateLayoutClassMarshalStubs +StubHelpers_LogPinnedArgument +StubHelpers_MulticastDebuggerTraceHelper +StubHelpers_SetLastError +StubHelpers_ThrowInteropException +StubHelpers_ThrowInteropParamException +StubHelpers_ValidateByref +StubHelpers_ValidateObject +SystemNative_Accept +SystemNative_Access +SystemNative_AlignedAlloc +SystemNative_AlignedFree +SystemNative_AlignedRealloc +SystemNative_Bind +SystemNative_Calloc +SystemNative_CanGetHiddenFlag +SystemNative_ChDir +SystemNative_ChMod +SystemNative_Close +SystemNative_CloseDir +SystemNative_Connect +SystemNative_Connectx +SystemNative_ConvertErrorPalToPlatform +SystemNative_ConvertErrorPlatformToPal +SystemNative_CopyFile +SystemNative_Disconnect +SystemNative_FAllocate +SystemNative_FChMod +SystemNative_FChflags +SystemNative_FLock +SystemNative_FStat +SystemNative_FSync +SystemNative_FTruncate +SystemNative_FUTimens +SystemNative_FcntlGetFD +SystemNative_FcntlGetIsNonBlocking +SystemNative_FcntlSetFD +SystemNative_FileSystemSupportsLocking +SystemNative_Free +SystemNative_FreeHostEntry +SystemNative_FreeLibrary +SystemNative_GetAddressFamily +SystemNative_GetAtOutOfBandMark +SystemNative_GetBytesAvailable +SystemNative_GetCommandLine +SystemNative_GetControlMessageBufferSize +SystemNative_GetCpuUtilization +SystemNative_GetCryptographicallySecureRandomBytes +SystemNative_GetCwd +SystemNative_GetDefaultSearchOrderPseudoHandle +SystemNative_GetErrNo +SystemNative_GetHostEntryForName +SystemNative_GetIPv4Address +SystemNative_GetIPv4MulticastOption +SystemNative_GetIPv6Address +SystemNative_GetIPv6MulticastOption +SystemNative_GetLingerOption +SystemNative_GetLoadLibraryError +SystemNative_GetLowResolutionTimestamp +SystemNative_GetMaximumAddressSize +SystemNative_GetNonCryptographicallySecureRandomBytes +SystemNative_GetPeerName +SystemNative_GetPort +SystemNative_GetProcAddress +SystemNative_GetRawSockOpt +SystemNative_GetSockName +SystemNative_GetSockOpt +SystemNative_GetSocketAddressSizes +SystemNative_GetSocketErrorOption +SystemNative_GetSocketType +SystemNative_GetSystemTimeAsTicks +SystemNative_GetTimeZoneData +SystemNative_GetTimestamp +SystemNative_GetWasiSocketDescriptor +SystemNative_IsMemfdSupported +SystemNative_LChflags +SystemNative_LChflagsCanSetHiddenFlag +SystemNative_LSeek +SystemNative_LStat +SystemNative_Link +SystemNative_Listen +SystemNative_LoadLibrary +SystemNative_LockFileRegion +SystemNative_Log +SystemNative_LogError +SystemNative_MAdvise +SystemNative_MMap +SystemNative_MSync +SystemNative_MUnmap +SystemNative_Malloc +SystemNative_MemfdCreate +SystemNative_MkDir +SystemNative_MkdTemp +SystemNative_MksTemps +SystemNative_Open +SystemNative_OpenDir +SystemNative_PRead +SystemNative_PReadV +SystemNative_PWrite +SystemNative_PWriteV +SystemNative_Pipe +SystemNative_PlatformSupportsDualModeIPv4PacketInfo +SystemNative_Poll +SystemNative_PosixFAdvise +SystemNative_Read +SystemNative_ReadDir +SystemNative_ReadFromNonblocking +SystemNative_ReadLink +SystemNative_ReadV +SystemNative_Realloc +SystemNative_Receive +SystemNative_ReceiveMessage +SystemNative_Rename +SystemNative_RmDir +SystemNative_Send +SystemNative_SendFile +SystemNative_SendMessage +SystemNative_SetAddressFamily +SystemNative_SetErrNo +SystemNative_SetIPv4Address +SystemNative_SetIPv4MulticastOption +SystemNative_SetIPv6Address +SystemNative_SetIPv6MulticastOption +SystemNative_SetLingerOption +SystemNative_SetPort +SystemNative_SetRawSockOpt +SystemNative_SetReceiveTimeout +SystemNative_SetSendTimeout +SystemNative_SetSockOpt +SystemNative_ShmOpen +SystemNative_ShmUnlink +SystemNative_Shutdown +SystemNative_Socket +SystemNative_Stat +SystemNative_StrErrorR +SystemNative_SymLink +SystemNative_SysConf +SystemNative_SysLog +SystemNative_ThreadSleep +SystemNative_TryGetIPPacketInformation +SystemNative_UTimensat +SystemNative_Unlink +SystemNative_WasiSubscribeSocketPollable +SystemNative_Write +SystemNative_WriteToNonblocking +SystemNative_WriteV +TailCallHelp_AllocTailCallArgBufferInternal +ThreadNative_Abort +ThreadNative_GetQCallSpecialException +ThreadNative_GetThreadState +ThreadNative_ResetAbort +ThrowInvalidCastException +TypeBuilder_AddInterfaceImpl +TypeBuilder_DefineCustomAttribute +TypeBuilder_DefineEvent +TypeBuilder_DefineField +TypeBuilder_DefineGenericParam +TypeBuilder_DefineMethod +TypeBuilder_DefineMethodImpl +TypeBuilder_DefineMethodSemantics +TypeBuilder_DefineMethodSpec +TypeBuilder_DefineProperty +TypeBuilder_DefineType +TypeBuilder_GetTokenFromSig +TypeBuilder_SetClassLayout +TypeBuilder_SetConstantValue +TypeBuilder_SetFieldLayoutOffset +TypeBuilder_SetMethodIL +TypeBuilder_SetMethodImpl +TypeBuilder_SetPInvokeData +TypeBuilder_SetParamInfo +TypeBuilder_SetParentType +TypeBuilder_TermCreateClass +TypeHandle_CanCastTo_NoCacheLookup +TypeHandle_GetCorElementType +TypeMapLazyDictionary_FindPrecachedExternalTypeMapEntry +TypeMapLazyDictionary_FindPrecachedProxyTypeMapEntry +TypeMapLazyDictionary_ProcessAttributes +UnsafeAccessors_ResolveGenericParamToTypeHandle +ValueType_GetHashCodeStrategy +VersionResilientHashCode_TypeHashCode +WasiFinalizer_RunWorker +WasiFinalizer_TryClearPending +ZDICT_trainFromBuffer +ZSTD_CCtx_refCDict +ZSTD_CCtx_refPrefix +ZSTD_CCtx_reset +ZSTD_CCtx_setParameter +ZSTD_CCtx_setPledgedSrcSize +ZSTD_DCtx_refDDict +ZSTD_DCtx_refPrefix +ZSTD_DCtx_reset +ZSTD_DCtx_setParameter +ZSTD_compress2 +ZSTD_compressBound +ZSTD_compressStream2 +ZSTD_createCCtx +ZSTD_createCDict_byReference +ZSTD_createDCtx +ZSTD_createDDict_byReference +ZSTD_decompress +ZSTD_decompressBound +ZSTD_decompressStream +ZSTD_decompress_usingDDict +ZSTD_defaultCLevel +ZSTD_freeCCtx +ZSTD_freeCDict +ZSTD_freeDCtx +ZSTD_freeDDict +ZSTD_getErrorName +ZSTD_isError +ZSTD_maxCLevel +ZSTD_minCLevel +memmove +memset diff --git a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets index 13b9359f95f294..c6085ae9268cdb 100644 --- a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets +++ b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets @@ -210,7 +210,7 @@ NativeLibrary items are converted to NativeFileReference items later in the flow (in _CoreCLRPrepareForNativeBuild) so we have to inspect both here. --> true - + true @@ -803,7 +804,7 @@ - + @@ -875,6 +876,18 @@ + + + + + + + <_EmccExportedFunctionDistinct Include="@(EmccExportedFunction->Distinct())" /> + + + <_EmccExportedFunctionDistinct Remove="@(_EmccExportedFunctionDistinct)" /> + + <_EmccExportedRuntimeMethods>"[BROWSER_HOST,@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]" <_EmccIncomingModuleJSAPIs>"[@(_EmccIncomingModuleJSAPI -> '%27%(Identity)%27', ',')]" diff --git a/src/mono/wasi/build/WasiApp.CoreCLR.targets b/src/mono/wasi/build/WasiApp.CoreCLR.targets index ac30371067fe44..d65cc13c6c52a0 100644 --- a/src/mono/wasi/build/WasiApp.CoreCLR.targets +++ b/src/mono/wasi/build/WasiApp.CoreCLR.targets @@ -311,7 +311,7 @@ - + + + + + + <_WasiRelinkLinkFlags Include="@(_WasiDirectPInvokeExport->'-Wl,--export-if-defined=%(Identity)')" /> <_WasiRelinkLinkFlags Include="--target=wasm32-unknown-wasip2" /> <_WasiRelinkLinkFlags Include="$(_WasiRelinkOptFlag)" /> <_WasiRelinkLinkFlags Include="-DNDEBUG" Condition="'$(Configuration)' != 'Debug'" /> diff --git a/src/native/corehost/browserhost/browserhost.proj b/src/native/corehost/browserhost/browserhost.proj index 91d097888b3189..e5037ed0cf7f86 100644 --- a/src/native/corehost/browserhost/browserhost.proj +++ b/src/native/corehost/browserhost/browserhost.proj @@ -18,6 +18,8 @@ $(BrowserHostInitialHeapSize) $(BrowserHostMaximumHeapSize) $(BrowserHostStackSize) + + <_WasmCallHelpersExportsPath>$(RepoRoot)src/coreclr/vm/wasm/browser/callhelpers-exports.txt true - + true + diff --git a/src/mono/wasi/build/WasiApp.CoreCLR.targets b/src/mono/wasi/build/WasiApp.CoreCLR.targets index d65cc13c6c52a0..fb85cd2dcfd511 100644 --- a/src/mono/wasi/build/WasiApp.CoreCLR.targets +++ b/src/mono/wasi/build/WasiApp.CoreCLR.targets @@ -441,7 +441,7 @@ 65537 - + diff --git a/src/native/corehost/browserhost/browserhost.proj b/src/native/corehost/browserhost/browserhost.proj index e5037ed0cf7f86..04b4fd946d241d 100644 --- a/src/native/corehost/browserhost/browserhost.proj +++ b/src/native/corehost/browserhost/browserhost.proj @@ -18,7 +18,7 @@ $(BrowserHostInitialHeapSize) $(BrowserHostMaximumHeapSize) $(BrowserHostStackSize) - + <_WasmCallHelpersExportsPath>$(RepoRoot)src/coreclr/vm/wasm/browser/callhelpers-exports.txt diff --git a/src/native/libs/Common/JavaScript/host/assets.ts b/src/native/libs/Common/JavaScript/host/assets.ts index 52e1e754429f3d..1b8f15d70e2466 100644 --- a/src/native/libs/Common/JavaScript/host/assets.ts +++ b/src/native/libs/Common/JavaScript/host/assets.ts @@ -152,7 +152,7 @@ function buildWebcilImports(memory: WebAssembly.Memory, payloadPtr: number, tabl webcilImports.__async_continuation = asyncContinuation as unknown as WebAssembly.ImportValue; webcilImports.__indirect_function_table = _ems_.wasmTable; webcilImports.__table_base = new WebAssembly.Global({ value: "i32", mutable: false }, tableStartIndex); - // R2R images import direct P/Invoke and FCall targets as functions named by their native symbol, which + // R2R images import QCall and FCall targets as functions named by their native symbol, which // the runtime module exports. Resolve them on demand so streaming instantiation doesn't need the import list. return new Proxy(webcilImports, { get: (target, name) => { From 9f31c07af84fa9a2054efdc61458eae0c8c2035a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 1 Dec 2026 20:01:51 -0800 Subject: [PATCH 4/9] Use plain WASM imports for R2R QCall/FCall/WasmImportLinkage targets Remove the lazy-resolution Proxy import objects and throw-on-call stubs. The hosts now pass the runtime module's exports (webcil) and imports (WasmImportLinkage modules) directly, so missing imports fail at instantiation like any WASM import. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/coreclr/hosts/corerun/wasm/libCorerun.js | 33 +++--------- .../libs/Common/JavaScript/host/assets.ts | 54 ++----------------- 2 files changed, 12 insertions(+), 75 deletions(-) diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index 9b96c03edd9dad..cc3a7f04df3e22 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -268,7 +268,9 @@ function libCoreRunFactory() { throw new Error("__async_continuation was not preserved by the linker or optimizer"); } payloadPtr = HEAPU32[ptrPtr >>> 2 >>> 0]; + // QCall and FCall targets are imported by their native symbol, which the runtime module exports. const webcilImports = { + ...wasmExports, memory: wasmMemory, __stack_pointer: wasmExports.__stack_pointer, __coreclr_wasm_rtlrestorecontext_tag: wasmExports.__coreclr_wasm_rtlrestorecontext_tag, @@ -278,33 +280,12 @@ function libCoreRunFactory() { // Runtime-async continuation return value, shared with the runtime module. __async_continuation: wasmExports.__async_continuation }; - // QCall and FCall targets are imported by their native symbol, which the runtime - // module exports. [WasmImportLinkage] P/Invoke targets are imported from the P/Invoke's own module - // and resolve from the runtime module's imports. A missing function fails when called, matching - // lazy P/Invoke binding. + // [WasmImportLinkage] P/Invoke targets are imported from the P/Invoke's own module, which the + // runtime module also imports. Emscripten supplies the same object for "env" and "wasi_snapshot_preview1". const imports = { webcil: webcilImports }; - for (const imp of WebAssembly.Module.imports(wasmModule)) { - if (imp.kind !== "function" || (imp.module === "webcil" && imp.name in webcilImports)) { - continue; - } - const importModule = imp.module; - const name = imp.name; - if (importModule === "webcil") { - webcilImports[name] = typeof (wasmExports[name]) === "function" - ? wasmExports[name] - : () => { throw new Error(`Native symbol '${name}' imported by a ReadyToRun image is not exported by the runtime module`); }; - continue; - } - // Emscripten supplies the same import object for the "env" and "wasi_snapshot_preview1" modules. - const provided = (importModule === "env" || importModule === "wasi_snapshot_preview1") && typeof (wasmImports) !== "undefined" - ? wasmImports[name] - : undefined; - if (!imports[importModule]) { - imports[importModule] = {}; - } - imports[importModule][name] = typeof (provided) === "function" - ? provided - : () => { throw new Error(`Function '${importModule}.${name}' imported by a ReadyToRun image is not provided to the runtime module`); }; + if (typeof (wasmImports) !== "undefined") { + imports.env = wasmImports; + imports.wasi_snapshot_preview1 = wasmImports; } wasmInstance = new WebAssembly.Instance(wasmModule, imports); } catch (e) { diff --git a/src/native/libs/Common/JavaScript/host/assets.ts b/src/native/libs/Common/JavaScript/host/assets.ts index 1b8f15d70e2466..a512e128021b52 100644 --- a/src/native/libs/Common/JavaScript/host/assets.ts +++ b/src/native/libs/Common/JavaScript/host/assets.ts @@ -63,17 +63,10 @@ export async function instantiateWebcilModule(webcilPromise: Promise, try { payloadPtr = allocWebcilPayload(payloadSize); const webcilImports = buildWebcilImports(memory, payloadPtr, tableEntries); - // R2R images import [WasmImportLinkage] P/Invoke targets from the P/Invoke's own module. Resolve them from - // the imports given to the runtime module so streaming instantiation doesn't need the import list. + // R2R images import [WasmImportLinkage] P/Invoke targets from the P/Invoke's own module, which the + // runtime module also imports. const imports: WebAssembly.Imports = tableEntries > 0 - ? new Proxy({ webcil: webcilImports } as WebAssembly.Imports, { - get: (target, module) => { - if (typeof module !== "string" || module in target) { - return Reflect.get(target, module); - } - return buildModuleImports(module); - }, - }) + ? { ...runtimeModuleImports, webcil: webcilImports } : { webcil: webcilImports }; let instance: WebAssembly.Instance; const contentType = res.headers && res.headers.get ? res.headers.get("Content-Type") : undefined; @@ -153,49 +146,12 @@ function buildWebcilImports(memory: WebAssembly.Memory, payloadPtr: number, tabl webcilImports.__indirect_function_table = _ems_.wasmTable; webcilImports.__table_base = new WebAssembly.Global({ value: "i32", mutable: false }, tableStartIndex); // R2R images import QCall and FCall targets as functions named by their native symbol, which - // the runtime module exports. Resolve them on demand so streaming instantiation doesn't need the import list. - return new Proxy(webcilImports, { - get: (target, name) => { - if (typeof name !== "string" || name in target) { - return Reflect.get(target, name); - } - return resolveNativeImport(name); - }, - }); + // the runtime module exports. + return { ...(_ems_.wasmExports as Record), ...webcilImports }; } return webcilImports; } -// A symbol the runtime module doesn't export fails when called rather than when the image loads, matching -// the lazy binding of P/Invokes the runtime resolves itself. -function resolveNativeImport(name: string): WebAssembly.ImportValue { - const exported = (_ems_.wasmExports as Record | undefined)?.[name]; - if (typeof exported === "function") { - return exported; - } - return (() => { - throw new Error(`Native symbol '${name}' imported by a ReadyToRun image is not exported by the runtime module`); - }) as unknown as WebAssembly.ImportValue; -} - -function buildModuleImports(module: string): Record { - const moduleImports = runtimeModuleImports?.[module] as Record | undefined; - return new Proxy({}, { - get: (_target, name) => { - if (typeof name !== "string") { - return undefined; - } - const value = moduleImports?.[name]; - if (typeof value === "function") { - return value; - } - return (() => { - throw new Error(`Function '${module}.${name}' imported by a ReadyToRun image is not provided to the runtime module`); - }) as unknown as WebAssembly.ImportValue; - }, - }); -} - // Records the table base for R2R images and registers the loaded image for // BrowserHost_ExternalAssemblyProbe. The engine has already installed the payload (and table slice) // from the module's active segments during instantiation. From f2541453876a16ce1cd0f08db6981be2e084501c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 1 Dec 2026 20:51:21 -0800 Subject: [PATCH 5/9] Pass corerun QCall export lists through files The browser and WASI corerun links listed every QCall export inline, which exceeds the Windows command-line limit. Emscripten reads EXPORTED_FUNCTIONS from a file and clang reads the WASI export options from a response file. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/coreclr/hosts/corerun/CMakeLists.txt | 38 +++++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 0334fd745fbeb2..69882613860cd2 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -124,10 +124,18 @@ else() list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sNODERAWFS=1 -lnodefs.js) endif() # R2R images import QCall targets by native symbol, so the module has to export them. + # The list is too long for a command line, so emscripten reads it from a file. set(CORERUN_DIRECT_PINVOKE_EXPORTS_FILE "${CLR_DIR}/vm/wasm/browser/callhelpers-exports.txt") + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") file(STRINGS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}" CORERUN_DIRECT_PINVOKE_EXPORTS) list(TRANSFORM CORERUN_DIRECT_PINVOKE_EXPORTS PREPEND "_") - list(JOIN CORERUN_DIRECT_PINVOKE_EXPORTS "," CORERUN_DIRECT_PINVOKE_EXPORTS) + string(REPLACE "," ";" CORERUN_EXPORTED_FUNCTIONS "_main,${CMAKE_EMCC_EXPORTED_FUNCTIONS}") + list(APPEND CORERUN_EXPORTED_FUNCTIONS ${CORERUN_DIRECT_PINVOKE_EXPORTS}) + list(REMOVE_ITEM CORERUN_EXPORTED_FUNCTIONS "") + list(JOIN CORERUN_EXPORTED_FUNCTIONS "\n" CORERUN_EXPORTED_FUNCTIONS) + set(CORERUN_EXPORTED_FUNCTIONS_NAME "corerun-exported-functions.txt") + set(CORERUN_EXPORTED_FUNCTIONS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CORERUN_EXPORTED_FUNCTIONS_NAME}") + file(CONFIGURE OUTPUT "${CORERUN_EXPORTED_FUNCTIONS_FILE}" CONTENT "${CORERUN_EXPORTED_FUNCTIONS}\n" @ONLY) list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sINITIAL_MEMORY=134217728 -sMAXIMUM_MEMORY=4294967296 @@ -139,23 +147,25 @@ else() -sEXPORT_ES6=1 -sEXIT_RUNTIME=1 -sEXPORTED_RUNTIME_METHODS=CORERUN,ENV,${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS} - -sEXPORTED_FUNCTIONS=_main,${CMAKE_EMCC_EXPORTED_FUNCTIONS},${CORERUN_DIRECT_PINVOKE_EXPORTS} -sEXPORT_NAME=createDotnetRuntime -sENVIRONMENT=node,shell,web -lexports.js -Wl,--error-limit=0) - target_link_options(corerun PRIVATE ${CORERUN_BROWSER_LINK_OPTIONS}) - set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") + target_link_options(corerun PRIVATE + ${CORERUN_BROWSER_LINK_OPTIONS} + "-sEXPORTED_FUNCTIONS=@${CORERUN_EXPORTED_FUNCTIONS_FILE}") + set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_EXPORTED_FUNCTIONS_FILE}") # Export everything a runtime test needs to re-link corerun with its # own native library and generated call tables. corerun_kit_export( COMPONENT hosts SOURCES ${CORERUN_SOURCES} - LINK_OPTIONS ${CORERUN_BROWSER_LINK_OPTIONS} + LINK_OPTIONS ${CORERUN_BROWSER_LINK_OPTIONS} "-sEXPORTED_FUNCTIONS=@${CORERUN_EXPORTED_FUNCTIONS_NAME}" COMPILE_OPTIONS -fwasm-exceptions -sWASM_LEGACY_EXCEPTIONS=0 -msimd128 JS_LIBRARIES "${JS_SYSTEM_NATIVE_BROWSER}" "${JS_SYSTEM_BROWSER_UTILS}" "${JS_CORE_RUN}" - EXTERN_POST_JS "${JS_CORE_RUN_EXTPOST}") + EXTERN_POST_JS "${JS_CORE_RUN_EXTPOST}" + EXTRA_FILES "${CORERUN_EXPORTED_FUNCTIONS_FILE}") elseif (CLR_CMAKE_TARGET_WASI) # wasm-component-ld wraps wasi:io@0.2.x imports into the WASI # component-model; the default lld produces a plain core module @@ -173,11 +183,16 @@ else() -Wl,--export=__async_continuation) # R2R images import QCall targets by native symbol, so the module has to export them. + # The list is too long for a command line, so the linker reads it from a response file. set(CORERUN_DIRECT_PINVOKE_EXPORTS_FILE "${CLR_DIR}/vm/wasm/wasi/callhelpers-exports.txt") + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") file(STRINGS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}" CORERUN_DIRECT_PINVOKE_EXPORTS) list(TRANSFORM CORERUN_DIRECT_PINVOKE_EXPORTS PREPEND "-Wl,--export-if-defined=") - list(APPEND CORERUN_WASI_LINK_OPTIONS ${CORERUN_DIRECT_PINVOKE_EXPORTS}) - set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") + list(JOIN CORERUN_DIRECT_PINVOKE_EXPORTS "\n" CORERUN_DIRECT_PINVOKE_EXPORTS) + set(CORERUN_EXPORTS_RSP_NAME "corerun-exports.rsp") + set(CORERUN_EXPORTS_RSP "${CMAKE_CURRENT_BINARY_DIR}/${CORERUN_EXPORTS_RSP_NAME}") + file(CONFIGURE OUTPUT "${CORERUN_EXPORTS_RSP}" CONTENT "${CORERUN_DIRECT_PINVOKE_EXPORTS}\n" @ONLY) + set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_EXPORTS_RSP}") if (CORERUN_WASI_COMPOSITE_R2R) list(APPEND CORERUN_WASI_LINK_OPTIONS @@ -192,7 +207,8 @@ else() target_link_options(corerun PRIVATE "-fuse-ld=${_wasi_sdk_bin}/wasm-component-ld" "-Wl,--component-type,${_wasi_http_world_wit}" - ${CORERUN_WASI_LINK_OPTIONS}) + ${CORERUN_WASI_LINK_OPTIONS} + "@${CORERUN_EXPORTS_RSP}") # Export everything a runtime test needs to re-link corerun with its # own native library and generated call tables. The kit carries the @@ -203,9 +219,9 @@ else() COMPONENT hosts WHOLE_ARCHIVE_HOST SOURCES ${CORERUN_SOURCES} - LINK_OPTIONS ${CORERUN_WASI_LINK_OPTIONS} "-Wl,--component-type,${_wasi_http_world_wit_name}" + LINK_OPTIONS ${CORERUN_WASI_LINK_OPTIONS} "-Wl,--component-type,${_wasi_http_world_wit_name}" "@${CORERUN_EXPORTS_RSP_NAME}" COMPILE_OPTIONS -fwasm-exceptions -mllvm -wasm-use-legacy-eh=false - EXTRA_FILES "${_wasi_http_world_wit}") + EXTRA_FILES "${_wasi_http_world_wit}" "${CORERUN_EXPORTS_RSP}") endif() if (CORERUN_IN_BROWSER) From 805590bdd281e3c05286164ebaace16c76f24dcb Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 1 Dec 2026 21:26:02 -0800 Subject: [PATCH 6/9] Fix WASM R2R direct QCall import mismatches - Link Node corerun with WASM_BIGINT so QCall exports keep i64 signatures. - Resolve JS-implemented QCalls from the runtime's env imports. - Match FreeGCHandleForTypeHandle's managed return type to its native void. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../src/System/RuntimeHandles.cs | 6 +++--- src/coreclr/hosts/corerun/CMakeLists.txt | 11 +++-------- src/coreclr/hosts/corerun/wasm/libCorerun.js | 4 +++- src/native/libs/Common/JavaScript/host/assets.ts | 8 ++++++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs index 752b63657095d8..dd33733a1d24db 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs @@ -602,12 +602,12 @@ internal IntPtr GetGCHandle(GCHandleType type) [ErrorHandler(typeof(QCallExceptionStatusMarshaller), ErrorLocation.HiddenLastParameter)] [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "QCall_FreeGCHandleForTypeHandle")] - private static partial IntPtr FreeGCHandle(QCallTypeHandle typeHandle, IntPtr objHandle); + private static partial void FreeGCHandle(QCallTypeHandle typeHandle, IntPtr objHandle); - internal IntPtr FreeGCHandle(IntPtr objHandle) + internal void FreeGCHandle(IntPtr objHandle) { RuntimeTypeHandle nativeHandle = GetNativeHandle(); - return FreeGCHandle(new QCallTypeHandle(ref nativeHandle), objHandle); + FreeGCHandle(new QCallTypeHandle(ref nativeHandle), objHandle); } [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 69882613860cd2..53705b4ab67b80 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -105,21 +105,16 @@ else() LINK_DEPENDS "${JS_CORE_RUN};${JS_CORE_RUN_EXTPOST};${JS_SYSTEM_NATIVE_BROWSER};${JS_SYSTEM_BROWSER_UTILS};" LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --js-library ${JS_CORE_RUN} --extern-post-js ${JS_CORE_RUN_EXTPOST}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + # R2R code imports QCalls directly from corerun, so exports must keep their + # natural i64 signatures rather than being legalized into i32 pairs. + list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sWASM_BIGINT=1) if (CORERUN_IN_BROWSER) - list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sWASM_BIGINT=1) # Include the virtual file system data for the browser scenario. set(WASM_PRELOAD_DIR "${CMAKE_INSTALL_PREFIX}/IL") if (EXISTS "${WASM_PRELOAD_DIR}") list(APPEND CORERUN_BROWSER_LINK_OPTIONS --preload-file ${WASM_PRELOAD_DIR}@/) endif() else() - # Node.js doesn't have good support for WASM_BIGINT, so disable it for the Node/shell. - list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sWASM_BIGINT=0) - - # remove HEAP64 and HEAPU64 from CMAKE_EMCC_EXPORTED_RUNTIME_METHODS - string(REPLACE "HEAP64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}") - string(REPLACE "HEAPU64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}") - # Add Node.js host file system support. list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sNODERAWFS=1 -lnodefs.js) endif() diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index cc3a7f04df3e22..faec6ebac1e8fe 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -268,8 +268,10 @@ function libCoreRunFactory() { throw new Error("__async_continuation was not preserved by the linker or optimizer"); } payloadPtr = HEAPU32[ptrPtr >>> 2 >>> 0]; - // QCall and FCall targets are imported by their native symbol, which the runtime module exports. + // QCall and FCall targets are imported by their native symbol, which the runtime module exports, + // or, for JS-implemented QCalls, imports from "env". const webcilImports = { + ...(typeof (wasmImports) !== "undefined" ? wasmImports : {}), ...wasmExports, memory: wasmMemory, __stack_pointer: wasmExports.__stack_pointer, diff --git a/src/native/libs/Common/JavaScript/host/assets.ts b/src/native/libs/Common/JavaScript/host/assets.ts index a512e128021b52..9b9f84288710b1 100644 --- a/src/native/libs/Common/JavaScript/host/assets.ts +++ b/src/native/libs/Common/JavaScript/host/assets.ts @@ -146,8 +146,12 @@ function buildWebcilImports(memory: WebAssembly.Memory, payloadPtr: number, tabl webcilImports.__indirect_function_table = _ems_.wasmTable; webcilImports.__table_base = new WebAssembly.Global({ value: "i32", mutable: false }, tableStartIndex); // R2R images import QCall and FCall targets as functions named by their native symbol, which - // the runtime module exports. - return { ...(_ems_.wasmExports as Record), ...webcilImports }; + // the runtime module exports, or, for JS-implemented QCalls, imports from "env". + return { + ...(runtimeModuleImports?.env as Record | undefined), + ...(_ems_.wasmExports as Record), + ...webcilImports + }; } return webcilImports; } From 0e65ec4984a4d043c2fa4c4b4b798195c4e19b7d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 2 Dec 2026 14:24:57 -0800 Subject: [PATCH 7/9] Restore QCall PInvoke fixups for WASM R2R Remove QCall export plumbing and QCall/FCall-specific Webcil imports while preserving plain WasmImportLinkage imports and configured direct P/Invoke behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/coreclr/hosts/corerun/CMakeLists.txt | 54 +- src/coreclr/hosts/corerun/wasm/libCorerun.js | 4 - .../TestCases/R2RTestSuites.cs | 3 + .../Webcil/WasmImportLinkagePInvoke.cs | 5 + .../WasmArgumentLayoutTests.cs | 7 - .../ReadyToRunCompilationModuleGroupBase.cs | 6 - .../JitInterface/CorInfoImpl.ReadyToRun.cs | 34 +- .../PInvokeTableGenerator.cs | 21 - .../PortableCallHelpersGenerator.cs | 9 - .../vm/wasm/browser/callhelpers-exports.txt | 503 ----------------- .../vm/wasm/generate-coreclr-helpers.md | 5 +- .../vm/wasm/generate-coreclr-helpers.proj | 1 - .../vm/wasm/wasi/callhelpers-exports.txt | 507 ------------------ .../build/BrowserWasmApp.CoreCLR.targets | 15 +- src/mono/wasi/build/WasiApp.CoreCLR.targets | 9 +- .../corehost/browserhost/browserhost.proj | 2 - 16 files changed, 35 insertions(+), 1150 deletions(-) delete mode 100644 src/coreclr/vm/wasm/browser/callhelpers-exports.txt delete mode 100644 src/coreclr/vm/wasm/wasi/callhelpers-exports.txt diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 53705b4ab67b80..54a29890c21c65 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -105,32 +105,24 @@ else() LINK_DEPENDS "${JS_CORE_RUN};${JS_CORE_RUN_EXTPOST};${JS_SYSTEM_NATIVE_BROWSER};${JS_SYSTEM_BROWSER_UTILS};" LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --js-library ${JS_CORE_RUN} --extern-post-js ${JS_CORE_RUN_EXTPOST}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - # R2R code imports QCalls directly from corerun, so exports must keep their - # natural i64 signatures rather than being legalized into i32 pairs. - list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sWASM_BIGINT=1) if (CORERUN_IN_BROWSER) + list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sWASM_BIGINT=1) # Include the virtual file system data for the browser scenario. set(WASM_PRELOAD_DIR "${CMAKE_INSTALL_PREFIX}/IL") if (EXISTS "${WASM_PRELOAD_DIR}") list(APPEND CORERUN_BROWSER_LINK_OPTIONS --preload-file ${WASM_PRELOAD_DIR}@/) endif() else() + # Node.js doesn't have good support for WASM_BIGINT, so disable it for the Node/shell. + list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sWASM_BIGINT=0) + + # remove HEAP64 and HEAPU64 from CMAKE_EMCC_EXPORTED_RUNTIME_METHODS + string(REPLACE "HEAP64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}") + string(REPLACE "HEAPU64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}") + # Add Node.js host file system support. list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sNODERAWFS=1 -lnodefs.js) endif() - # R2R images import QCall targets by native symbol, so the module has to export them. - # The list is too long for a command line, so emscripten reads it from a file. - set(CORERUN_DIRECT_PINVOKE_EXPORTS_FILE "${CLR_DIR}/vm/wasm/browser/callhelpers-exports.txt") - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") - file(STRINGS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}" CORERUN_DIRECT_PINVOKE_EXPORTS) - list(TRANSFORM CORERUN_DIRECT_PINVOKE_EXPORTS PREPEND "_") - string(REPLACE "," ";" CORERUN_EXPORTED_FUNCTIONS "_main,${CMAKE_EMCC_EXPORTED_FUNCTIONS}") - list(APPEND CORERUN_EXPORTED_FUNCTIONS ${CORERUN_DIRECT_PINVOKE_EXPORTS}) - list(REMOVE_ITEM CORERUN_EXPORTED_FUNCTIONS "") - list(JOIN CORERUN_EXPORTED_FUNCTIONS "\n" CORERUN_EXPORTED_FUNCTIONS) - set(CORERUN_EXPORTED_FUNCTIONS_NAME "corerun-exported-functions.txt") - set(CORERUN_EXPORTED_FUNCTIONS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CORERUN_EXPORTED_FUNCTIONS_NAME}") - file(CONFIGURE OUTPUT "${CORERUN_EXPORTED_FUNCTIONS_FILE}" CONTENT "${CORERUN_EXPORTED_FUNCTIONS}\n" @ONLY) list(APPEND CORERUN_BROWSER_LINK_OPTIONS -sINITIAL_MEMORY=134217728 -sMAXIMUM_MEMORY=4294967296 @@ -142,25 +134,22 @@ else() -sEXPORT_ES6=1 -sEXIT_RUNTIME=1 -sEXPORTED_RUNTIME_METHODS=CORERUN,ENV,${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS} + -sEXPORTED_FUNCTIONS=_main,${CMAKE_EMCC_EXPORTED_FUNCTIONS} -sEXPORT_NAME=createDotnetRuntime -sENVIRONMENT=node,shell,web -lexports.js -Wl,--error-limit=0) - target_link_options(corerun PRIVATE - ${CORERUN_BROWSER_LINK_OPTIONS} - "-sEXPORTED_FUNCTIONS=@${CORERUN_EXPORTED_FUNCTIONS_FILE}") - set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_EXPORTED_FUNCTIONS_FILE}") + target_link_options(corerun PRIVATE ${CORERUN_BROWSER_LINK_OPTIONS}) # Export everything a runtime test needs to re-link corerun with its # own native library and generated call tables. corerun_kit_export( COMPONENT hosts SOURCES ${CORERUN_SOURCES} - LINK_OPTIONS ${CORERUN_BROWSER_LINK_OPTIONS} "-sEXPORTED_FUNCTIONS=@${CORERUN_EXPORTED_FUNCTIONS_NAME}" + LINK_OPTIONS ${CORERUN_BROWSER_LINK_OPTIONS} COMPILE_OPTIONS -fwasm-exceptions -sWASM_LEGACY_EXCEPTIONS=0 -msimd128 JS_LIBRARIES "${JS_SYSTEM_NATIVE_BROWSER}" "${JS_SYSTEM_BROWSER_UTILS}" "${JS_CORE_RUN}" - EXTERN_POST_JS "${JS_CORE_RUN_EXTPOST}" - EXTRA_FILES "${CORERUN_EXPORTED_FUNCTIONS_FILE}") + EXTERN_POST_JS "${JS_CORE_RUN_EXTPOST}") elseif (CLR_CMAKE_TARGET_WASI) # wasm-component-ld wraps wasi:io@0.2.x imports into the WASI # component-model; the default lld produces a plain core module @@ -177,18 +166,6 @@ else() -Wl,--export=GetDotNetRuntimeContractDescriptor -Wl,--export=__async_continuation) - # R2R images import QCall targets by native symbol, so the module has to export them. - # The list is too long for a command line, so the linker reads it from a response file. - set(CORERUN_DIRECT_PINVOKE_EXPORTS_FILE "${CLR_DIR}/vm/wasm/wasi/callhelpers-exports.txt") - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}") - file(STRINGS "${CORERUN_DIRECT_PINVOKE_EXPORTS_FILE}" CORERUN_DIRECT_PINVOKE_EXPORTS) - list(TRANSFORM CORERUN_DIRECT_PINVOKE_EXPORTS PREPEND "-Wl,--export-if-defined=") - list(JOIN CORERUN_DIRECT_PINVOKE_EXPORTS "\n" CORERUN_DIRECT_PINVOKE_EXPORTS) - set(CORERUN_EXPORTS_RSP_NAME "corerun-exports.rsp") - set(CORERUN_EXPORTS_RSP "${CMAKE_CURRENT_BINARY_DIR}/${CORERUN_EXPORTS_RSP_NAME}") - file(CONFIGURE OUTPUT "${CORERUN_EXPORTS_RSP}" CONTENT "${CORERUN_DIRECT_PINVOKE_EXPORTS}\n" @ONLY) - set_property(TARGET corerun APPEND PROPERTY LINK_DEPENDS "${CORERUN_EXPORTS_RSP}") - if (CORERUN_WASI_COMPOSITE_R2R) list(APPEND CORERUN_WASI_LINK_OPTIONS -Wl,--table-base=${CORERUN_WASI_R2R_TABLE_BASE} @@ -202,8 +179,7 @@ else() target_link_options(corerun PRIVATE "-fuse-ld=${_wasi_sdk_bin}/wasm-component-ld" "-Wl,--component-type,${_wasi_http_world_wit}" - ${CORERUN_WASI_LINK_OPTIONS} - "@${CORERUN_EXPORTS_RSP}") + ${CORERUN_WASI_LINK_OPTIONS}) # Export everything a runtime test needs to re-link corerun with its # own native library and generated call tables. The kit carries the @@ -214,9 +190,9 @@ else() COMPONENT hosts WHOLE_ARCHIVE_HOST SOURCES ${CORERUN_SOURCES} - LINK_OPTIONS ${CORERUN_WASI_LINK_OPTIONS} "-Wl,--component-type,${_wasi_http_world_wit_name}" "@${CORERUN_EXPORTS_RSP_NAME}" + LINK_OPTIONS ${CORERUN_WASI_LINK_OPTIONS} "-Wl,--component-type,${_wasi_http_world_wit_name}" COMPILE_OPTIONS -fwasm-exceptions -mllvm -wasm-use-legacy-eh=false - EXTRA_FILES "${_wasi_http_world_wit}" "${CORERUN_EXPORTS_RSP}") + EXTRA_FILES "${_wasi_http_world_wit}") endif() if (CORERUN_IN_BROWSER) diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index faec6ebac1e8fe..bae4d7463ef254 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -268,11 +268,7 @@ function libCoreRunFactory() { throw new Error("__async_continuation was not preserved by the linker or optimizer"); } payloadPtr = HEAPU32[ptrPtr >>> 2 >>> 0]; - // QCall and FCall targets are imported by their native symbol, which the runtime module exports, - // or, for JS-implemented QCalls, imports from "env". const webcilImports = { - ...(typeof (wasmImports) !== "undefined" ? wasmImports : {}), - ...wasmExports, memory: wasmMemory, __stack_pointer: wasmExports.__stack_pointer, __coreclr_wasm_rtlrestorecontext_tag: wasmExports.__coreclr_wasm_rtlrestorecontext_tag, diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs index 140f1bf0eb8cd5..23819d9c078c50 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs @@ -173,8 +173,11 @@ static void Validate(ReadyToRunReader reader) WasmR2RAssert.GetWasmFunctionImportNames(webcilReader, "test:module/interface@1.0.0")); Assert.DoesNotContain(WasmR2RAssert.GetWasmFunctionImportNames(webcilReader, "webcil"), name => name.Contains("resource.call", StringComparison.Ordinal)); + Assert.DoesNotContain(WasmR2RAssert.GetWasmFunctionImportNames(webcilReader, "webcil"), + name => name.Contains("QCall_Test", StringComparison.Ordinal)); Assert.DoesNotContain(pinvokeTargets, target => target.Contains(".Imported(", StringComparison.Ordinal)); Assert.Contains(pinvokeTargets, target => target.Contains(".NotDirect(", StringComparison.Ordinal)); + Assert.Contains(pinvokeTargets, target => target.Contains(".QCallTarget(", StringComparison.Ordinal)); Assert.True(WasmR2RAssert.WasmIndexSpacesHaveExpectedEntries(webcilReader, out string diagnostic), diagnostic); } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/Webcil/WasmImportLinkagePInvoke.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/Webcil/WasmImportLinkagePInvoke.cs index 38f08e3e850b6e..71d628715eae12 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/Webcil/WasmImportLinkagePInvoke.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/Webcil/WasmImportLinkagePInvoke.cs @@ -15,7 +15,12 @@ public static class WasmImportLinkagePInvoke [DllImport("NotDirect", EntryPoint = "NotDirect_Call")] private static extern int NotDirect(int value); + [DllImport("QCall", EntryPoint = "QCall_Test")] + private static extern int QCallTarget(int value); + public static int CallImported(int value) => Imported(value); public static int CallNotDirect(int value) => NotDirect(value); + + public static int CallQCallTarget(int value) => QCallTarget(value); } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs index a46fab4dec2f27..963bf3b2c548d2 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs @@ -1405,13 +1405,6 @@ public UnsupportedOSPlatformAttribute(string platform) { } Assert.True(repeatExitCode == 0, log.ToString()); Assert.Equal(table, File.ReadAllText(Path.Combine(options.OutputDirectory, "callhelpers-pinvoke.cpp"))); - // R2R images import QCall targets by these names, so the native module must export them. - string[] exports = File.ReadAllLines(Path.Combine(options.OutputDirectory, PortableCallHelpersGenerator.PInvokeExportsFileName)); - Assert.DoesNotContain("Native_Test", exports); - Assert.Single(exports, e => e == "QCall_Test"); - Assert.DoesNotContain("QCall_Unavailable", exports); - Assert.Contains(targetOS == "browser" ? "QCall_memmove" : "memmove", exports); - Assert.Contains(targetOS == "browser" ? "QCall_memset" : "memset", exports); } finally { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs index a84234a2c72d84..ec6012229fad75 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs @@ -116,11 +116,6 @@ public bool IsDirectPInvoke(MethodDesc method) return true; } - if (method.GetPInvokeMethodMetadata().Module == "QCall") - { - return true; - } - if (!_directPInvokes.TryGetDirectEntryPoint(method, out _)) { return false; @@ -143,7 +138,6 @@ private HashSet GetWasmIncompatibleDirectEntryPoints(EcmaModule module) MethodDesc method = module.GetMethod(handle); if (!method.IsPInvoke || method.HasCustomAttribute("System.Runtime.InteropServices", "WasmImportLinkageAttribute") - || method.GetPInvokeMethodMetadata().Module == "QCall" || !_directPInvokes.TryGetDirectEntryPoint(method, out _)) { continue; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index a983cf9ff1d761..9de3e7d70de24b 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -3666,34 +3666,18 @@ private void getAddressOfPInvokeTarget(CORINFO_METHOD_STRUCT_* method, ref CORIN EcmaMethod ecmaMethod = (EcmaMethod)methodDesc; if (_compilation.NodeFactory.Target.IsWasm - && _compilation.CompilationModuleGroup.IsDirectPInvoke(ecmaMethod)) + && _compilation.CompilationModuleGroup.IsDirectPInvoke(ecmaMethod) + && ecmaMethod.HasCustomAttribute("System.Runtime.InteropServices", "WasmImportLinkageAttribute")) { - // QCalls and [WasmImportLinkage] P/Invokes are called through a Wasm function import, without a fixup - // or the generated P/Invoke table. [WasmImportLinkage] targets import the entry point from the - // P/Invoke's module, as the runtime module does; QCalls import the native symbol the runtime module - // exports from the "webcil" module. P/Invokes into configured direct modules use the fixup below. + // [WasmImportLinkage] P/Invokes are ordinary WebAssembly function imports. Other P/Invokes use + // the PInvokeTarget fixup and generated table below. PInvokeMetadata metadata = ecmaMethod.GetPInvokeMethodMetadata(); string entryPoint = metadata.Name ?? ecmaMethod.GetName(); - ExternFunctionSymbolNode target = null; - if (ecmaMethod.HasCustomAttribute("System.Runtime.InteropServices", "WasmImportLinkageAttribute")) - { - target = _compilation.SymbolNodeFactory.GetDirectWasmPInvokeTargetNode(metadata.Module, entryPoint, nativeSignature); - } - else if (metadata.Module == "QCall") - { - target = _compilation.SymbolNodeFactory.GetDirectWasmPInvokeTargetNode( - "webcil", - ILCompiler.PortableCallHelpers.PInvokeTableGenerator.GetQCallSymbolName( - _compilation.NodeFactory.Target.OperatingSystem, entryPoint), - nativeSignature); - } - - if (target is not null) - { - pLookup.addr = (void*)ObjectToHandle(target); - pLookup.accessType = InfoAccessType.IAT_VALUE; - return; - } + ExternFunctionSymbolNode target = _compilation.SymbolNodeFactory.GetDirectWasmPInvokeTargetNode( + metadata.Module, entryPoint, nativeSignature); + pLookup.addr = (void*)ObjectToHandle(target); + pLookup.accessType = InfoAccessType.IAT_VALUE; + return; } ModuleToken moduleToken = new ModuleToken(ecmaMethod.Module, ecmaMethod.Handle); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs index 09f279ba3780d1..da8eb4b3cf6384 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/PortableCallHelpers/PInvokeTableGenerator.cs @@ -20,25 +20,6 @@ namespace ILCompiler.PortableCallHelpers /// internal sealed class PInvokeTableGenerator(InteropLogger log) { - private readonly SortedSet _qcallExports = new(StringComparer.Ordinal); - - /// - /// The native symbols of the QCalls the emitted table binds, which ReadyToRun code imports directly. - /// See . - /// - public IReadOnlyCollection QCallExports => _qcallExports; - - /// - /// The native symbol a QCall binds to, as declared in the generated table. - /// - public static string GetQCallSymbolName(TargetOS targetOS, string entryPoint) - { - if (entryPoint is "memmove" or "memset") - return targetOS == TargetOS.Browser ? $"QCall_{entryPoint}" : entryPoint; - - return FixupSymbolName(entryPoint); - } - public void EmitPInvokeTable(TextWriter w, TargetDetails target, ModuleDesc systemModule, IEnumerable pinvokeModules, List pinvokes, IEnumerable pinvokeModuleLists = null) { var linked = new DirectPInvokeSet(target, pinvokeModules, pinvokeModuleLists ?? []); @@ -317,8 +298,6 @@ private void EmitQCallTable(TextWriter w, TargetDetails target, List generator.EmitPInvokeTable(w, context.Target, context.SystemModule, options.PInvokeModules, pinvokes, options.PInvokeModuleLists)); - // ReadyToRun code imports QCall targets by native symbol, so the native module has to export them. - WriteIfDifferent(Path.Combine(options.OutputDirectory, PInvokeExportsFileName), log, - w => - { - foreach (string symbol in generator.QCallExports) - w.WriteLine(symbol); - }); - WriteIfDifferent(Path.Combine(options.OutputDirectory, ReversePInvokeFileName), log, w => generator.EmitNativeToInterp(w, callbacks)); diff --git a/src/coreclr/vm/wasm/browser/callhelpers-exports.txt b/src/coreclr/vm/wasm/browser/callhelpers-exports.txt deleted file mode 100644 index 0f25ec5116b6ce..00000000000000 --- a/src/coreclr/vm/wasm/browser/callhelpers-exports.txt +++ /dev/null @@ -1,503 +0,0 @@ -AppContext_SetFirstChanceExceptionHandler -AppContext_TryGetHostPropertyValue -AppDomain_CreateDynamicAssembly -AppendExceptionStackFrame -Array_CreateInstance -Array_Ctor -Array_GetCorElementTypeOfElementType -Array_GetElementConstructorEntrypoint -AssemblyHandle_GetManifestModuleSlow -AssemblyLoadContext_IsTracingEnabled -AssemblyName_InitializeAssemblySpec -AssemblyNative_ApplyUpdate -AssemblyNative_GetAssemblyFromHandle -AssemblyNative_GetCodeBase -AssemblyNative_GetEntryAssembly -AssemblyNative_GetEntryPoint -AssemblyNative_GetExecutingAssembly -AssemblyNative_GetExportedTypes -AssemblyNative_GetFlags -AssemblyNative_GetForwardedType -AssemblyNative_GetFullName -AssemblyNative_GetHashAlgorithm -AssemblyNative_GetImageRuntimeVersion -AssemblyNative_GetLoadContextForAssembly -AssemblyNative_GetLoadedAssemblies -AssemblyNative_GetLocale -AssemblyNative_GetLocation -AssemblyNative_GetManifestResourceInfo -AssemblyNative_GetManifestResourceNames -AssemblyNative_GetModule -AssemblyNative_GetModules -AssemblyNative_GetPublicKey -AssemblyNative_GetReferencedAssemblies -AssemblyNative_GetResource -AssemblyNative_GetSimpleName -AssemblyNative_GetTypeCore -AssemblyNative_GetTypeCoreIgnoreCase -AssemblyNative_GetVersion -AssemblyNative_InitializeAssemblyLoadContext -AssemblyNative_InternalLoad -AssemblyNative_InternalTryGetRawMetadata -AssemblyNative_IsApplyUpdateSupported -AssemblyNative_LoadFromPath -AssemblyNative_LoadFromStream -AssemblyNative_PrepareForAssemblyLoadContextRelease -AssemblyNative_TraceAssemblyLoadFromResolveHandlerInvoked -AssemblyNative_TraceAssemblyResolveHandlerInvoked -AssemblyNative_TraceResolvingHandlerInvoked -AsyncHelpers_AddContinuationToExInternal -AsyncHelpers_ResumeInterpreterContinuation -Buffer_BulkMoveWithWriteBarrierInternal -CallFilterFunclet -CustomAttribute_ParseAttributeUsageAttribute -DebugDebugger_Break -DebugDebugger_CustomNotification -DebugDebugger_IsLoggingHelper -DebugDebugger_IsManagedDebuggerAttached -DebugDebugger_Launch -DebugDebugger_Log -DebugDebugger_PrepareFuncEvalResult -DebugDebugger_ReadFuncEvalPrimitiveRegister -DebugDebugger_WriteFuncEvalObjectRegister -DebugDebugger_WriteFuncEvalRegister -Delegate_AdjustTarget -Delegate_BindToMethodInfo -Delegate_BindToMethodName -Delegate_Construct -Delegate_CreateMethodInfo -Delegate_GetInvokeMethod -Delegate_GetMethodDesc -Delegate_GetMulticastInvoke -Delegate_GetMulticastInvokeSlow -Delegate_InitializeVirtualCallStub -DependentHandle_InternalAlloc -DependentHandle_InternalAllocWithGCTransition -DependentHandle_InternalFree -DependentHandle_InternalFreeWithGCTransition -DependentHandle_InternalGetDependent -DependentHandle_InternalGetTargetAndDependent -DependentHandle_InternalGetTargetWithDebugValidation -DependentHandle_InternalSetDependent -DependentHandle_InternalSetTargetToNull -EHEnumInitFromStackFrameIterator -EHEnumNext -Enum_GetValuesAndNames -Environment_Exit -Environment_FailFast -Environment_GetEnviron -Environment_GetEnvironmentVariable -Environment_SetEnvironmentVariable -Environment_get_ExitCode -Environment_set_ExitCode -EventPipeInternal_CreateProvider -EventPipeInternal_DefineEvent -EventPipeInternal_DeleteProvider -EventPipeInternal_Disable -EventPipeInternal_Enable -EventPipeInternal_EventActivityIdControl -EventPipeInternal_GetNextEvent -EventPipeInternal_GetProvider -EventPipeInternal_GetSessionInfo -EventPipeInternal_SignalSession -EventPipeInternal_WriteEventData -ExceptionNative_GetFrozenStackTrace -ExceptionNative_GetMessageFromNativeResources -ExceptionNative_GetMethodFromStackTrace -ExceptionNative_ThrowAmbiguousResolutionException -ExceptionNative_ThrowClassAccessException -ExceptionNative_ThrowEntryPointNotFoundException -ExceptionNative_ThrowFieldAccessException -ExceptionNative_ThrowMethodAccessException -Exception_IsImmutableException -Exception_PrepareForForeignExceptionRaise -FileLoadException_GetMessageForHR -GCFrameRegistration_RegisterForGCReporting -GCFrameRegistration_UnregisterForGCReporting -GCHandle_InternalAllocWithGCTransition -GCHandle_InternalCompareExchange -GCHandle_InternalFreeWithGCTransition -GCHandle_InternalGetWithDebugValidation -GCHandle_InternalSet -GCHandle__InternalAlloc -GCHandle__InternalFree -GCInterface_AllocateNewArray -GCInterface_Collect -GCInterface_EnableNoGCRegionCallback -GCInterface_EndNoGCRegion -GCInterface_EnumerateConfigurationValues -GCInterface_GetNextFinalizableObject -GCInterface_GetTotalAllocatedBytesPrecise -GCInterface_GetTotalMemory -GCInterface_ReRegisterForFinalize -GCInterface_RefreshMemoryLimit -GCInterface_RegisterFrozenSegment -GCInterface_StartNoGCRegion -GCInterface_UnregisterFrozenSegment -GCInterface_WaitForFullGCApproach -GCInterface_WaitForFullGCComplete -GCInterface_WaitForPendingFinalizers -GCSettings_GetGCLatencyMode -GCSettings_GetLOHCompactionMode -GCSettings_SetGCLatencyMode -GCSettings_SetLOHCompactionMode -GCSettings_get_IsServerGC -GC_GetAllocatedBytesForCurrentThread -GC_GetCurrentObjSize -GC_GetGCNow -GC_GetGenerationInternal -GC_GetLastGCDuration -GC_GetLastGCStartTime -GC_GetMaxGeneration -GC_GetMemoryInfo -GC_GetSegmentSize -GC_GetTotalAllocatedBytesApproximate -GC_SuppressFinalizeInternal -GC__CancelFullGCNotification -GC__CollectionCount -GC__GetTotalPauseDuration -GC__RegisterForFullGCNotification -GenericHandleWorker -GetCurrentExInfo -GetFileLoadExceptionMessage -GetTypeLoadExceptionMessage -InitClassHelper -Interlocked_CompareExchange32 -Interlocked_CompareExchange32Pointer -Interlocked_CompareExchange64 -Interlocked_CompareExchangeObject -Interlocked_Exchange32 -Interlocked_Exchange64 -Interlocked_ExchangeAdd32 -Interlocked_ExchangeAdd64 -Interlocked_ExchangeObject -Interlocked_MemoryBarrierProcessWide -IsInstanceOf_NoCacheLookup -JitInfo_GetCompilationTimeInTicks -JitInfo_GetCompiledILBytes -JitInfo_GetCompiledMethodCount -LoaderAllocator_Destroy -MarshalNative_GetDelegateForFunctionPointerInternal -MarshalNative_GetExceptionForHR -MarshalNative_GetFunctionPointerForDelegateInternal -MarshalNative_GetIsInCooperativeGCModeFunctionPointer -MarshalNative_HasLayout -MarshalNative_OffsetOf -MarshalNative_Prelink -MarshalNative_SizeOfHelper -Marshal_GetExceptionCode -Marshal_GetExceptionPointers -Marshal_GetLastPInvokeError -Marshal_SetLastPInvokeError -MathF_Acos -MathF_Acosh -MathF_Asin -MathF_Asinh -MathF_Atan -MathF_Atan2 -MathF_Atanh -MathF_Cbrt -MathF_Ceiling -MathF_Cos -MathF_Cosh -MathF_Exp -MathF_Floor -MathF_FusedMultiplyAdd -MathF_Log -MathF_Log10 -MathF_Log2 -MathF_ModF -MathF_Pow -MathF_Sin -MathF_SinCos -MathF_Sinh -MathF_Sqrt -MathF_Tan -MathF_Tanh -Math_Acos -Math_Acosh -Math_Asin -Math_Asinh -Math_Atan -Math_Atan2 -Math_Atanh -Math_Cbrt -Math_Ceiling -Math_Cos -Math_Cosh -Math_DivInt32Internal -Math_DivInt64Internal -Math_DivUInt32Internal -Math_DivUInt64Internal -Math_Exp -Math_Floor -Math_FusedMultiplyAdd -Math_Log -Math_Log10 -Math_Log2 -Math_ModF -Math_ModInt32Internal -Math_ModInt64Internal -Math_ModUInt32Internal -Math_ModUInt64Internal -Math_Pow -Math_Sin -Math_SinCos -Math_Sinh -Math_Sqrt -Math_Tan -Math_Tanh -MdUtf8String_EqualsCaseInsensitive -MetadataImport_Enum -MetadataImport_GetClassLayout -MetadataImport_GetCustomAttributeProps -MetadataImport_GetDefaultValue -MetadataImport_GetEventProps -MetadataImport_GetFieldDefProps -MetadataImport_GetFieldMarshal -MetadataImport_GetFieldOffset -MetadataImport_GetGenericParamProps -MetadataImport_GetMarshalAs -MetadataImport_GetMemberRefProps -MetadataImport_GetMetadataImport -MetadataImport_GetName -MetadataImport_GetNamespace -MetadataImport_GetPInvokeMap -MetadataImport_GetParamDefProps -MetadataImport_GetParentToken -MetadataImport_GetPropertyProps -MetadataImport_GetScopeProps -MetadataImport_GetSigOfFieldDef -MetadataImport_GetSigOfMethodDef -MetadataImport_GetSignatureFromToken -MetadataImport_GetUserString -MetadataImport_IsValidToken -MethodBase_GetCurrentMethod -MethodTable_CanCompareBitsOrUseFastGetHashCode -MethodTable_GetLoaderAllocatorHandle -MethodTable_GetMethodTableMatchingParentClass -MethodTable_GetNumInstanceFieldBytes -MethodTable_GetPrimitiveCorElementType -ModuleBuilder_GetArrayMethodToken -ModuleBuilder_GetMemberRef -ModuleBuilder_GetMemberRefFromSignature -ModuleBuilder_GetMemberRefOfFieldInfo -ModuleBuilder_GetMemberRefOfMethodInfo -ModuleBuilder_GetStringConstant -ModuleBuilder_GetTokenFromTypeSpec -ModuleBuilder_GetTypeRef -ModuleBuilder_SetFieldRVAContent -ModuleHandle_GetDynamicMethod -ModuleHandle_GetMDStreamVersion -ModuleHandle_GetModuleType -ModuleHandle_GetPEKind -ModuleHandle_GetToken -ModuleHandle_ResolveField -ModuleHandle_ResolveMethod -ModuleHandle_ResolveType -NativeLibrary_LoadByName -NativeRuntimeEventSource_LogContentionLockCreated -NativeRuntimeEventSource_LogContentionStart -NativeRuntimeEventSource_LogContentionStop -NativeRuntimeEventSource_LogDecreaseMemoryPressure -NativeRuntimeEventSource_LogIncreaseMemoryPressure -NativeRuntimeEventSource_LogThreadPoolIODequeue -NativeRuntimeEventSource_LogThreadPoolIOEnqueue -NativeRuntimeEventSource_LogThreadPoolIOPack -NativeRuntimeEventSource_LogThreadPoolMinMaxThreads -NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment -NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample -NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats -NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart -NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop -NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait -NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount -NativeRuntimeEventSource_LogWaitHandleWaitStart -NativeRuntimeEventSource_LogWaitHandleWaitStop -ObjectHeader_GetLockHandleIfExists -ObjectHeader_GetOrCreateLockObject -ObjectNative_AllocateUninitializedClone -ObjectNative_GetHashCodeSlow -QCall_FreeGCHandleForTypeHandle -QCall_GetGCHandleForTypeHandle -QCall_memmove -QCall_memset -ReflectionInvocation_CompileMethod -ReflectionInvocation_GetBoxInfo -ReflectionInvocation_GetGuid -ReflectionInvocation_PrepareDelegate -ReflectionInvocation_PrepareMethod -ReflectionInvocation_RunClassConstructor -ReflectionInvocation_RunModuleConstructor -ReflectionInvocation_SizeOf -ReflectionSerialization_GetCreateUninitializedObjectInfo -ResolveVirtualFunctionPointer -RuntimeAssembly_GetIsCollectible -RuntimeAssembly_GetIsDynamic -RuntimeAssembly_GetManifestModule -RuntimeAssembly_GetTokenInternal -RuntimeFieldHandle_AcquiresContextFromThis -RuntimeFieldHandle_GetApproxDeclaringMethodTable -RuntimeFieldHandle_GetAttributes -RuntimeFieldHandle_GetEnCFieldAddr -RuntimeFieldHandle_GetFieldDataReference -RuntimeFieldHandle_GetInstanceFieldOffset -RuntimeFieldHandle_GetLoaderAllocatorInternal -RuntimeFieldHandle_GetRVAFieldInfo -RuntimeFieldHandle_GetStaticFieldAddress -RuntimeFieldHandle_GetStaticFieldForGenericType -RuntimeFieldHandle_GetToken -RuntimeFieldHandle_GetUtf8NameInternal -RuntimeFieldHandle_GetValue -RuntimeFieldHandle_GetValueDirect -RuntimeFieldHandle_IsFastPathSupported -RuntimeFieldHandle_SetValue -RuntimeFieldHandle_SetValueDirect -RuntimeHelpers_ContentEquals -RuntimeHelpers_GetTailCallArgBuffer -RuntimeHelpers_GetTailCallInfo -RuntimeHelpers_TryEnsureSufficientExecutionStack -RuntimeHelpers_TryGetHashCode -RuntimeMethodHandle_ConstructInstantiation -RuntimeMethodHandle_Destroy -RuntimeMethodHandle_GetAttributes -RuntimeMethodHandle_GetDiagnosticCodeStart -RuntimeMethodHandle_GetFunctionPointer -RuntimeMethodHandle_GetGenericParameterCount -RuntimeMethodHandle_GetImplAttributes -RuntimeMethodHandle_GetLoaderAllocatorInternal -RuntimeMethodHandle_GetMethodBody -RuntimeMethodHandle_GetMethodDef -RuntimeMethodHandle_GetMethodFromCanonical -RuntimeMethodHandle_GetMethodInstantiation -RuntimeMethodHandle_GetMethodTable -RuntimeMethodHandle_GetResolver -RuntimeMethodHandle_GetSlot -RuntimeMethodHandle_GetStubIfNeededInternal -RuntimeMethodHandle_GetStubIfNeededSlow -RuntimeMethodHandle_GetTypicalMethodDefinition -RuntimeMethodHandle_GetUtf8NameInternal -RuntimeMethodHandle_GetVirtualFunctionPointer -RuntimeMethodHandle_HasMethodInstantiation -RuntimeMethodHandle_IsAsyncMethod -RuntimeMethodHandle_IsCAVisibleFromDecoratedType -RuntimeMethodHandle_IsCollectible -RuntimeMethodHandle_IsConstructor -RuntimeMethodHandle_IsDynamicMethod -RuntimeMethodHandle_IsGenericMethodDefinition -RuntimeMethodHandle_IsTypicalMethodDefinition -RuntimeMethodHandle_StripMethodInstantiation -RuntimeModule_GetFullyQualifiedName -RuntimeModule_GetScopeName -RuntimeModule_GetTypes -RuntimeTypeHandle_AllocateTypeAssociatedMemory -RuntimeTypeHandle_AllocateTypeAssociatedMemoryAligned -RuntimeTypeHandle_CompareCanonicalHandles -RuntimeTypeHandle_ConstructName -RuntimeTypeHandle_ContainsGenericVariables -RuntimeTypeHandle_CreateInstanceForAnotherGenericParameter -RuntimeTypeHandle_GetActivationInfo -RuntimeTypeHandle_GetArgumentTypesFromFunctionPointer -RuntimeTypeHandle_GetArrayRank -RuntimeTypeHandle_GetAssemblyIfExists -RuntimeTypeHandle_GetAssemblySlow -RuntimeTypeHandle_GetAttributes -RuntimeTypeHandle_GetConstraints -RuntimeTypeHandle_GetDeclaringMethodForGenericParameter -RuntimeTypeHandle_GetDeclaringTypeHandle -RuntimeTypeHandle_GetDeclaringTypeHandleForGenericVariable -RuntimeTypeHandle_GetElementTypeHandle -RuntimeTypeHandle_GetFields -RuntimeTypeHandle_GetFirstIntroducedMethod -RuntimeTypeHandle_GetGenericTypeDefinition -RuntimeTypeHandle_GetGenericVariableIndex -RuntimeTypeHandle_GetInstantiation -RuntimeTypeHandle_GetInterfaceMethodImplementation -RuntimeTypeHandle_GetInterfaces -RuntimeTypeHandle_GetMethodAt -RuntimeTypeHandle_GetModuleIfExists -RuntimeTypeHandle_GetModuleSlow -RuntimeTypeHandle_GetNextIntroducedMethod -RuntimeTypeHandle_GetNumVirtuals -RuntimeTypeHandle_GetNumVirtualsAndStaticVirtuals -RuntimeTypeHandle_GetRuntimeTypeFromHandleSlow -RuntimeTypeHandle_GetToken -RuntimeTypeHandle_GetUtf8NameInternal -RuntimeTypeHandle_Instantiate -RuntimeTypeHandle_InternalAlloc -RuntimeTypeHandle_InternalAllocNoChecks -RuntimeTypeHandle_InternalAllocNoChecks_FastPath -RuntimeTypeHandle_IsGenericVariable -RuntimeTypeHandle_IsUnmanagedFunctionPointer -RuntimeTypeHandle_IsVisible -RuntimeTypeHandle_MakeArray -RuntimeTypeHandle_MakeByRef -RuntimeTypeHandle_MakeFunctionPointer -RuntimeTypeHandle_MakePointer -RuntimeTypeHandle_MakeSZArray -RuntimeTypeHandle_RegisterCollectibleTypeDependency -RuntimeTypeHandle_SatisfiesConstraints -RuntimeTypeHandle_VerifyInterfaceIsImplemented -SfiInit -SfiNext -Signature_AreEqual -Signature_GetCallingConventionFromFunctionPointerAtOffsetInternal -Signature_GetCustomModifiersAtOffset -Signature_GetParameterOffsetInternal -Signature_GetTypeParameterOffsetInternal -Signature_Init -StackFrame_GetMethodDescFromNativeIP -StackTrace_GetStackFramesInternal -Stream_HasOverriddenSlow -String_Intern -String_IsInterned -StubHelpers_ClearLastError -StubHelpers_CreateCustomMarshaler -StubHelpers_CreateLayoutClassMarshalStubs -StubHelpers_LogPinnedArgument -StubHelpers_MulticastDebuggerTraceHelper -StubHelpers_SetLastError -StubHelpers_ThrowInteropException -StubHelpers_ThrowInteropParamException -StubHelpers_ValidateByref -StubHelpers_ValidateObject -SystemJS_MarkAsyncMain -SystemJS_RejectMainPromise -SystemJS_ResolveMainPromise -SystemJS_ScheduleBackgroundJob -SystemJS_ScheduleTimer -TailCallHelp_AllocTailCallArgBufferInternal -ThreadNative_Abort -ThreadNative_GetQCallSpecialException -ThreadNative_GetThreadState -ThreadNative_ResetAbort -ThrowInvalidCastException -TypeBuilder_AddInterfaceImpl -TypeBuilder_DefineCustomAttribute -TypeBuilder_DefineEvent -TypeBuilder_DefineField -TypeBuilder_DefineGenericParam -TypeBuilder_DefineMethod -TypeBuilder_DefineMethodImpl -TypeBuilder_DefineMethodSemantics -TypeBuilder_DefineMethodSpec -TypeBuilder_DefineProperty -TypeBuilder_DefineType -TypeBuilder_GetTokenFromSig -TypeBuilder_SetClassLayout -TypeBuilder_SetConstantValue -TypeBuilder_SetFieldLayoutOffset -TypeBuilder_SetMethodIL -TypeBuilder_SetMethodImpl -TypeBuilder_SetPInvokeData -TypeBuilder_SetParamInfo -TypeBuilder_SetParentType -TypeBuilder_TermCreateClass -TypeHandle_CanCastTo_NoCacheLookup -TypeHandle_GetCorElementType -TypeMapLazyDictionary_FindPrecachedExternalTypeMapEntry -TypeMapLazyDictionary_FindPrecachedProxyTypeMapEntry -TypeMapLazyDictionary_ProcessAttributes -UnsafeAccessors_ResolveGenericParamToTypeHandle -ValueType_GetHashCodeStrategy -VersionResilientHashCode_TypeHashCode diff --git a/src/coreclr/vm/wasm/generate-coreclr-helpers.md b/src/coreclr/vm/wasm/generate-coreclr-helpers.md index 7ed5e5f716ccf0..5b1e42b06bf141 100644 --- a/src/coreclr/vm/wasm/generate-coreclr-helpers.md +++ b/src/coreclr/vm/wasm/generate-coreclr-helpers.md @@ -28,14 +28,11 @@ By default the scripts generate **both** WebAssembly variations; pass `--target- | `browser` | `src/coreclr/vm/wasm/browser/` | `artifacts/bin/testhost/net12.0-browser--wasm/shared/Microsoft.NETCore.App/12.0.0/` | | `wasi` | `src/coreclr/vm/wasm/wasi/` | `artifacts/bin/testhost/net12.0-wasi--wasm/shared/Microsoft.NETCore.App/12.0.0/` | -Each run emits four files into the output directory: +Each run emits three files into the output directory: - `callhelpers-pinvoke.cpp` - `callhelpers-reverse.cpp` - `callhelpers-interp-to-managed.cpp` -- `callhelpers-exports.txt` - -`callhelpers-exports.txt` lists the native symbols of the QCalls in `callhelpers-pinvoke.cpp`, one per line. The native module exports them, because ReadyToRun code imports these targets by symbol instead of resolving them through the table. ## The shared QCall/FCall table diff --git a/src/coreclr/vm/wasm/generate-coreclr-helpers.proj b/src/coreclr/vm/wasm/generate-coreclr-helpers.proj index 5222805423edb2..0e7ce3259baccd 100644 --- a/src/coreclr/vm/wasm/generate-coreclr-helpers.proj +++ b/src/coreclr/vm/wasm/generate-coreclr-helpers.proj @@ -154,7 +154,6 @@ - diff --git a/src/coreclr/vm/wasm/wasi/callhelpers-exports.txt b/src/coreclr/vm/wasm/wasi/callhelpers-exports.txt deleted file mode 100644 index 817443aefa8bc8..00000000000000 --- a/src/coreclr/vm/wasm/wasi/callhelpers-exports.txt +++ /dev/null @@ -1,507 +0,0 @@ -AppContext_SetFirstChanceExceptionHandler -AppContext_TryGetHostPropertyValue -AppDomain_CreateDynamicAssembly -AppendExceptionStackFrame -Array_CreateInstance -Array_Ctor -Array_GetCorElementTypeOfElementType -Array_GetElementConstructorEntrypoint -AssemblyHandle_GetManifestModuleSlow -AssemblyLoadContext_IsTracingEnabled -AssemblyName_InitializeAssemblySpec -AssemblyNative_ApplyUpdate -AssemblyNative_GetAssemblyCount -AssemblyNative_GetAssemblyFromHandle -AssemblyNative_GetCodeBase -AssemblyNative_GetEntryAssembly -AssemblyNative_GetEntryPoint -AssemblyNative_GetExecutingAssembly -AssemblyNative_GetExportedTypes -AssemblyNative_GetFlags -AssemblyNative_GetForwardedType -AssemblyNative_GetFullName -AssemblyNative_GetHashAlgorithm -AssemblyNative_GetImageRuntimeVersion -AssemblyNative_GetLoadContextForAssembly -AssemblyNative_GetLoadedAssemblies -AssemblyNative_GetLocale -AssemblyNative_GetLocation -AssemblyNative_GetManifestResourceInfo -AssemblyNative_GetManifestResourceNames -AssemblyNative_GetModule -AssemblyNative_GetModules -AssemblyNative_GetPublicKey -AssemblyNative_GetReferencedAssemblies -AssemblyNative_GetResource -AssemblyNative_GetSimpleName -AssemblyNative_GetTypeCore -AssemblyNative_GetTypeCoreIgnoreCase -AssemblyNative_GetVersion -AssemblyNative_InitializeAssemblyLoadContext -AssemblyNative_InternalLoad -AssemblyNative_InternalTryGetRawMetadata -AssemblyNative_IsApplyUpdateSupported -AssemblyNative_LoadFromPath -AssemblyNative_LoadFromStream -AssemblyNative_PrepareForAssemblyLoadContextRelease -AssemblyNative_TraceAssemblyLoadFromResolveHandlerInvoked -AssemblyNative_TraceAssemblyResolveHandlerInvoked -AssemblyNative_TraceResolvingHandlerInvoked -AssemblyNative_TraceSatelliteSubdirectoryPathProbed -AsyncHelpers_AddContinuationToExInternal -AsyncHelpers_ResumeInterpreterContinuation -Buffer_BulkMoveWithWriteBarrierInternal -CallFilterFunclet -CustomAttribute_ParseAttributeUsageAttribute -DebugDebugger_Break -DebugDebugger_CustomNotification -DebugDebugger_IsLoggingHelper -DebugDebugger_IsManagedDebuggerAttached -DebugDebugger_Launch -DebugDebugger_Log -DebugDebugger_PrepareFuncEvalResult -DebugDebugger_ReadFuncEvalPrimitiveRegister -DebugDebugger_WriteFuncEvalObjectRegister -DebugDebugger_WriteFuncEvalRegister -Delegate_AdjustTarget -Delegate_BindToMethodInfo -Delegate_BindToMethodName -Delegate_Construct -Delegate_CreateMethodInfo -Delegate_GetInvokeMethod -Delegate_GetMethodDesc -Delegate_GetMulticastInvoke -Delegate_GetMulticastInvokeSlow -Delegate_InitializeVirtualCallStub -DependentHandle_InternalAlloc -DependentHandle_InternalAllocWithGCTransition -DependentHandle_InternalFree -DependentHandle_InternalFreeWithGCTransition -DependentHandle_InternalGetDependent -DependentHandle_InternalGetTargetAndDependent -DependentHandle_InternalGetTargetWithDebugValidation -DependentHandle_InternalSetDependent -DependentHandle_InternalSetTargetToNull -EHEnumInitFromStackFrameIterator -EHEnumNext -Enum_GetValuesAndNames -Environment_Exit -Environment_FailFast -Environment_GetEnviron -Environment_GetEnvironmentVariable -Environment_SetEnvironmentVariable -Environment_get_ExitCode -Environment_set_ExitCode -EventPipeInternal_CreateProvider -EventPipeInternal_DefineEvent -EventPipeInternal_DeleteProvider -EventPipeInternal_Disable -EventPipeInternal_Enable -EventPipeInternal_EventActivityIdControl -EventPipeInternal_GetNextEvent -EventPipeInternal_GetProvider -EventPipeInternal_GetSessionInfo -EventPipeInternal_SignalSession -EventPipeInternal_WasiRunJobs -EventPipeInternal_WriteEventData -ExceptionNative_GetFrozenStackTrace -ExceptionNative_GetMessageFromNativeResources -ExceptionNative_GetMethodFromStackTrace -ExceptionNative_ThrowAmbiguousResolutionException -ExceptionNative_ThrowClassAccessException -ExceptionNative_ThrowEntryPointNotFoundException -ExceptionNative_ThrowFieldAccessException -ExceptionNative_ThrowMethodAccessException -Exception_GetExceptionCount -Exception_IsImmutableException -Exception_PrepareForForeignExceptionRaise -FileLoadException_GetMessageForHR -GCFrameRegistration_RegisterForGCReporting -GCFrameRegistration_UnregisterForGCReporting -GCHandle_InternalAllocWithGCTransition -GCHandle_InternalCompareExchange -GCHandle_InternalFreeWithGCTransition -GCHandle_InternalGetWithDebugValidation -GCHandle_InternalSet -GCHandle__InternalAlloc -GCHandle__InternalFree -GCInterface_AllocateNewArray -GCInterface_Collect -GCInterface_EnableNoGCRegionCallback -GCInterface_EndNoGCRegion -GCInterface_EnumerateConfigurationValues -GCInterface_GetGenerationBudget -GCInterface_GetNextFinalizableObject -GCInterface_GetTotalAllocatedBytesPrecise -GCInterface_GetTotalMemory -GCInterface_ReRegisterForFinalize -GCInterface_RefreshMemoryLimit -GCInterface_RegisterFrozenSegment -GCInterface_StartNoGCRegion -GCInterface_UnregisterFrozenSegment -GCInterface_WaitForFullGCApproach -GCInterface_WaitForFullGCComplete -GCInterface_WaitForPendingFinalizers -GCSettings_GetGCLatencyMode -GCSettings_GetLOHCompactionMode -GCSettings_SetGCLatencyMode -GCSettings_SetLOHCompactionMode -GCSettings_get_IsServerGC -GC_GetAllocatedBytesForCurrentThread -GC_GetCurrentObjSize -GC_GetGCNow -GC_GetGenerationInternal -GC_GetGenerationSize -GC_GetLastGCDuration -GC_GetLastGCPercentTimeInGC -GC_GetLastGCStartTime -GC_GetMaxGeneration -GC_GetMemoryInfo -GC_GetSegmentSize -GC_GetTotalAllocatedBytesApproximate -GC_SuppressFinalizeInternal -GC__CancelFullGCNotification -GC__CollectionCount -GC__GetTotalPauseDuration -GC__RegisterForFullGCNotification -GenericHandleWorker -GetCurrentExInfo -GetFileLoadExceptionMessage -GetTypeLoadExceptionMessage -InitClassHelper -Interlocked_CompareExchange32 -Interlocked_CompareExchange32Pointer -Interlocked_CompareExchange64 -Interlocked_CompareExchangeObject -Interlocked_Exchange32 -Interlocked_Exchange64 -Interlocked_ExchangeAdd32 -Interlocked_ExchangeAdd64 -Interlocked_ExchangeObject -Interlocked_MemoryBarrierProcessWide -IsInstanceOf_NoCacheLookup -JitInfo_GetCompilationTimeInTicks -JitInfo_GetCompiledILBytes -JitInfo_GetCompiledMethodCount -LoaderAllocator_Destroy -MarshalNative_GetDelegateForFunctionPointerInternal -MarshalNative_GetExceptionForHR -MarshalNative_GetFunctionPointerForDelegateInternal -MarshalNative_GetIsInCooperativeGCModeFunctionPointer -MarshalNative_HasLayout -MarshalNative_OffsetOf -MarshalNative_Prelink -MarshalNative_SizeOfHelper -Marshal_GetExceptionCode -Marshal_GetExceptionPointers -Marshal_GetLastPInvokeError -Marshal_SetLastPInvokeError -MathF_Acos -MathF_Acosh -MathF_Asin -MathF_Asinh -MathF_Atan -MathF_Atan2 -MathF_Atanh -MathF_Cbrt -MathF_Ceiling -MathF_Cos -MathF_Cosh -MathF_Exp -MathF_Floor -MathF_FusedMultiplyAdd -MathF_Log -MathF_Log10 -MathF_Log2 -MathF_ModF -MathF_Pow -MathF_Sin -MathF_SinCos -MathF_Sinh -MathF_Sqrt -MathF_Tan -MathF_Tanh -Math_Acos -Math_Acosh -Math_Asin -Math_Asinh -Math_Atan -Math_Atan2 -Math_Atanh -Math_Cbrt -Math_Ceiling -Math_Cos -Math_Cosh -Math_DivInt32Internal -Math_DivInt64Internal -Math_DivUInt32Internal -Math_DivUInt64Internal -Math_Exp -Math_Floor -Math_FusedMultiplyAdd -Math_Log -Math_Log10 -Math_Log2 -Math_ModF -Math_ModInt32Internal -Math_ModInt64Internal -Math_ModUInt32Internal -Math_ModUInt64Internal -Math_Pow -Math_Sin -Math_SinCos -Math_Sinh -Math_Sqrt -Math_Tan -Math_Tanh -MdUtf8String_EqualsCaseInsensitive -MetadataImport_Enum -MetadataImport_GetClassLayout -MetadataImport_GetCustomAttributeProps -MetadataImport_GetDefaultValue -MetadataImport_GetEventProps -MetadataImport_GetFieldDefProps -MetadataImport_GetFieldMarshal -MetadataImport_GetFieldOffset -MetadataImport_GetGenericParamProps -MetadataImport_GetMarshalAs -MetadataImport_GetMemberRefProps -MetadataImport_GetMetadataImport -MetadataImport_GetName -MetadataImport_GetNamespace -MetadataImport_GetPInvokeMap -MetadataImport_GetParamDefProps -MetadataImport_GetParentToken -MetadataImport_GetPropertyProps -MetadataImport_GetScopeProps -MetadataImport_GetSigOfFieldDef -MetadataImport_GetSigOfMethodDef -MetadataImport_GetSignatureFromToken -MetadataImport_GetUserString -MetadataImport_IsValidToken -MethodBase_GetCurrentMethod -MethodTable_CanCompareBitsOrUseFastGetHashCode -MethodTable_GetLoaderAllocatorHandle -MethodTable_GetMethodTableMatchingParentClass -MethodTable_GetNumInstanceFieldBytes -MethodTable_GetPrimitiveCorElementType -ModuleBuilder_GetArrayMethodToken -ModuleBuilder_GetMemberRef -ModuleBuilder_GetMemberRefFromSignature -ModuleBuilder_GetMemberRefOfFieldInfo -ModuleBuilder_GetMemberRefOfMethodInfo -ModuleBuilder_GetStringConstant -ModuleBuilder_GetTokenFromTypeSpec -ModuleBuilder_GetTypeRef -ModuleBuilder_SetFieldRVAContent -ModuleHandle_GetDynamicMethod -ModuleHandle_GetMDStreamVersion -ModuleHandle_GetModuleType -ModuleHandle_GetPEKind -ModuleHandle_GetToken -ModuleHandle_ResolveField -ModuleHandle_ResolveMethod -ModuleHandle_ResolveType -NativeLibrary_LoadByName -NativeRuntimeEventSource_LogContentionLockCreated -NativeRuntimeEventSource_LogContentionStart -NativeRuntimeEventSource_LogContentionStop -NativeRuntimeEventSource_LogDecreaseMemoryPressure -NativeRuntimeEventSource_LogIncreaseMemoryPressure -NativeRuntimeEventSource_LogThreadPoolIODequeue -NativeRuntimeEventSource_LogThreadPoolIOEnqueue -NativeRuntimeEventSource_LogThreadPoolIOPack -NativeRuntimeEventSource_LogThreadPoolMinMaxThreads -NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment -NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample -NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats -NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart -NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop -NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait -NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount -NativeRuntimeEventSource_LogWaitHandleWaitStart -NativeRuntimeEventSource_LogWaitHandleWaitStop -ObjectHeader_GetLockHandleIfExists -ObjectHeader_GetOrCreateLockObject -ObjectNative_AllocateUninitializedClone -ObjectNative_GetHashCodeSlow -QCall_FreeGCHandleForTypeHandle -QCall_GetGCHandleForTypeHandle -ReflectionInvocation_CompileMethod -ReflectionInvocation_GetBoxInfo -ReflectionInvocation_GetGuid -ReflectionInvocation_PrepareDelegate -ReflectionInvocation_PrepareMethod -ReflectionInvocation_RunClassConstructor -ReflectionInvocation_RunModuleConstructor -ReflectionInvocation_SizeOf -ReflectionSerialization_GetCreateUninitializedObjectInfo -ResolveVirtualFunctionPointer -RuntimeAssembly_GetIsCollectible -RuntimeAssembly_GetIsDynamic -RuntimeAssembly_GetManifestModule -RuntimeAssembly_GetTokenInternal -RuntimeFieldHandle_AcquiresContextFromThis -RuntimeFieldHandle_GetApproxDeclaringMethodTable -RuntimeFieldHandle_GetAttributes -RuntimeFieldHandle_GetEnCFieldAddr -RuntimeFieldHandle_GetFieldDataReference -RuntimeFieldHandle_GetInstanceFieldOffset -RuntimeFieldHandle_GetLoaderAllocatorInternal -RuntimeFieldHandle_GetRVAFieldInfo -RuntimeFieldHandle_GetStaticFieldAddress -RuntimeFieldHandle_GetStaticFieldForGenericType -RuntimeFieldHandle_GetToken -RuntimeFieldHandle_GetUtf8NameInternal -RuntimeFieldHandle_GetValue -RuntimeFieldHandle_GetValueDirect -RuntimeFieldHandle_IsFastPathSupported -RuntimeFieldHandle_SetValue -RuntimeFieldHandle_SetValueDirect -RuntimeHelpers_ContentEquals -RuntimeHelpers_GetTailCallArgBuffer -RuntimeHelpers_GetTailCallInfo -RuntimeHelpers_TryEnsureSufficientExecutionStack -RuntimeHelpers_TryGetHashCode -RuntimeMethodHandle_ConstructInstantiation -RuntimeMethodHandle_Destroy -RuntimeMethodHandle_GetAttributes -RuntimeMethodHandle_GetDiagnosticCodeStart -RuntimeMethodHandle_GetFunctionPointer -RuntimeMethodHandle_GetGenericParameterCount -RuntimeMethodHandle_GetImplAttributes -RuntimeMethodHandle_GetLoaderAllocatorInternal -RuntimeMethodHandle_GetMethodBody -RuntimeMethodHandle_GetMethodDef -RuntimeMethodHandle_GetMethodFromCanonical -RuntimeMethodHandle_GetMethodInstantiation -RuntimeMethodHandle_GetMethodTable -RuntimeMethodHandle_GetResolver -RuntimeMethodHandle_GetSlot -RuntimeMethodHandle_GetStubIfNeededInternal -RuntimeMethodHandle_GetStubIfNeededSlow -RuntimeMethodHandle_GetTypicalMethodDefinition -RuntimeMethodHandle_GetUtf8NameInternal -RuntimeMethodHandle_GetVirtualFunctionPointer -RuntimeMethodHandle_HasMethodInstantiation -RuntimeMethodHandle_IsAsyncMethod -RuntimeMethodHandle_IsCAVisibleFromDecoratedType -RuntimeMethodHandle_IsCollectible -RuntimeMethodHandle_IsConstructor -RuntimeMethodHandle_IsDynamicMethod -RuntimeMethodHandle_IsGenericMethodDefinition -RuntimeMethodHandle_IsTypicalMethodDefinition -RuntimeMethodHandle_StripMethodInstantiation -RuntimeModule_GetFullyQualifiedName -RuntimeModule_GetScopeName -RuntimeModule_GetTypes -RuntimeTypeHandle_AllocateTypeAssociatedMemory -RuntimeTypeHandle_AllocateTypeAssociatedMemoryAligned -RuntimeTypeHandle_CompareCanonicalHandles -RuntimeTypeHandle_ConstructName -RuntimeTypeHandle_ContainsGenericVariables -RuntimeTypeHandle_CreateInstanceForAnotherGenericParameter -RuntimeTypeHandle_GetActivationInfo -RuntimeTypeHandle_GetArgumentTypesFromFunctionPointer -RuntimeTypeHandle_GetArrayRank -RuntimeTypeHandle_GetAssemblyIfExists -RuntimeTypeHandle_GetAssemblySlow -RuntimeTypeHandle_GetAttributes -RuntimeTypeHandle_GetConstraints -RuntimeTypeHandle_GetDeclaringMethodForGenericParameter -RuntimeTypeHandle_GetDeclaringTypeHandle -RuntimeTypeHandle_GetDeclaringTypeHandleForGenericVariable -RuntimeTypeHandle_GetElementTypeHandle -RuntimeTypeHandle_GetFields -RuntimeTypeHandle_GetFirstIntroducedMethod -RuntimeTypeHandle_GetGenericTypeDefinition -RuntimeTypeHandle_GetGenericVariableIndex -RuntimeTypeHandle_GetInstantiation -RuntimeTypeHandle_GetInterfaceMethodImplementation -RuntimeTypeHandle_GetInterfaces -RuntimeTypeHandle_GetMethodAt -RuntimeTypeHandle_GetModuleIfExists -RuntimeTypeHandle_GetModuleSlow -RuntimeTypeHandle_GetNextIntroducedMethod -RuntimeTypeHandle_GetNumVirtuals -RuntimeTypeHandle_GetNumVirtualsAndStaticVirtuals -RuntimeTypeHandle_GetRuntimeTypeFromHandleSlow -RuntimeTypeHandle_GetToken -RuntimeTypeHandle_GetUtf8NameInternal -RuntimeTypeHandle_Instantiate -RuntimeTypeHandle_InternalAlloc -RuntimeTypeHandle_InternalAllocNoChecks -RuntimeTypeHandle_InternalAllocNoChecks_FastPath -RuntimeTypeHandle_IsGenericVariable -RuntimeTypeHandle_IsUnmanagedFunctionPointer -RuntimeTypeHandle_IsVisible -RuntimeTypeHandle_MakeArray -RuntimeTypeHandle_MakeByRef -RuntimeTypeHandle_MakeFunctionPointer -RuntimeTypeHandle_MakePointer -RuntimeTypeHandle_MakeSZArray -RuntimeTypeHandle_RegisterCollectibleTypeDependency -RuntimeTypeHandle_SatisfiesConstraints -RuntimeTypeHandle_VerifyInterfaceIsImplemented -SfiInit -SfiNext -Signature_AreEqual -Signature_GetCallingConventionFromFunctionPointerAtOffsetInternal -Signature_GetCustomModifiersAtOffset -Signature_GetParameterOffsetInternal -Signature_GetTypeParameterOffsetInternal -Signature_Init -StackFrame_GetMethodDescFromNativeIP -StackTrace_GetStackFramesInternal -Stream_HasOverriddenSlow -String_Intern -String_IsInterned -StubHelpers_ClearLastError -StubHelpers_CreateCustomMarshaler -StubHelpers_CreateLayoutClassMarshalStubs -StubHelpers_LogPinnedArgument -StubHelpers_MulticastDebuggerTraceHelper -StubHelpers_SetLastError -StubHelpers_ThrowInteropException -StubHelpers_ThrowInteropParamException -StubHelpers_ValidateByref -StubHelpers_ValidateObject -TailCallHelp_AllocTailCallArgBufferInternal -ThreadNative_Abort -ThreadNative_GetQCallSpecialException -ThreadNative_GetThreadState -ThreadNative_ResetAbort -ThrowInvalidCastException -TypeBuilder_AddInterfaceImpl -TypeBuilder_DefineCustomAttribute -TypeBuilder_DefineEvent -TypeBuilder_DefineField -TypeBuilder_DefineGenericParam -TypeBuilder_DefineMethod -TypeBuilder_DefineMethodImpl -TypeBuilder_DefineMethodSemantics -TypeBuilder_DefineMethodSpec -TypeBuilder_DefineProperty -TypeBuilder_DefineType -TypeBuilder_GetTokenFromSig -TypeBuilder_SetClassLayout -TypeBuilder_SetConstantValue -TypeBuilder_SetFieldLayoutOffset -TypeBuilder_SetMethodIL -TypeBuilder_SetMethodImpl -TypeBuilder_SetPInvokeData -TypeBuilder_SetParamInfo -TypeBuilder_SetParentType -TypeBuilder_TermCreateClass -TypeHandle_CanCastTo_NoCacheLookup -TypeHandle_GetCorElementType -TypeMapLazyDictionary_FindPrecachedExternalTypeMapEntry -TypeMapLazyDictionary_FindPrecachedProxyTypeMapEntry -TypeMapLazyDictionary_ProcessAttributes -UnsafeAccessors_ResolveGenericParamToTypeHandle -ValueType_GetHashCodeStrategy -VersionResilientHashCode_TypeHashCode -WasiFinalizer_RunWorker -WasiFinalizer_TryClearPending -memmove -memset diff --git a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets index 8c323a71b0194c..13b9359f95f294 100644 --- a/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets +++ b/src/mono/browser/build/BrowserWasmApp.CoreCLR.targets @@ -710,7 +710,6 @@ <_WasmPInvokeTablePath>$(_WasmIntermediateOutputPath)callhelpers-pinvoke.cpp <_WasmReversePInvokeTablePath>$(_WasmIntermediateOutputPath)callhelpers-reverse.cpp <_WasmInterpToNativeTablePath>$(_WasmIntermediateOutputPath)callhelpers-interp-to-managed.cpp - <_WasmCallHelpersExportsPath>$(_WasmIntermediateOutputPath)callhelpers-exports.txt @@ -804,7 +803,7 @@ - + @@ -876,18 +875,6 @@ - - - - - - - <_EmccExportedFunctionDistinct Include="@(EmccExportedFunction->Distinct())" /> - - - <_EmccExportedFunctionDistinct Remove="@(_EmccExportedFunctionDistinct)" /> - - <_EmccExportedRuntimeMethods>"[BROWSER_HOST,@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]" <_EmccIncomingModuleJSAPIs>"[@(_EmccIncomingModuleJSAPI -> '%27%(Identity)%27', ',')]" diff --git a/src/mono/wasi/build/WasiApp.CoreCLR.targets b/src/mono/wasi/build/WasiApp.CoreCLR.targets index fb85cd2dcfd511..ac30371067fe44 100644 --- a/src/mono/wasi/build/WasiApp.CoreCLR.targets +++ b/src/mono/wasi/build/WasiApp.CoreCLR.targets @@ -311,7 +311,7 @@ - + - - - - - <_WasiRelinkLinkFlags Include="@(_WasiDirectPInvokeExport->'-Wl,--export-if-defined=%(Identity)')" /> <_WasiRelinkLinkFlags Include="--target=wasm32-unknown-wasip2" /> <_WasiRelinkLinkFlags Include="$(_WasiRelinkOptFlag)" /> <_WasiRelinkLinkFlags Include="-DNDEBUG" Condition="'$(Configuration)' != 'Debug'" /> diff --git a/src/native/corehost/browserhost/browserhost.proj b/src/native/corehost/browserhost/browserhost.proj index 04b4fd946d241d..91d097888b3189 100644 --- a/src/native/corehost/browserhost/browserhost.proj +++ b/src/native/corehost/browserhost/browserhost.proj @@ -18,8 +18,6 @@ $(BrowserHostInitialHeapSize) $(BrowserHostMaximumHeapSize) $(BrowserHostStackSize) - - <_WasmCallHelpersExportsPath>$(RepoRoot)src/coreclr/vm/wasm/browser/callhelpers-exports.txt diff --git a/src/native/libs/Common/JavaScript/host/assets.ts b/src/native/libs/Common/JavaScript/host/assets.ts index 9b9f84288710b1..cf768bbb42f71c 100644 --- a/src/native/libs/Common/JavaScript/host/assets.ts +++ b/src/native/libs/Common/JavaScript/host/assets.ts @@ -145,13 +145,6 @@ function buildWebcilImports(memory: WebAssembly.Memory, payloadPtr: number, tabl webcilImports.__async_continuation = asyncContinuation as unknown as WebAssembly.ImportValue; webcilImports.__indirect_function_table = _ems_.wasmTable; webcilImports.__table_base = new WebAssembly.Global({ value: "i32", mutable: false }, tableStartIndex); - // R2R images import QCall and FCall targets as functions named by their native symbol, which - // the runtime module exports, or, for JS-implemented QCalls, imports from "env". - return { - ...(runtimeModuleImports?.env as Record | undefined), - ...(_ems_.wasmExports as Record), - ...webcilImports - }; } return webcilImports; } From 023f5ece48de8f79e38ed34e0563b8e445324e41 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 2 Dec 2026 15:06:44 -0800 Subject: [PATCH 9/9] Fix WASM R2R call lowering Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/coreclr/hosts/corerun/wasm/libCorerun.js | 4 ++-- src/coreclr/jit/lower.cpp | 20 ------------------- src/coreclr/jit/lowerwasm.cpp | 5 +++-- .../WasmArgumentLayoutTests.cs | 1 - .../ReadyToRunSymbolNodeFactory.cs | 15 +++++++------- .../vm/wasm/generate-coreclr-helpers.proj | 1 - .../libs/Common/JavaScript/host/assets.ts | 10 +++++----- 7 files changed, 18 insertions(+), 38 deletions(-) diff --git a/src/coreclr/hosts/corerun/wasm/libCorerun.js b/src/coreclr/hosts/corerun/wasm/libCorerun.js index bae4d7463ef254..897b2a91e37a2e 100644 --- a/src/coreclr/hosts/corerun/wasm/libCorerun.js +++ b/src/coreclr/hosts/corerun/wasm/libCorerun.js @@ -278,8 +278,8 @@ function libCoreRunFactory() { // Runtime-async continuation return value, shared with the runtime module. __async_continuation: wasmExports.__async_continuation }; - // [WasmImportLinkage] P/Invoke targets are imported from the P/Invoke's own module, which the - // runtime module also imports. Emscripten supplies the same object for "env" and "wasi_snapshot_preview1". + // R2R Webcil images can import [WasmImportLinkage] P/Invoke targets from their declared modules. + // Reuse Emscripten's host imports for "env" and "wasi_snapshot_preview1". const imports = { webcil: webcilImports }; if (typeof (wasmImports) !== "undefined") { imports.env = wasmImports; diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 9339ae69973909..e19710f79afa7f 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -6399,14 +6399,6 @@ GenTree* Lowering::LowerDirectCall(GenTreeCall* call) // For JIT helper based tailcall (only used on x86) the target // address is passed as an arg to the helper so we want a node for // it. -#ifdef TARGET_WASMARCH - if (m_compiler->IsReadyToRun()) - { - // IAT_VALUE identifies a directly callable symbol rather than a portable entrypoint cell. - call->gtDirectCallAddress = addr; - break; - } -#endif if (!IsCallTargetInRange(addr) || call->IsTailCallViaJitHelper()) { result = AddrGen(addr); @@ -7308,18 +7300,6 @@ GenTree* Lowering::LowerNonvirtPinvokeCall(GenTreeCall* call) switch (lookup.accessType) { case IAT_VALUE: -#ifdef TARGET_WASMARCH - if (m_compiler->IsReadyToRun()) - { - // IAT_VALUE identifies a native function imported by symbol, which is called directly. - call->gtDirectCallAddress = addr; -#ifdef FEATURE_READYTORUN - call->gtEntryPoint.addr = nullptr; - call->gtEntryPoint.accessType = IAT_VALUE; -#endif - break; - } -#endif // IsCallTargetInRange always return true on x64. It wants to use rip-based addressing // for this call. Unfortunately, in case of already resolved pinvokes to external libs, // which are identified via accessType: IAT_VALUE, the relative offset is unlikely to diff --git a/src/coreclr/jit/lowerwasm.cpp b/src/coreclr/jit/lowerwasm.cpp index 7dc46aadbf8951..0a6ce2660fffb3 100644 --- a/src/coreclr/jit/lowerwasm.cpp +++ b/src/coreclr/jit/lowerwasm.cpp @@ -35,11 +35,12 @@ void Lowering::SetMultiplyUsed(GenTree* node DEBUGARG(const char* reason)) // IsCallTargetInRange: Can a call target address be encoded in-place? // // Return Value: -// False when PEP is enabled, true when it is not enabled. +// True when PEP is disabled or this is ReadyToRun, where direct call targets are function symbols that can +// be encoded directly even with PEP codegen. // bool Lowering::IsCallTargetInRange(void* addr) { - return !m_compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PORTABLE_ENTRY_POINTS); + return !m_compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PORTABLE_ENTRY_POINTS) || m_compiler->IsReadyToRun(); } //--------------------------------------------------------------------------------------------- diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs index 963bf3b2c548d2..d0205c84419b76 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/WasmArgumentLayoutTests.cs @@ -1404,7 +1404,6 @@ public UnsupportedOSPlatformAttribute(string platform) { } int repeatExitCode = PortableCallHelpersGenerator.Run(context, options, new Logger(log, isVerbose: false)); Assert.True(repeatExitCode == 0, log.ToString()); Assert.Equal(table, File.ReadAllText(Path.Combine(options.OutputDirectory, "callhelpers-pinvoke.cpp"))); - } finally { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs index e94697aca906a7..f3e9de567fa83d 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs @@ -814,13 +814,6 @@ public override int GetHashCode() } private NodeCache _pInvokeTargetNodes = new NodeCache(); - private NodeCache<(string ImportModule, string ImportName, MethodSignature Signature), ExternFunctionSymbolNode> _wasmImportLinkagePInvokeTargets = - new NodeCache<(string ImportModule, string ImportName, MethodSignature Signature), ExternFunctionSymbolNode>(key => - { - Utf8String symbolName = new Utf8String($"{key.ImportModule}#{key.ImportName}"); - return new ExternFunctionSymbolNode(symbolName, key.Signature, isUnmanagedCallersOnly: true, isAsyncCall: false, hasGenericContextArg: false, - new WasmLinkageMetadata(new Utf8String(key.ImportName), new Utf8String(key.ImportModule))); - }); public Import GetIndirectPInvokeTargetNode(MethodWithToken methodWithToken) { @@ -832,6 +825,14 @@ public Import GetPInvokeTargetNode(MethodWithToken methodWithToken) return _pInvokeTargetNodes.GetOrAdd(new PInvokeTargetKey(methodWithToken, isIndirect: false)); } + private NodeCache<(string ImportModule, string ImportName, MethodSignature Signature), ExternFunctionSymbolNode> _wasmImportLinkagePInvokeTargets = + new NodeCache<(string ImportModule, string ImportName, MethodSignature Signature), ExternFunctionSymbolNode>(key => + { + Utf8String symbolName = new Utf8String($"{key.ImportModule}#{key.ImportName}"); + return new ExternFunctionSymbolNode(symbolName, key.Signature, isUnmanagedCallersOnly: true, isAsyncCall: false, hasGenericContextArg: false, + new WasmLinkageMetadata(new Utf8String(key.ImportName), new Utf8String(key.ImportModule))); + }); + /// /// A native function a Wasm image imports and calls directly through WasmImportLinkage. /// diff --git a/src/coreclr/vm/wasm/generate-coreclr-helpers.proj b/src/coreclr/vm/wasm/generate-coreclr-helpers.proj index 5c873e4ec3bc04..627b095bb5f19f 100644 --- a/src/coreclr/vm/wasm/generate-coreclr-helpers.proj +++ b/src/coreclr/vm/wasm/generate-coreclr-helpers.proj @@ -152,7 +152,6 @@ - diff --git a/src/native/libs/Common/JavaScript/host/assets.ts b/src/native/libs/Common/JavaScript/host/assets.ts index cf768bbb42f71c..20e4331b357f37 100644 --- a/src/native/libs/Common/JavaScript/host/assets.ts +++ b/src/native/libs/Common/JavaScript/host/assets.ts @@ -10,7 +10,7 @@ const hasInstantiateStreaming = typeof WebAssembly !== "undefined" && typeof Web const loadedAssemblies: Map = new Map(); // Self-installing wrapper version; keep in sync with WebcilConstants.WASM_WRAPPER_VERSION_SELF_INSTALLING. const webcilWrapperVersion = 2; -let runtimeModuleImports: WebAssembly.Imports | undefined; +let hostImports: WebAssembly.Imports | undefined; export function registerPdbBytes(bytes: Uint8Array, virtualPath: string, shortName: string) { const sp = _ems_.stackSave(); @@ -63,10 +63,10 @@ export async function instantiateWebcilModule(webcilPromise: Promise, try { payloadPtr = allocWebcilPayload(payloadSize); const webcilImports = buildWebcilImports(memory, payloadPtr, tableEntries); - // R2R images import [WasmImportLinkage] P/Invoke targets from the P/Invoke's own module, which the - // runtime module also imports. + // R2R Webcil images have tableEntries > 0; IL-only Webcil images have no table. R2R images use the + // host-provided imports to resolve [WasmImportLinkage] P/Invokes from their declared modules. const imports: WebAssembly.Imports = tableEntries > 0 - ? { ...runtimeModuleImports, webcil: webcilImports } + ? { ...hostImports, webcil: webcilImports } : { webcil: webcilImports }; let instance: WebAssembly.Instance; const contentType = res.headers && res.headers.get ? res.headers.get("Content-Type") : undefined; @@ -244,7 +244,7 @@ export function installVfsFile(bytes: Uint8Array, asset: VfsAsset) { export async function instantiateWasm(wasmPromise: Promise, imports: WebAssembly.Imports): Promise<{ instance: WebAssembly.Instance; module: WebAssembly.Module; }> { let instance: WebAssembly.Instance; let module: WebAssembly.Module; - runtimeModuleImports = imports; + hostImports = imports; try { const res = await checkResponseOk(wasmPromise); if (!hasInstantiateStreaming || !res.isStreamingOk) {