Skip to content
Prev Previous commit
Next Next commit
[mono][interp] Disable simd intrinsics by default on wasm
These intrinsics are not yet implemented on jiterpreter, making it slighty slower instead.
  • Loading branch information
BrzVlad committed Feb 21, 2023
commit f69a049d2b557089fcc24168ea7a9d949427f508
4 changes: 4 additions & 0 deletions src/mono/mono/mini/interp/interp-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ typedef enum {

#define PROFILE_INTERP 0

#ifndef HOST_BROWSER
#define INTERP_ENABLE_SIMD
#endif

#define INTERP_IMETHOD_TAG_1(im) ((gpointer)((mono_u)(im) | 1))
#define INTERP_IMETHOD_IS_TAGGED_1(im) ((mono_u)(im) & 1)
#define INTERP_IMETHOD_UNTAG_1(im) ((InterpMethod*)((mono_u)(im) & ~1))
Expand Down
6 changes: 6 additions & 0 deletions src/mono/mono/mini/interp/interp-simd.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

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

#ifdef INTERP_ENABLE_SIMD

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 Expand Up @@ -595,3 +599,5 @@ PPPP_SIMD_Method interp_simd_p_ppp_table [] = {
};
#undef INTERP_SIMD_INTRINSIC_P_PPP
#define INTERP_SIMD_INTRINSIC_P_PPP(a,b)

#endif // INTERP_ENABLE_SIMD
17 changes: 16 additions & 1 deletion src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@
#include "mintops.h"
#include "interp-intrins.h"
#include "tiering.h"

#ifdef INTERP_ENABLE_SIMD
#include "interp-simd.h"
#endif

#include <mono/mini/mini.h>
#include <mono/mini/mini-runtime.h>
Expand Down Expand Up @@ -5792,7 +5795,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
ip += 7;
goto call;
}

#ifdef INTERP_ENABLE_SIMD
MINT_IN_CASE(MINT_SIMD_V128_LDC) {
memcpy (locals + ip [1], ip + 2, SIZEOF_V128);
ip += 10;
Expand Down Expand Up @@ -5859,6 +5862,18 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
interp_simd_p_ppp_table [ip [5]] (locals + ip [1], locals + ip [2], locals + ip [3], locals + ip [4]);
ip += 6;
MINT_IN_BREAK;
#else
MINT_IN_CASE(MINT_SIMD_V128_LDC)
MINT_IN_CASE(MINT_SIMD_V128_I1_CREATE)
MINT_IN_CASE(MINT_SIMD_V128_I2_CREATE)
MINT_IN_CASE(MINT_SIMD_V128_I4_CREATE)
MINT_IN_CASE(MINT_SIMD_V128_I8_CREATE)
MINT_IN_CASE(MINT_SIMD_INTRINS_P_P)
MINT_IN_CASE(MINT_SIMD_INTRINS_P_PP)
MINT_IN_CASE(MINT_SIMD_INTRINS_P_PPP)
g_assert_not_reached ();
MINT_IN_BREAK;
#endif

MINT_IN_CASE(MINT_INTRINS_SPAN_CTOR) {
gpointer ptr = LOCAL_VAR (ip [2], gpointer);
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1884,8 +1884,10 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
klass_name_space = m_class_get_name_space (target_method->klass);
const char *klass_name = m_class_get_name (target_method->klass);

#ifdef INTERP_ENABLE_SIMD
if ((mono_interp_opt & INTERP_OPT_SIMD) && interp_emit_simd_intrinsics (td, target_method, csignature))
return TRUE;
#endif

if (target_method->klass == mono_defaults.string_class) {
if (tm [0] == 'g') {
Expand Down Expand Up @@ -10835,4 +10837,6 @@ mono_jiterp_insert_ins (TransformData *td, InterpInst *prev_ins, int opcode)

#endif

#ifdef INTERP_ENABLE_SIMD
#include "transform-simd.c"
#endif