MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / runAtomicNotifyOp

Method runAtomicNotifyOp

lib/executor/engine/threadInstr.cpp:9–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace Executor {
8
9Expect<void>
10Executor::runAtomicNotifyOp(Runtime::StackManager &StackMgr,
11 Runtime::Instance::MemoryInstance &MemInst,
12 const AST::Instruction &Instr) {
13 ValVariant RawCount = StackMgr.pop();
14 ValVariant &RawAddress = StackMgr.getTop();
15 const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType();
16 uint64_t Address = extractAddr(RawAddress, AddrType);
17 EXPECTED_TRY(checkOffsetOverflow(MemInst, Instr, Address, sizeof(uint32_t)));
18 Address += Instr.getMemoryOffset();
19 uint32_t Align =
20 AddrType == AddressType::I32 ? sizeof(uint32_t) : sizeof(uint64_t);
21
22 if (Address % Align != 0) {
23 spdlog::error(ErrCode::Value::UnalignedAtomicAccess);
24 spdlog::error(
25 ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset()));
26 return Unexpect(ErrCode::Value::UnalignedAtomicAccess);
27 }
28
29 uint64_t Count = extractAddr(RawCount, AddrType);
30 EXPECTED_TRY(
31 auto Total,
32 atomicNotify(MemInst, Address, Count).map_error([&Instr](auto E) {
33 spdlog::error(E);
34 spdlog::error(
35 ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset()));
36 return E;
37 }));
38 RawAddress = emplaceAddr(Total, AddrType);
39 return {};
40}
41
42Expect<void> Executor::runMemoryFenceOp() {
43 std::atomic_thread_fence(std::memory_order_release);

Callers

nothing calls this directly

Calls 11

extractAddrFunction · 0.85
InfoInstructionClass · 0.85
UnexpectFunction · 0.85
emplaceAddrFunction · 0.85
popMethod · 0.80
getAddrTypeMethod · 0.80
getMemoryOffsetMethod · 0.80
EXPECTED_TRYFunction · 0.70
errorFunction · 0.50
getOpCodeMethod · 0.45
getOffsetMethod · 0.45

Tested by

no test coverage detected