| 35 | } |
| 36 | |
| 37 | Expect<void> Executor::runMemoryInitOp( |
| 38 | Runtime::StackManager &StackMgr, Runtime::Instance::MemoryInstance &MemInst, |
| 39 | Runtime::Instance::DataInstance &DataInst, const AST::Instruction &Instr) { |
| 40 | // Pop the length, source, and destination from the stack. |
| 41 | // Currently, the length and source offset from the data instance are |
| 42 | // 32-bit. |
| 43 | uint64_t Len = static_cast<uint64_t>(StackMgr.pop().get<uint32_t>()); |
| 44 | uint64_t Src = static_cast<uint64_t>(StackMgr.pop().get<uint32_t>()); |
| 45 | const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType(); |
| 46 | uint64_t Dst = extractAddr(StackMgr.pop(), AddrType); |
| 47 | |
| 48 | // Replace mem[Dst : Dst + Len] with data[Src : Src + Len]. |
| 49 | return MemInst.setBytes(DataInst.getData(), Dst, Src, Len) |
| 50 | .map_error([&Instr](auto E) { |
| 51 | spdlog::error( |
| 52 | ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset())); |
| 53 | return E; |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | Expect<void> |
| 58 | Executor::runDataDropOp(Runtime::Instance::DataInstance &DataInst) { |
nothing calls this directly
no test coverage detected