Skip to content

Commit

Permalink
Use native wasm atomic fence instead of calling C for memory barriers
Browse files Browse the repository at this point in the history
  • Loading branch information
kg committed Sep 5, 2024
1 parent 568796a commit 26ad367
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/jiterpreter-trace-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "./memory";
import {
WasmOpcode, WasmSimdOpcode, WasmValtype,
getOpcodeName, MintOpArgType
getOpcodeName, MintOpArgType, WasmAtomicOpcode
} from "./jiterpreter-opcodes";
import {
MintOpcode, SimdInfo,
Expand Down Expand Up @@ -3956,7 +3956,7 @@ function emit_atomics (
) {
if (opcode === MintOpcode.MINT_MONO_MEMORY_BARRIER) {
if (WasmEnableThreads)
builder.callImport("membar");
builder.appendAtomic(WasmAtomicOpcode.atomic_fence);
return true;
}

Expand Down
6 changes: 0 additions & 6 deletions src/mono/browser/runtime/jiterpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ function getTraceImports () {
["stelemr_tc", "stelemr", getRawCwrap("mono_jiterp_stelem_ref")],
importDef("fma", getRawCwrap("fma")),
importDef("fmaf", getRawCwrap("fmaf")),
importDef("membar", getRawCwrap("mono_jiterp_memory_barrier")),
];

if (instrumentedMethodNames.length > 0) {
Expand Down Expand Up @@ -664,11 +663,6 @@ function initialize_builder (builder: WasmBuilder) {
},
WasmValtype.void, true
);
builder.defineType(
"membar",
{},
WasmValtype.void, true
);

const traceImports = getTraceImports();

Expand Down
5 changes: 0 additions & 5 deletions src/mono/mono/mini/interp/jiterpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,11 +1165,6 @@ mono_jiterp_stelem_ref (
return 1;
}

EMSCRIPTEN_KEEPALIVE void
mono_jiterp_memory_barrier () {
mono_memory_barrier ();
}


// keep in sync with jiterpreter-enums.ts JiterpMember
enum {
Expand Down

0 comments on commit 26ad367

Please sign in to comment.