Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions docs/design/mono/webcil.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,40 @@ In particular, `payloadSize` is still a little-endian `u32`; `getWebcilSize` wri
4 bytes, and its `memory.init` source offset and length operands remain `i32`.
Memory64 is not supported by the passive version 0 wrapper.

##### Memory64 ReadyToRun wrappers

A memory64 ReadyToRun wrapper follows the same rules with pointer-sized `i64` values. It imports an
`i64` memory, a table64 `__indirect_function_table` whose operands and element segment offset are
`i64`, and `i64` `__memory_base` and `__table_base` globals. The runtime globals it imports, such as
`__stack_pointer`, are also `i64`. The host supplies `__memory_base` and `__table_base` as immutable
`i64` `WebAssembly.Global` values with JavaScript `BigInt` values.

`patchWebcilHeader` takes `(param $d i64) (param $n i32)`. The `TableBase` field of the `WebcilHeader`
stays a 32-bit value, so the function wraps `__table_base` to 32 bits with `i32.wrap_i64` before the
`i32.store`. `payloadSize` and `tableSize` in data segment 0 remain little-endian `u32` values.

``` wat
;; ReadyToRun image, memory64.
(module
(import "webcil" "memory" (memory (;0;) i64 1))
(import "webcil" "__stack_pointer" (global (;0;) (mut i64)))
(import "webcil" "__memory_base" (global (;1;) i64))
(import "webcil" "__table_base" (global (;2;) i64))
(import "webcil" "__indirect_function_table" (table (;0;) i64 1 funcref))
(func (export "patchWebcilHeader") (param $d i64) (param $n i32) (result)
local.get 1
i32.const 32
i32.ge_s
if
local.get 0
global.get 2
i32.wrap_i64
i32.store offset=28
end
)
(elem (;0;) (global.get 2) func 2)) ;; active at __table_base
```

##### WASI host composition

WASI hosts use offline composition rather than instantiating R2R modules at runtime.
Expand Down
3 changes: 1 addition & 2 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,7 @@
<ItemGroup>
<!-- crossgen2/ILC have dependencies on the JITs, so build them if the cross component includes crossgen2/ILC. -->
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWasmArch)' != 'true' and ($(_subset.Contains('+clr.tools+')) or $(_subset.Contains('+clr.nativecorelib+')) or $(_subset.Contains('+clr.crossarchtools+')))" Include="ClrJitSubset=true" />
<!-- When targeting WebAssembly, only build the wasm JIT for the cross component. wasm64 has no JIT yet,
so this builds only the JIT interface that crossgen2 needs to generate interpreter call helpers. -->
<!-- When targeting WebAssembly, only build the wasm JIT for the cross component. -->
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWasmArch)' == 'true' and ($(_subset.Contains('+clr.tools+')) or $(_subset.Contains('+clr.nativecorelib+')) or $(_subset.Contains('+clr.crossarchtools+')))" Include="ClrWasmJitSubset=true" />
<!-- When targeting Windows, we need to build a copy of the diagnostic libraries that can run on the host to enable remote debugging of a local build. -->
<_CrossToolSubset Condition="'$(_BuildCrossComponents)' == 'true' and '$(TargetsWindows)' == 'true'" Include="ClrDebugSubset=true" />
Expand Down
2 changes: 1 addition & 1 deletion eng/codeOptimization.targets
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<PublishReadyToRunPgoFiles Condition="'$(IncludeMibcFilesInReadyToRun)' == 'true'" Include="@(MergedMibcFile)"/>
</ItemGroup>

<PropertyGroup Condition="'$(IncludeMibcFilesInReadyToRun)' == 'true' and '$(TargetArchitecture)' != 'wasm'">
<PropertyGroup Condition="'$(IncludeMibcFilesInReadyToRun)' == 'true' and '$(TargetsWasmArch)' != 'true'">
<PublishReadyToRunCrossgen2ExtraArgs>$(PublishReadyToRunCrossgen2ExtraArgs);--embed-pgo-data</PublishReadyToRunCrossgen2ExtraArgs>
</PropertyGroup>
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ parameters:
isExtraPlatformsBuild: false
platforms: []
useHelixMonitor: false
runReadyToRunTests: true

jobs:

