Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@
<PlatformManifestFileEntry Include="libmono-profiler-browser.a" IsNative="true" />
<PlatformManifestFileEntry Include="libmono-wasm-eh-js.a" IsNative="true" />
<PlatformManifestFileEntry Include="libmono-wasm-eh-wasm.a" IsNative="true" />
<PlatformManifestFileEntry Include="libmono-wasm-simd.a" IsNative="true" />
<PlatformManifestFileEntry Include="libmono-wasm-nosimd.a" IsNative="true" />
<PlatformManifestFileEntry Include="wasm-bundled-timezones.a" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet.js.map" IsNative="true" />
Expand Down
8 changes: 0 additions & 8 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,6 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "emscripten")
add_compile_options(-Wno-strict-prototypes)
add_compile_options(-Wno-unused-but-set-variable)
add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
# Allow using WASM simd intrinsics in the interpreter
add_compile_options(-msimd128)
# Disable autovectorization (it is automatically turned on by msimd128)
add_compile_options(-disable-loop-vectorization)
add_compile_options(-disable-vectorization)
add_compile_options(-fno-vectorize)
add_compile_options(-fno-tree-vectorize)
add_compile_options(-fno-slp-vectorize)
set(DISABLE_EXECUTABLES 1)
# FIXME: Is there a cmake option for this ?
set(DISABLE_SHARED_LIBS 1)
Expand Down
6 changes: 6 additions & 0 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,12 @@
<_MonoRuntimeArtifacts Condition="'$(TargetsBrowser)' == 'true' and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)out\lib\libmono-wasm-eh-wasm.a">
<Destination>$(RuntimeBinDir)libmono-wasm-eh-wasm.a</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true') and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)out\lib\libmono-wasm-simd.a">
<Destination>$(RuntimeBinDir)libmono-wasm-simd.a</Destination>
</_MonoRuntimeArtifacts>
<_MonoRuntimeArtifacts Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true') and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)out\lib\libmono-wasm-nosimd.a">
<Destination>$(RuntimeBinDir)libmono-wasm-nosimd.a</Destination>
</_MonoRuntimeArtifacts>
<_MonoICorDebugArtifacts Condition="'$(MonoMsCorDbi)' == 'true'" Include="$(MonoObjDir)out\lib\$(LibPrefix)mscordbi$(LibSuffix)">
<Destination>$(RuntimeBinDir)$(LibPrefix)mscordbi$(LibSuffix)</Destination>
</_MonoICorDebugArtifacts>
Expand Down
25 changes: 23 additions & 2 deletions src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ set(interp_sources
interp/interp.h
interp/interp-internals.h
interp/interp.c
interp/interp-simd.c
interp/interp-intrins.h
interp/interp-intrins.c
interp/mintops.h
Expand All @@ -297,11 +296,17 @@ set(interp_sources
interp/tiering.h
interp/tiering.c
interp/jiterpreter.c)
set(interp_simd_sources
interp/interp-simd.c)
set(interp_stub_sources
interp-stubs.c)

if(NOT DISABLE_INTERPRETER)
set(mini_interp_sources ${interp_sources})
if(HOST_WASM)
set(mini_interp_sources ${interp_sources})
else()
set(mini_interp_sources ${interp_sources} ${interp_simd_sources})
endif()
else()
set(mini_interp_sources ${interp_stub_sources})
endif()
Expand Down Expand Up @@ -504,6 +509,19 @@ if(HOST_BROWSER)
install(TARGETS mono-wasm-eh-wasm LIBRARY)
endif()

if(HOST_BROWSER OR HOST_WASI)
add_library(mono-wasm-simd STATIC interp/interp-simd.c)
target_link_libraries (mono-wasm-simd PRIVATE monoapi eglib_api)
set_target_properties(mono-wasm-simd PROPERTIES COMPILE_FLAGS "-msimd128")
install(TARGETS mono-wasm-simd LIBRARY)
endif()

if(HOST_BROWSER OR HOST_WASI OR TARGET_WASM)
add_library(mono-wasm-nosimd STATIC interp/interp-nosimd.c)
target_link_libraries (mono-wasm-nosimd PRIVATE monoapi eglib_api)
install(TARGETS mono-wasm-nosimd LIBRARY)
endif()

find_package(Python3 COMPONENTS Interpreter)

add_custom_command(
Expand Down Expand Up @@ -576,6 +594,9 @@ if(NOT DISABLE_EXECUTABLES)
endif()
endif()
target_link_libraries(mono-sgen PRIVATE monoapi eglib_api monosgen-static)
if (HOST_WASM)
target_link_libraries(mono-sgen PRIVATE mono-wasm-nosimd)
endif()
if(HAVE_ICU_SHIM)
target_link_libraries(mono-sgen PRIVATE icu_shim_objects)
endif()
Expand Down
31 changes: 31 additions & 0 deletions src/mono/mono/mini/interp/interp-nosimd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

#include "interp-internals.h"
#include "interp-simd.h"

#ifdef INTERP_ENABLE_SIMD

gboolean interp_simd_enabled = FALSE;

#ifdef HOST_BROWSER

int interp_simd_p_p_wasm_opcode_table [] = {
};

int interp_simd_p_pp_wasm_opcode_table [] = {
};

int interp_simd_p_ppp_wasm_opcode_table [] = {
};

#endif // HOST_BROWSER

PP_SIMD_Method interp_simd_p_p_table [] = {
};

PPP_SIMD_Method interp_simd_p_pp_table [] = {
};

PPPP_SIMD_Method interp_simd_p_ppp_table [] = {
};

#endif // INTERP_ENABLE_SIMD
2 changes: 2 additions & 0 deletions src/mono/mono/mini/interp/interp-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#ifdef INTERP_ENABLE_SIMD

gboolean interp_simd_enabled = TRUE;

typedef gint64 v128_i8 __attribute__ ((vector_size (SIZEOF_V128)));
typedef guint64 v128_u8 __attribute__ ((vector_size (SIZEOF_V128)));
typedef gint32 v128_i4 __attribute__ ((vector_size (SIZEOF_V128)));
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/interp/interp-simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <glib.h>

extern gboolean interp_simd_enabled;

typedef void (*PP_SIMD_Method) (gpointer, gpointer);
typedef void (*PPP_SIMD_Method) (gpointer, gpointer, gpointer);
typedef void (*PPPP_SIMD_Method) (gpointer, gpointer, gpointer, gpointer);
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/mini/interp/transform-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

#include "config.h"
#include "interp-simd.h"
#include <glib.h>
#include <mono/utils/bsearch.h>
#include <mono/metadata/class-internals.h>
Expand Down Expand Up @@ -900,6 +901,9 @@ interp_emit_simd_intrinsics (TransformData *td, MonoMethod *cmethod, MonoMethodS
if (image != mono_get_corlib ())
return FALSE;

if (!interp_simd_enabled)
return FALSE;

class_ns = m_class_get_name_space (cmethod->klass);
class_name = m_class_get_name (cmethod->klass);

Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasi/build/WasiApp.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@
<!--<_WasmEHLib Condition="'$(WasmEnableExceptionHandling)' != 'true'">libmono-wasm-eh-js.a</_WasmEHLib>-->
<!--<_WasmEHLibToExclude Condition="'$(WasmEnableExceptionHandling)' == 'true'">libmono-wasm-eh-js.a</_WasmEHLibToExclude>-->
<_WasmEHLibToExclude Condition="'$(WasmEnableExceptionHandling)' != 'true'">libmono-wasm-eh-wasm.a</_WasmEHLibToExclude>
<_WasmSIMDLib Condition="'$(WasmEnableSIMD)' == 'true'">libmono-wasm-simd.a</_WasmSIMDLib>
<_WasmSIMDLib Condition="'$(WasmEnableSIMD)' != 'true'">libmono-wasm-nosimd.a</_WasmSIMDLib>
<_WasmSIMDLibToExclude Condition="'$(WasmEnableSIMD)' != 'true'">libmono-wasm-simd.a</_WasmSIMDLibToExclude>
<_WasmSIMDLibToExclude Condition="'$(WasmEnableSIMD)' == 'true'">libmono-wasm-nosimd.a</_WasmSIMDLibToExclude>
</PropertyGroup>

<ItemGroup>
Expand All @@ -286,7 +290,9 @@
Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)*.a"
Exclude="@(_MonoRuntimeComponentDontLink->'$(MicrosoftNetCoreAppRuntimePackRidNativeDir)%(Identity)')" />
<_WasmNativeFileForLinking Condition="'$(_WasmEHLib)' != ''" Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmEHLib)" />
<_WasmNativeFileForLinking Condition="'$(_WasmSIMDLib)' != ''" Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmSIMDLib)" />
<_WasmNativeFileForLinking Remove="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmEHLibToExclude)" />
<_WasmNativeFileForLinking Remove="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmSIMDLibToExclude)" />

