| 7 | namespace Executor { |
| 8 | |
| 9 | Expect<void> |
| 10 | Executor::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 | |
| 42 | Expect<void> Executor::runMemoryFenceOp() { |
| 43 | std::atomic_thread_fence(std::memory_order_release); |
nothing calls this directly
no test coverage detected