Skip to content

Commit

Permalink
[mono][wasm] Add a 'wasm-gc-safepoints' option to enable the generati…
Browse files Browse the repository at this point in the history
…on of GC safe points in AOTed code on WASM. (#70520)
  • Loading branch information
vargaz authored Jun 10, 2022
1 parent c361857 commit b2add49
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -11831,7 +11831,7 @@ emit_method_inner (EmitContext *ctx)
}
ctx->has_safepoints = requires_safepoint;

if (!cfg->llvm_only && mono_threads_are_safepoints_enabled () && requires_safepoint) {
if (requires_safepoint && mini_safepoints_enabled ()) {
if (!cfg->compile_aot) {
LLVMSetGC (method, "coreclr");
emit_gc_safepoint_poll (ctx->module, ctx->lmodule, cfg);
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/mini/mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <mono/utils/mono-conc-hashtable.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/utils/ftnptr.h>
#include <mono/utils/options.h>
#include <mono/metadata/icalls.h>

// Forward declare so that mini-*.h can have pointers to them.
Expand Down Expand Up @@ -2931,7 +2932,7 @@ static inline gboolean
mini_safepoints_enabled (void)
{
#if defined (TARGET_WASM)
return FALSE;
return mono_opt_wasm_gc_safepoints;
#else
return TRUE;
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/utils/options-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ DEFINE_BOOL_READONLY(readonly_flag, "readonly-flag", FALSE, "Example")
#endif
*/

DEFINE_BOOL(wasm_exceptions, "wasm-exceptions", FALSE, "Enable codegen for wasm exceptions")
DEFINE_BOOL(wasm_exceptions, "wasm-exceptions", FALSE, "Enable codegen for WASM exceptions")
DEFINE_BOOL(wasm_gc_safepoints, "wasm-gc-safepoints", FALSE, "Use GC safepoints on WASM")
DEFINE_BOOL(aot_lazy_assembly_load, "aot-lazy-assembly-load", FALSE, "Load assemblies referenced by AOT images lazily")

/* Cleanup */
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/build/WasmApp.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@
<MonoAOTCompilerDefaultAotArguments Include="deterministic" />
<MonoAOTCompilerDefaultAotArguments Include="mattr=simd" Condition="'$(WasmSIMD)' == 'true'" />
<MonoAOTCompilerDefaultProcessArguments Include="--wasm-exceptions" Condition="'$(WasmExceptionHandling)' == 'true'" />
<MonoAOTCompilerDefaultProcessArguments Include="--wasm-gc-safepoints" Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true'" />
<AotProfilePath Include="$(WasmAotProfilePath)"/>
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit b2add49

Please sign in to comment.