<_WasmNativeFileForLinking Include="$(WasiSysRoot)\lib\wasm32-wasi\libc++.a" />
<_WasmNativeFileForLinking Include="$(WasiSysRoot)\lib\wasm32-wasi\libc++abi.a" />
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasi/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target_link_libraries(dotnet
${MONO_ARTIFACTS_DIR}/libmono-ee-interp.a
${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a
${MONO_ARTIFACTS_DIR}/libmono-icall-table.a
${MONO_ARTIFACTS_DIR}/libmono-wasm-${CONFIGURATION_INTERPSIMDTABLES_LIB}.a
${NATIVE_BIN_DIR}/wasm-bundled-timezones.a
${NATIVE_BIN_DIR}/libSystem.Native.a
${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a
Expand Down
2 changes: 2 additions & 0 deletions src/mono/wasi/wasi.proj
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) -DICU_LIB_DIR=&quot;$(ICULibDir.TrimEnd('\/'))&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) -DMONO_ARTIFACTS_DIR=&quot;$(MonoArtifactsPath.TrimEnd('\/'))&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR=&quot;$(NativeBinDir.TrimEnd('\/'))&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableSIMD)' == 'true'">$(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_COMPILE_OPTIONS=&quot;-msimd128&quot; -DCONFIGURATION_INTERPSIMDTABLES_LIB=&quot;simd&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableSIMD)' != 'true'">$(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_INTERPSIMDTABLES_LIB=&quot;nosimd&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(MonoWasmThreads)' == 'true'">$(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(OS)' == 'Windows_NT'">call &quot;$(RepositoryEngineeringDir)native\init-vs-env.cmd&quot; wasm &amp;&amp; $(CMakeBuildRuntimeConfigureCmd)</CMakeBuildRuntimeConfigureCmd>

Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/build/WasmApp.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@
<_WasmEHLib Condition="'$(WasmEnableExceptionHandling)' != 'true'">libmono-wasm-eh-js.a</_WasmEHLib>
<_WasmEHLibToExclude Condition="'$(WasmEnableExceptionHandling)' == 'true'">libmono-wasm-eh-js.a</_WasmEHLibToExclude>
<_WasmEHLibToExclude Condition="'$(WasmEnableExceptionHandling)' != 'true'">libmono-wasm-eh-wasm.a</_WasmEHLibToExclude>
<_WasmSIMDLib Condition="'$(WasmEnableSIMD)' == 'true'">libmono-wasm-simd.a</_WasmSIMDLib>
<_WasmSIMDLib Condition="'$(WasmEnableSIMD)' != 'true'">libmono-wasm-nosimd.a</_WasmSIMDLib>
<_WasmSIMDLibToExclude Condition="'$(WasmEnableSIMD)' != 'true'">libmono-wasm-simd.a</_WasmSIMDLibToExclude>
<_WasmSIMDLibToExclude Condition="'$(WasmEnableSIMD)' == 'true'">libmono-wasm-nosimd.a</_WasmSIMDLibToExclude>
<_EmccExportedLibraryFunction>&quot;[@(EmccExportedLibraryFunction -> '%27%(Identity)%27', ',')]&quot;</_EmccExportedLibraryFunction>
<_EmccExportedRuntimeMethods>&quot;[@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]&quot;</_EmccExportedRuntimeMethods>
<_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')</_EmccExportedFunctions>
Expand All @@ -460,7 +464,9 @@
Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)*.a"
Exclude="@(_MonoRuntimeComponentDontLink->'$(MicrosoftNetCoreAppRuntimePackRidNativeDir)%(Identity)')" />
<_WasmNativeFileForLinking Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmEHLib)" />
<_WasmNativeFileForLinking Condition="'$(_WasmSIMDLib)' != ''" Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmSIMDLib)" />
<_WasmNativeFileForLinking Remove="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmEHLibToExclude)" />
<_WasmNativeFileForLinking Remove="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmSIMDLibToExclude)" />