Expand Down Expand Up @@ -39,16 +38,15 @@ jobs:
useHelixMonitor: ${{ parameters.useHelixMonitor }}
# CrossgenFramework skips wasm, so regenerate CORE_ROOT from the same BCL
# bits and enable Crossgen2 only for test assemblies on Helix.
- ${{ if eq(parameters.runReadyToRunTests, true) }}:
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
parameters:
creator: dotnet-bot
readyToRun: true
testBuildArgs: generatelayoutonly crossgen2 -os browser /p:HostConfiguration=Release
testRunNamePrefixSuffix: CoreCLR_R2R_CG2_$(_BuildConfig)
timeoutPerTestInMinutes: 30
timeoutPerTestCollectionInMinutes: 90
useHelixMonitor: ${{ parameters.useHelixMonitor }}
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
parameters:
creator: dotnet-bot
readyToRun: true
testBuildArgs: generatelayoutonly crossgen2 -os browser /p:HostConfiguration=Release
testRunNamePrefixSuffix: CoreCLR_R2R_CG2_$(_BuildConfig)
timeoutPerTestInMinutes: 30
timeoutPerTestCollectionInMinutes: 90
useHelixMonitor: ${{ parameters.useHelixMonitor }}
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
parameters:
Expand Down
2 changes: 0 additions & 2 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ extends:
platforms:
- browser_wasm64
nameSuffix: CoreCLR_ReleaseLibraries
# browser-wasm64 runs on the interpreter until ReadyToRun support is added.
runReadyToRunTests: false
useHelixMonitor: ${{ variables.enableHelixJobMonitor }}
condition: >-
or(
Expand Down
1 change: 1 addition & 0 deletions eng/restore/optimizationData.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<MIBCPackageDef Include="optimization.linux-x64.mibc.runtime" Version="$(optimizationlinuxx64MIBCRuntimeVersion)" MibcArchitecture="linux/x64"/>
<MIBCPackageDef Include="optimization.linux-arm64.mibc.runtime" Version="$(optimizationlinuxarm64MIBCRuntimeVersion)" MibcArchitecture="linux/arm64"/>
<MIBCPackageDef Include="optimization.browser-wasm.mibc.runtime" Version="$(optimizationbrowserwasmMIBCRuntimeVersion)" MibcArchitecture="browser/wasm"/>
<MIBCPackageDef Include="optimization.browser-wasm.mibc.runtime" Version="$(optimizationbrowserwasmMIBCRuntimeVersion)" MibcArchitecture="browser/wasm64"/>

<!-- Mibc data to use when exact architecture match not available -->
<MIBCPackageDef Include="optimization.windows_nt-x64.mibc.runtime" Version="$(optimizationwindows_ntx64MIBCRuntimeVersion)" MibcArchitecture="windows"/>
Expand Down
9 changes: 3 additions & 6 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,9 @@ if(CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASMARCH)
add_subdirectory(nativeresources)
add_subdirectory(dlls/mscorrc)
endif (CLR_CMAKE_HOST_UNIX)
# There is no wasm64 JIT yet, so wasm64 cross-component builds produce only the jitinterface.
if(NOT CLR_CMAKE_TARGET_ARCH_WASM64)
add_subdirectory(utilcode)
add_subdirectory(gcinfo)
add_subdirectory(jit)
endif()
add_subdirectory(utilcode)
add_subdirectory(gcinfo)
add_subdirectory(jit)
return()
endif()

Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.Build.NoTargets">

<Import Project="$(WasmPInvokeModulesPropsPath)"
Condition="'$(TargetArchitecture)' == 'wasm'" />
Condition="'$(TargetsWasmArch)' == 'true'" />

<ItemGroup>
<ProjectReference Include="$(CoreClrProjectRoot)runtime.proj"
Expand Down Expand Up @@ -46,8 +46,6 @@
<PublishReadyToRun>true</PublishReadyToRun>
<!-- Disable crossgen on NetBSD, illumos, Solaris and Haiku for now. This can be revisited when we have full support. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</PublishReadyToRun>
<!-- wasm64 runs on the interpreter until ReadyToRun support is added. -->
<PublishReadyToRun Condition="'$(TargetsWasm64)' == 'true'">false</PublishReadyToRun>

<CrossgenTargetName Condition="!$(PublishReadyToRun)">CopyILCoreLib</CrossgenTargetName>

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/gcinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,8 @@ endif (NOT CLR_CMAKE_TARGET_ARCH_RISCV64)
if (CLR_CMAKE_TARGET_ARCH_WASMARCH)
create_gcinfo_lib(TARGET gcinfo_unix_wasm OS browser ARCH wasm)
create_gcinfo_lib(TARGET gcinfo_universal_wasm OS universal ARCH wasm)
if (CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM64)
create_gcinfo_lib(TARGET gcinfo_universal_wasm64 OS universal ARCH wasm64)
endif()
install_clr(TARGETS gcinfo_unix_wasm DESTINATIONS sharedFramework COMPONENT runtime)
endif (CLR_CMAKE_TARGET_ARCH_WASMARCH)
2 changes: 2 additions & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ enum class CorInfoReloc
WASM_METHOD_RELATIVE_VIRTUAL_IP_I32, // Wasm: the current method's virtual IP relative to the image virtual IP base, stored as a 4-byte uint32.
WASM_METHOD_FRAME_IDENTITY_SLEB, // Wasm: the current method's runtime-specific shadow-frame identity, encoded as a 5-byte varint32.
WASM_DEFERRED_CALL, // Wasm: metadata for a deferred direct call; the target is its exact signature handle and the location is its first immediate byte. Does not write bytes.
WASM_METHOD_RELATIVE_VIRTUAL_IP_I64, // Wasm: the current method's virtual IP relative to the image virtual IP base, stored as an 8-byte uint64.
};

