Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4059107
[wasi][coreclr] Enable WasmEnableRelaxedSimd by default on CoreCLR WASI
lewing Nov 6, 2026
0c78503
Quarantine WASI R2R tests that depend on R2R CoreLib against #134949
lewing Nov 6, 2026
1190148
Enable wasm relaxed SIMD from the crossgen2 instruction set alone
lewing Nov 6, 2026
bfb5daf
Clarify the WASI relaxed SIMD default comment
lewing Nov 6, 2026
8bffd8d
Make PublishRelaxedSimdCoreClr exercise relaxed SIMD
lewing Nov 6, 2026
9fa237a
Don't document interpreted RelaxedSimd.IsSupported as intended behavior
lewing Nov 6, 2026
20cf330
Trim relaxed SIMD docs and comments
lewing Nov 6, 2026
03aa29d
Compile CoreLib with relaxed SIMD in the browser HW-intrinsics leg
lewing Nov 6, 2026
246d787
Make relaxed SIMD a WASI compiler default and validate images against…
lewing Nov 8, 2026
27c0885
Run the wasm intrinsics library tests on WASI
lewing Nov 8, 2026
88cc58f
Merge origin/main into lewing-wasi-relaxed-simd-opt-in
lewing Nov 10, 2026
43dbf22
Merge remote-tracking branch 'origin/main' into lewing-wasi-relaxed-s…
lewing Nov 12, 2026
907eec7
Run the WASI wasm intrinsics tests in whole-program composite mode
lewing Nov 12, 2026
34951da
[wasm][nativeaot] Enable PackedSimd for NativeAOT
lewing Nov 6, 2026
ed71d5c
[wasm][nativeaot] Enable RelaxedSimd for NativeAOT from WasmEnableRel…
lewing Nov 6, 2026
6f87a73
Revert the WASI note in the NativeAOT optimizing doc
lewing Nov 8, 2026
ec2b87b
Rely on the compiler's WASI relaxed SIMD default for NativeAOT
lewing Nov 8, 2026
50e1d30
Forward IlcInstructionSet to the src/tests inner build
lewing Nov 8, 2026
3fc5ae1
Simplify the wasm IsSupported fold in resolveId
lewing Nov 8, 2026
361d116
Enable wasm intrinsics for every wasm CoreLib
lewing Nov 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/workflow/building/coreclr/wasi-r2r.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ of the number of function definitions; table slots may contain duplicate or non-
references.
Non-composite R2R and `WasmSingleFileBundle` are not supported by this path.

Relaxed SIMD is a default WASI instruction set. Hosts without relaxed SIMD fail to load the composite; publish with
`-p:PublishReadyToRunInstructionSet=-relaxed-simd` for them.

## Runtime tests