<_WasmExtraJSFile Include="@(Content)" Condition="'%(Content.Extension)' == '.js'" />

Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ target_link_libraries(dotnet.native
${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a
${MONO_ARTIFACTS_DIR}/libmono-icall-table.a
${MONO_ARTIFACTS_DIR}/libmono-wasm-eh-js.a
${MONO_ARTIFACTS_DIR}/libmono-wasm-${CONFIGURATION_INTERPSIMDTABLES_LIB}.a
${MONO_ARTIFACTS_DIR}/libmono-profiler-aot.a
${MONO_ARTIFACTS_DIR}/libmono-profiler-browser.a
${NATIVE_BIN_DIR}/wasm-bundled-timezones.a
Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/wasm.proj
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) -DICU_LIB_DIR=&quot;$(ICULibDir.TrimEnd('\/').Replace('\','/'))&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) -DMONO_ARTIFACTS_DIR=&quot;$(MonoArtifactsPath.TrimEnd('\/').Replace('\','/'))&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR=&quot;$(NativeBinDir.TrimEnd('\/').Replace('\','/'))&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableSIMD)' == 'true'">$(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_COMPILE_OPTIONS=&quot;-msimd128&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableSIMD)' == 'true'">$(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_COMPILE_OPTIONS=&quot;-msimd128&quot; -DCONFIGURATION_INTERPSIMDTABLES_LIB=&quot;simd&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableSIMD)' != 'true'">$(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_INTERPSIMDTABLES_LIB=&quot;nosimd&quot;</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(MonoWasmThreads)' == 'true'">$(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableLegacyJsInterop)' == 'false'">$(CMakeBuildRuntimeConfigureCmd) -DDISABLE_LEGACY_JS_INTEROP=1</CMakeBuildRuntimeConfigureCmd>
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath)</CMakeBuildRuntimeConfigureCmd>
Expand Down