enum CorInfoGCType
Expand Down Expand Up @@ -1733,6 +1734,7 @@ enum CorInfoArch
CORINFO_ARCH_LOONGARCH64,
CORINFO_ARCH_RISCV64,
CORINFO_ARCH_WASM32,
CORINFO_ARCH_WASM64,
};

enum CORINFO_OS
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

#include <minipal/guid.h>

constexpr GUID JITEEVersionIdentifier = { /* c77c1a0f-c8c6-4a68-90db-4d8c1253c5ea */
0xc77c1a0f,
0xc8c6,
0x4a68,
{0x90, 0xdb, 0x4d, 0x8c, 0x12, 0x53, 0xc5, 0xea}
constexpr GUID JITEEVersionIdentifier = { /* d8f122f8-1793-4be8-964b-26bc38ea9fa6 */
0xd8f122f8,
0x1793,
0x4be8,
{0x96, 0x4b, 0x26, 0xbc, 0x38, 0xea, 0x9f, 0xa6}
};

#endif // JIT_EE_VERSIONING_GUID_H
9 changes: 6 additions & 3 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@
JITHELPER(CORINFO_HELP_LRSZ, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_LMUL, NULL, METHOD__NIL)
#endif // TARGET_64BIT
#ifndef TARGET_64BIT
#if !defined(TARGET_64BIT) || defined(TARGET_WASMARCH)
DYNAMICJITHELPER(CORINFO_HELP_LMUL_OVF, NULL, METHOD__MATH__MULTIPLY_CHECKED_INT64)
DYNAMICJITHELPER(CORINFO_HELP_ULMUL_OVF, NULL, METHOD__MATH__MULTIPLY_CHECKED_UINT64)
#else
JITHELPER(CORINFO_HELP_LMUL_OVF, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULMUL_OVF, NULL, METHOD__NIL)
#endif
#ifndef TARGET_64BIT
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
JITHELPER(CORINFO_HELP_LDIV, JIT_LDiv, METHOD__NIL)
JITHELPER(CORINFO_HELP_LMOD, JIT_LMod, METHOD__NIL)
Expand All @@ -78,8 +83,6 @@
DYNAMICJITHELPER(CORINFO_HELP_ULMOD, NULL, METHOD__MATH__MOD_UINT64)
#endif // TARGET_X86 && TARGET_WINDOWS
#else // TARGET_64BIT
JITHELPER(CORINFO_HELP_LMUL_OVF, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULMUL_OVF, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_LDIV, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_LMOD, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULDIV, NULL, METHOD__NIL)
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function(create_standalone_jit)
elseif(TARGETDETAILS_ARCH STREQUAL "riscv64")
set(JIT_ARCH_SOURCES ${JIT_RISCV64_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_RISCV64_HEADERS})
elseif(TARGETDETAILS_ARCH STREQUAL "wasm")
elseif(TARGETDETAILS_ARCH STREQUAL "wasm" OR TARGETDETAILS_ARCH STREQUAL "wasm64")
set(JIT_ARCH_SOURCES ${JIT_WASM_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_WASM_HEADERS})
else()
Expand All @@ -84,7 +84,7 @@ function(create_standalone_jit)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_MASKED_HW_INTRINSICS)
endif ()

if (TARGETDETAILS_ARCH STREQUAL "wasm")
if (TARGETDETAILS_ARCH STREQUAL "wasm" OR TARGETDETAILS_ARCH STREQUAL "wasm64")
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_SIMD)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_HW_INTRINSICS)
endif ()
Expand Down Expand Up @@ -743,7 +743,7 @@ if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)

if (CLR_CMAKE_TARGET_ARCH_WASMARCH)
create_standalone_jit(TARGET clrjit_universal_wasm_${ARCH_HOST_NAME} OS universal ARCH wasm)
create_standalone_jit(TARGET clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} OS universal ARCH ${ARCH_TARGET_NAME})
endif (CLR_CMAKE_TARGET_ARCH_WASMARCH)

if (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
Expand All @@ -759,7 +759,7 @@ else()
endif (CLR_CMAKE_TARGET_ARCH_RISCV64)

if (CLR_CMAKE_TARGET_UNIX)
if (NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le AND NOT ARCH_TARGET_NAME STREQUAL riscv64 AND NOT ARCH_TARGET_NAME STREQUAL wasm)
if (NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le AND NOT ARCH_TARGET_NAME STREQUAL riscv64 AND NOT CLR_CMAKE_TARGET_ARCH_WASMARCH)
if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
install_clr(TARGETS clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit)
else()
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,9 @@ class CodeGen final : public CodeGenInterface

void genCompareFloat(GenTreeOp* treeNode);
void genCompareInt(GenTreeOp* treeNode);
#ifdef TARGET_WASMARCH
void genWidenCompareResult(GenTreeOp* treeNode);
#endif // TARGET_WASMARCH
#ifdef TARGET_XARCH
bool genCanAvoidEmittingCompareAgainstZero(GenTree* tree, emitAttr opSize);
GenTree* genTryFindFlagsConsumer(GenTree* flagsProducer, GenCondition** condition);
Expand Down
Loading
Loading