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

Method runMemoryInitOp

lib/executor/engine/memoryInstr.cpp:37–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37Expect<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
57Expect<void>
58Executor::runDataDropOp(Runtime::Instance::DataInstance &DataInst) {

Callers

nothing calls this directly

Calls 9

extractAddrFunction · 0.85
InfoInstructionClass · 0.85
popMethod · 0.80
getAddrTypeMethod · 0.80
setBytesMethod · 0.80
errorFunction · 0.50
getDataMethod · 0.45
getOpCodeMethod · 0.45
getOffsetMethod · 0.45

Tested by

no test coverage detected