未验证 提交 8be6ee08 编写于 作者: K Katelyn Gadd 提交者: GitHub

Re-enable automatic gc safe transitions in threaded wasm mode (#71229)

Gc safe transitions and memory barriers were disabled for wasm, now they are enabled if the wasm_gc_safepoints AOT compiler option is set or the DISABLE_THREADS define is not active
上级 4537ce8b
......@@ -45,6 +45,7 @@
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-threads-coop.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/options.h>
#include <string.h>
#include <errno.h>
#include "icall-decl.h"
......@@ -662,7 +663,12 @@ gc_safe_transition_builder_init (GCSafeTransitionBuilder *builder, MonoMethodBui
builder->coop_cominterop_fnptr = -1;
#endif
#if defined (TARGET_WASM)
return FALSE;
#ifndef DISABLE_THREADS
return TRUE;
#else
/* if we're in the AOT compiler, obey the --wasm-gc-safepoints option even if the AOT compiler doesn't have threads enabled */
return mono_opt_wasm_gc_safepoints;
#endif
#else
return TRUE;
#endif
......@@ -2289,7 +2295,12 @@ emit_thunk_invoke_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethod *method, Mono
MonoExceptionClause *clause;
MonoType *object_type = mono_get_object_type ();
#if defined (TARGET_WASM)
const gboolean do_blocking_transition = FALSE;
/* in the AOT compiler emit blocking transitions if --wasm-gc-safepoints was used */
#ifndef DISABLE_THREADS
const gboolean do_blocking_transition = TRUE;
#else
const gboolean do_blocking_transition = mono_opt_wasm_gc_safepoints;
#endif
#else
const gboolean do_blocking_transition = TRUE;
#endif
......
......@@ -3724,9 +3724,7 @@ save_seq_points (TransformData *td, MonoJitInfo *jinfo)
static void
interp_emit_memory_barrier (TransformData *td, int kind)
{
#if defined(TARGET_WASM)
// mono_memory_barrier is dummy on wasm
#elif defined(TARGET_X86) || defined(TARGET_AMD64)
#if defined(TARGET_X86) || defined(TARGET_AMD64)
if (kind == MONO_MEMORY_BARRIER_SEQ)
interp_add_ins (td, MINT_MONO_MEMORY_BARRIER);
#else
......
......@@ -2932,7 +2932,11 @@ static inline gboolean
mini_safepoints_enabled (void)
{
#if defined (TARGET_WASM)
return mono_opt_wasm_gc_safepoints;
#ifndef DISABLE_THREADS
return TRUE;
#else
return mono_opt_wasm_gc_safepoints;
#endif
#else
return TRUE;
#endif
......
......@@ -21,23 +21,7 @@
*/
//#define mono_compiler_barrier() asm volatile("": : :"memory")
#ifdef HOST_WASM
static inline void mono_memory_barrier (void)
{
}
static inline void mono_memory_read_barrier (void)
{
}
static inline void mono_memory_write_barrier (void)
{
}
#define mono_compiler_barrier() asm volatile("": : :"memory")
#elif _MSC_VER
#if _MSC_VER
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
......@@ -71,7 +55,7 @@ static inline void mono_memory_write_barrier (void)
#define mono_compiler_barrier() _ReadWriteBarrier ()
#elif defined(USE_GCC_ATOMIC_OPS)
#elif defined(USE_GCC_ATOMIC_OPS) || defined(HOST_WASM)
static inline void mono_memory_barrier (void)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册