The WASI runtime-test pipeline keeps separate interpreter and `R2R_CG2` jobs. The R2R job uses
Expand Down
13 changes: 12 additions & 1 deletion eng/pipelines/coreclr/hardware-intrinsics-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ pr:
include:
- eng/pipelines/coreclr/hardware-intrinsics-wasm.yml
- eng/pipelines/coreclr/templates/jit-hardware-intrinsics-wasm.yml
- src/coreclr/crossgen-corelib.proj
- src/coreclr/jit/*wasm*
- src/tests/Directory.Build.targets
- src/tests/build.proj
- src/tests/JIT/HardwareIntrinsics/Wasm/**

variables:
Expand All @@ -28,4 +31,12 @@ extends:
parameters:
platforms:
- browser_wasm
testBuildArgs: '/p:WasmEnableRelaxedSimd=true -test:JIT/HardwareIntrinsics/HardwareIntrinsics_Wasm_r.csproj -test:JIT/HardwareIntrinsics/HardwareIntrinsics_Wasm_ro.csproj'
extraBuildArgs: /p:PublishReadyToRunInstructionSet=relaxed-simd
testBuildArgs: '/p:PublishReadyToRunInstructionSet=relaxed-simd -test:JIT/HardwareIntrinsics/HardwareIntrinsics_Wasm_r.csproj -test:JIT/HardwareIntrinsics/HardwareIntrinsics_Wasm_ro.csproj'
- template: /eng/pipelines/coreclr/templates/jit-hardware-intrinsics-wasm.yml
parameters:
platforms:
- wasi_wasm
# Compiles CoreLib into each test composite, so the tests can use relaxed SIMD.
extraHelixArguments: /p:WholeProgramCompositeBuildMode=true
testBuildArgs: '/p:PublishReadyToRunInstructionSet=relaxed-simd -test:JIT/HardwareIntrinsics/HardwareIntrinsics_Wasm_r.csproj -test:JIT/HardwareIntrinsics/HardwareIntrinsics_Wasm_ro.csproj'
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ parameters:
type: object
- name: testBuildArgs
type: string
- name: extraHelixArguments
type: string
default: ''
- name: extraBuildArgs
type: string
default: ''

jobs:
# Build CoreCLR + libraries for wasm, build the wasm HardwareIntrinsics tests,
Expand All @@ -22,7 +28,7 @@ jobs:
jobParameters:
testGroup: outerloop
nameSuffix: CoreCLR
buildArgs: -s clr+libs+packs -c $(_BuildConfig) /p:TestAssemblies=false
buildArgs: -s clr+libs+packs -c $(_BuildConfig) /p:TestAssemblies=false ${{ parameters.extraBuildArgs }}
timeoutInMinutes: 180
postBuildSteps:
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
Expand All @@ -32,6 +38,7 @@ jobs:
testRunNamePrefixSuffix: CoreCLR_R2R
# The CoreCLR interpreter does not implement Wasm SIMD; ReadyToRun code does.
readyToRun: true
extraHelixArguments: ${{ parameters.extraHelixArguments }}
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
parameters:
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@
<!-- wasm: enable cross-module inlining/optimization across the whole shared framework (the -r IL closure). -->
<_CoreLibCrossgen2ExtraArgs Include="--opt-cross-module:*"
Condition="'$(PublishReadyToRunContainerFormat)' == 'wasm'" />
<!-- On wasm, every ReadyToRun image must target the instruction sets CoreLib was compiled for. -->
<_CoreLibCrossgen2ExtraArgs Include="--instruction-set:$(PublishReadyToRunInstructionSet)"
Condition="'$(PublishReadyToRunInstructionSet)' != ''" />
<_CoreLibCrossgen2ExtraArgs Include="@(WasmCoreClrFrameworkPInvokeModule->WithMetadataValue('Browser', 'true')->WithMetadataValue('PrebuiltR2RDirect', 'true')->'--directpinvoke:%(Identity)')"
Condition="'$(PublishReadyToRunContainerFormat)' == 'wasm' and '$(TargetOS)' == 'browser'" />
<_CoreLibCrossgen2ExtraArgs Include="@(WasmCoreClrFrameworkPInvokeModule->WithMetadataValue('Wasi', 'true')->WithMetadataValue('PrebuiltR2RDirect', 'true')->'--directpinvoke:%(Identity)')"
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/hosts/corerun/wasi_r2r_probe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// calls out to it to obtain the composite R2R webcil image and the per-assembly stubs.
//
// The in-tree WASI R2R composer populates the image when publishing. The host must be linked with the
// flags that supply a composite's imports -- see WasiEnableCompositeR2R in WasiApp.CoreCLR.targets.
// flags that supply a composite's imports (see WasiApp.CoreCLR.targets).
// Without them this probe compiles but can never be satisfied.
//
// Requires corerun.hpp to be included first (for pal::try_map_file_readonly). Include exactly once per
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/hwintrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,10 @@ NamedIntrinsic HWIntrinsicInfo::resolveId(Compiler* comp,
if (isIsaSupported && comp->compSupportsHWIntrinsic(isa) &&
(vectorByteLength <= comp->getPreferredVectorByteLength()))
{
#ifdef TARGET_WASM
// Wasm has no runtime ISA detection, so the compile-time ISA support is exact.
return NI_IsSupported_True;
#else
if (!comp->IsTargetAbi(CORINFO_NATIVEAOT_ABI) || comp->compExactlyDependsOn(isa))
{
return NI_IsSupported_True;
Expand All @@ -1296,6 +1300,7 @@ NamedIntrinsic HWIntrinsicInfo::resolveId(Compiler* comp,
assert(comp->IsTargetAbi(CORINFO_NATIVEAOT_ABI));
return NI_IsSupported_Dynamic;
}
#endif
}

return NI_IsSupported_False;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ
}
else if (architecture is TargetArchitecture.Wasm32)
{
// TODO-WASM: return the correct intrinsic id once xplat intrinsics are implemented.
return "";
if (potentialType.Namespace != "System.Runtime.Intrinsics.Wasm"u8)
return "";
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/tools/Common/InstructionSetHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public static InstructionSetSupport ConfigureInstructionSetSupport(string instru
{
instructionSetSupportBuilder.AddSupportedInstructionSet("base");
instructionSetSupportBuilder.AddSupportedInstructionSet("simd128");

if (targetOS == TargetOS.Wasi)
{
instructionSetSupportBuilder.AddSupportedInstructionSet("relaxed-simd");
}
}

bool throttleAvx512 = false;
Expand Down
13 changes: 0 additions & 13 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,15 +1457,6 @@ extern "C" DWORD64 __stdcall GetDataCacheZeroIDReg();
extern "C" uint64_t GetSveLengthFromOS();
#endif

#ifdef TARGET_WASM
static bool s_wasmRelaxedSimdSupported;

extern "C" void coreclr_wasm_set_relaxed_simd_supported()
{
s_wasmRelaxedSimdSupported = true;
}
#endif

void EEJitManager::SetCpuInfo()
{
LIMITED_METHOD_CONTRACT;
Expand Down Expand Up @@ -1510,10 +1501,6 @@ void EEJitManager::SetCpuInfo()
#if defined(TARGET_WASM)
CPUCompileFlags.Set(InstructionSet_WasmBase);
CPUCompileFlags.Set(InstructionSet_PackedSimd);
if (s_wasmRelaxedSimdSupported)
{
CPUCompileFlags.Set(InstructionSet_RelaxedSimd);
}
#endif

#if defined(TARGET_X86) || defined(TARGET_AMD64)
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/vm/codeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -2341,6 +2341,15 @@ class EEJitManager final : public EECodeGenManager
return m_CPUCompileFlags;
}

#if defined(TARGET_WASM) && !defined(DACCESS_COMPILE)
// Wasm cannot detect instruction sets at run time; CoreLib's ReadyToRun image defines them.
void SetInstructionSetFromCoreLib(CORINFO_InstructionSet instructionSet)
{
LIMITED_METHOD_CONTRACT;
m_CPUCompileFlags.Set(instructionSet);
}
#endif

#if defined(TARGET_ARM64)
inline bool UseScalableVectorT()
{
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14637,6 +14637,15 @@ BOOL LoadDynamicInfoEntry(Module *currentModule,
DWORD instructionSetEncoded = CorSigUncompressData(pBlob);
bool mustInstructionSetBeSupported = !!(instructionSetEncoded & 1);
ReadyToRunInstructionSet instructionSet = (ReadyToRunInstructionSet)(instructionSetEncoded >> 1);
#ifdef TARGET_WASM
// Other images must match the instruction sets CoreLib was compiled for.
if (mustInstructionSetBeSupported && currentModule->IsSystem())
{
ExecutionManager::GetEEJitManager()->SetInstructionSetFromCoreLib(InstructionSetFromR2RInstructionSet(instructionSet));
corjitFlags = ExecutionManager::GetEEJitManager()->GetCPUCompileFlags();
continue;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is continue not return FALSE ?

}
#endif // TARGET_WASM
if (IsInstructionSetSupported(corjitFlags, instructionSet) != mustInstructionSetBeSupported)
{
return FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
<IsApplePlatform Condition="'$(TargetsOSX)' == 'true' or '$(IsiOSLike)' == 'true'">true</IsApplePlatform>
<IsMobileLike Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true' or '$(IsiOSLike)' == 'true' or '$(TargetsAndroid)' == 'true'">true</IsMobileLike>
<SupportsArmIntrinsics Condition="'$(Platform)' == 'arm64'">true</SupportsArmIntrinsics>
<SupportsWasmIntrinsics Condition="'$(Platform)' == 'wasm' and '$(FeatureMono)' == 'true'">true</SupportsWasmIntrinsics>
<SupportsWasmIntrinsics Condition="'$(Platform)' == 'wasm' and '$(FeatureCoreCLR)' == 'true'">true</SupportsWasmIntrinsics>
<SupportsWasmIntrinsics Condition="'$(Platform)' == 'wasm'">true</SupportsWasmIntrinsics>
<SupportsWasmIntrinsics Condition="'$(SupportsWasmIntrinsics)' == ''">false</SupportsWasmIntrinsics>
<!-- Mono does not implement RelaxedSimd, so it uses the PlatformNotSupported implementation. -->
<SupportsWasmRelaxedSimdIntrinsics Condition="'$(SupportsWasmIntrinsics)' == 'true' and '$(FeatureCoreCLR)' == 'true'">true</SupportsWasmRelaxedSimdIntrinsics>
<SupportsWasmRelaxedSimdIntrinsics Condition="'$(SupportsWasmIntrinsics)' == 'true' and '$(FeatureMono)' != 'true'">true</SupportsWasmRelaxedSimdIntrinsics>
<SupportsWasmRelaxedSimdIntrinsics Condition="'$(SupportsWasmRelaxedSimdIntrinsics)' == ''">false</SupportsWasmRelaxedSimdIntrinsics>
<SupportsX86Intrinsics Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'x86'">true</SupportsX86Intrinsics>
<SupportsX86Intrinsics Condition="'$(Platform)' == 'x86' and '$(FeatureMono)' == 'true'">false</SupportsX86Intrinsics>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<NoWarn>$(NoWarn),1718,SYSLIB0013</NoWarn>
<TestRuntime>true</TestRuntime>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi</TargetFrameworks>
<WasmEnableRelaxedSimd Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'CoreCLR'">true</WasmEnableRelaxedSimd>
<WasmWarnOnUnresolvedPInvokeModules Condition="'$(TargetOS)' == 'browser'">false</WasmWarnOnUnresolvedPInvokeModules>
<!-- Disable nullability public only feature for NullabilityInfoContextTests -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace System.Runtime.Intrinsics.Wasm.Tests
{
[PlatformSpecific(TestPlatforms.Browser)]
[PlatformSpecific(TestPlatforms.Browser | TestPlatforms.Wasi)]
[ConditionalClass(typeof(PackedSimdTests), nameof(IsSupported))]
public sealed class PackedSimdTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace System.Runtime.Intrinsics.Wasm.Tests
{
[PlatformSpecific(TestPlatforms.Browser)]
[PlatformSpecific(TestPlatforms.Browser | TestPlatforms.Wasi)]
public sealed class RelaxedSimdTests
{
public static bool IsNotSupported => !RelaxedSimd.IsSupported;
Expand Down
6 changes: 0 additions & 6 deletions src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@
<_ExeExt Condition="$([MSBuild]::IsOSPlatform('windows'))">.exe</_ExeExt>
</PropertyGroup>

<ItemGroup Condition="'$(WasmEnableRelaxedSimd)' == 'true'">
<RuntimeHostConfigurationOption Include="System.Runtime.Intrinsics.Wasm.RelaxedSimd.IsSupported"
Value="true"
Trim="true" />
</ItemGroup>

<!-- EmccInitialHeapSize is the documented browser property (src/mono/browser/README.md) and
EmccTotalMemory is its legacy alias; the Mono path collapses both into WasmInitialHeapSize
(BrowserWasmApp.targets). Do the same here at evaluation time so the relink registry in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<PublishReadyToRunCrossgen2ExtraArgs Condition="'$(WasmEnableRelaxedSimd)' == 'true'">$(PublishReadyToRunCrossgen2ExtraArgs);--instruction-set:relaxed-simd</PublishReadyToRunCrossgen2ExtraArgs>
</PropertyGroup>

<ItemGroup Condition="'$(WasmEnableRelaxedSimd)' == 'true'">
<RuntimeHostConfigurationOption Include="System.Runtime.Intrinsics.Wasm.RelaxedSimd.IsSupported"
Value="true"
Trim="true" />
</ItemGroup>

<!-- Prebuilt R2R probe directory for ConvertDllsToWebcil. PublishTrimmed is deliberately not consulted:
publish always crossgens the whole closure, so framework and app R2R both come from obj/R2R. Only the
dev-loop build differs - it never crossgens, so its BCL comes from the runtime pack's R2R images.
Expand Down
15 changes: 4 additions & 11 deletions src/mono/wasi/build/WasiApp.CoreCLR.targets
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<PublishReadyToRunContainerFormat Condition="'$(PublishReadyToRunContainerFormat)' == '' or '$(PublishReadyToRunContainerFormat)' == 'pe'">wasm</PublishReadyToRunContainerFormat>
<PublishReadyToRunComposite Condition="'$(PublishReadyToRunComposite)' == ''">true</PublishReadyToRunComposite>
<PublishReadyToRunCrossgen2ExtraArgs>$(PublishReadyToRunCrossgen2ExtraArgs);--opt-cross-module:*</PublishReadyToRunCrossgen2ExtraArgs>
<WasiEnableCompositeR2R Condition="'$(WasiEnableCompositeR2R)' == ''">true</WasiEnableCompositeR2R>
<!-- Run wasm-opt over the composed module. Off by default so codegen problems surface in crossgen2's
output instead of being optimized away. -->
<WasiR2ROptimizeComposite Condition="'$(WasiR2ROptimizeComposite)' == ''">false</WasiR2ROptimizeComposite>
Expand All @@ -93,8 +92,6 @@
Text="PublishReadyToRunContainerFormat '$(PublishReadyToRunContainerFormat)' is not supported for CoreCLR wasi-wasm; only 'wasm' is supported." />
<Error Condition="'$(WasmSingleFileBundle)' == 'true'"
Text="CoreCLR ReadyToRun publishing for wasi-wasm does not support WasmSingleFileBundle." />
<Error Condition="'$(WasiEnableCompositeR2R)' != 'true'"
Text="CoreCLR ReadyToRun publishing for wasi-wasm requires WasiEnableCompositeR2R=true." />
</Target>

<Target Name="_WasiCoreCLRSetRuntimePaths"
Expand Down Expand Up @@ -429,10 +426,6 @@
<PropertyGroup>
<_WasiRelinkOutput>$(_WasiRelinkObjDir)corerun</_WasiRelinkOutput>
<_WasiPublishedHost>$(WasmAppDir)managed\corerun</_WasiPublishedHost>
<!-- Opt-in: link the app host so a composite ReadyToRun image can be spliced into it afterwards
(see docs/workflow/building/coreclr/wasi-r2r.md). Off by default because the table reservation below is a fixed
cost paid by every app whether or not it is ever spliced. -->
<WasiEnableCompositeR2R Condition="'$(WasiEnableCompositeR2R)' == ''">false</WasiEnableCompositeR2R>
<!-- Table slots 1..N-1 are reserved for the composite's ACTIVE element segment, which the engine
installs at instantiation - so the table must already be large enough. Reserve by the
element segment's slot count, independently of how many function definitions those slots reference. -->
Expand All @@ -450,10 +443,10 @@
<!-- The remaining imports a composed composite needs from its host. The per-app host carries the
probe (wasi_r2r_probe.hpp, via libWasiHost.a), so without them the probe is present but can
never be satisfied and the app silently interprets everything. -->
<_WasiRelinkLinkFlags Include="-Wl,--table-base=$(WasiCompositeR2RTableBase)" Condition="'$(WasiEnableCompositeR2R)' == 'true'" />
<_WasiRelinkLinkFlags Include="-Wl,--export-table" Condition="'$(WasiEnableCompositeR2R)' == 'true'" />
<_WasiRelinkLinkFlags Include="-Wl,--export=__stack_pointer" Condition="'$(WasiEnableCompositeR2R)' == 'true'" />
<_WasiRelinkLinkFlags Include="-Wl,--export=__coreclr_wasm_rtlrestorecontext_tag" Condition="'$(WasiEnableCompositeR2R)' == 'true'" />
<_WasiRelinkLinkFlags Include="-Wl,--table-base=$(WasiCompositeR2RTableBase)" Condition="'$(PublishReadyToRun)' == 'true'" />
<_WasiRelinkLinkFlags Include="-Wl,--export-table" Condition="'$(PublishReadyToRun)' == 'true'" />
<_WasiRelinkLinkFlags Include="-Wl,--export=__stack_pointer" Condition="'$(PublishReadyToRun)' == 'true'" />
<_WasiRelinkLinkFlags Include="-Wl,--export=__coreclr_wasm_rtlrestorecontext_tag" Condition="'$(PublishReadyToRun)' == 'true'" />
<_WasiRelinkLinkFlags Include="-fwasm-exceptions" />
<_WasiRelinkLinkFlags Include="-mllvm" />
<_WasiRelinkLinkFlags Include="-wasm-use-legacy-eh=false" />
Expand Down
Loading
Loading