/src/WasmEdge/include/executor/engine/memory.ipp
Line | Count | Source |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: Copyright The WasmEdge Authors |
3 | | |
4 | | #include "executor/executor.h" |
5 | | #include "runtime/instance/memory.h" |
6 | | |
7 | | #include <cstdint> |
8 | | |
9 | | namespace WasmEdge { |
10 | | namespace Executor { |
11 | | |
12 | | template <typename T, uint32_t BitWidth> |
13 | | TypeT<T> Executor::runLoadOp(Runtime::StackManager &StackMgr, |
14 | | Runtime::Instance::MemoryInstance &MemInst, |
15 | 0 | const AST::Instruction &Instr) { |
16 | | // Calculate EA |
17 | 0 | ValVariant &Val = StackMgr.getTop(); |
18 | 0 | const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType(); |
19 | 0 | uint64_t EA = extractAddr(Val, AddrType); |
20 | 0 | EXPECTED_TRY(checkOffsetOverflow(MemInst, Instr, EA, BitWidth / 8)); |
21 | 0 | EA += Instr.getMemoryOffset(); |
22 | | // Value = Mem.Data[EA : N / 8] |
23 | 0 | return MemInst.loadValue<T, BitWidth / 8>(Val.emplace<T>(), EA) |
24 | 0 | .map_error([&Instr](auto E) { |
25 | 0 | spdlog::error( |
26 | 0 | ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset())); |
27 | 0 | return E; |
28 | 0 | }); Unexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned int, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned long, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<float, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<double, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<int, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned int, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<int, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned int, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<long, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned long, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<long, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned long, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<long, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned long, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned __int128, 128u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned __int128, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadOp<unsigned __int128, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) const |
29 | 0 | } Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned int, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned long, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<float>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<float, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<double>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<double, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<int, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned int, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<int, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned int, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<long, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned long, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<long, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned long, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<long, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned long, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned __int128>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned __int128, 128u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned __int128>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned __int128, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNumV<unsigned __int128>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runLoadOp<unsigned __int128, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) |
30 | | |
31 | | template <typename T, uint32_t BitWidth> |
32 | | TypeN<T> Executor::runStoreOp(Runtime::StackManager &StackMgr, |
33 | | Runtime::Instance::MemoryInstance &MemInst, |
34 | 0 | const AST::Instruction &Instr) { |
35 | | // Pop the value t.const c from the Stack |
36 | 0 | T C = StackMgr.pop().get<T>(); |
37 | | |
38 | | // Calculate EA = i + offset |
39 | 0 | const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType(); |
40 | 0 | uint64_t I = extractAddr(StackMgr.pop(), AddrType); |
41 | 0 | EXPECTED_TRY(checkOffsetOverflow(MemInst, Instr, I, BitWidth / 8)); |
42 | 0 | uint64_t EA = I + Instr.getMemoryOffset(); |
43 | | |
44 | | // Store value to bytes. |
45 | 0 | return MemInst.storeValue<T, BitWidth / 8>(C, EA).map_error([&Instr](auto E) { |
46 | 0 | spdlog::error( |
47 | 0 | ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset())); |
48 | 0 | return E; |
49 | 0 | }); Unexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned int, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned long, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<float, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<double, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned int, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned int, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned long, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned long, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned long, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreOp<unsigned __int128, 128u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) const |
50 | 0 | } Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned int, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned long, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<float>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<float, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<double>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<double, 64u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned int, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned int>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned int, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned long, 8u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned long, 16u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned long>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned long, 32u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: std::__1::enable_if<IsWasmNativeNumV<unsigned __int128>, cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runStoreOp<unsigned __int128, 128u>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) |
51 | | |
52 | | template <typename TIn, typename TOut> |
53 | | Expect<void> |
54 | | Executor::runLoadExpandOp(Runtime::StackManager &StackMgr, |
55 | | Runtime::Instance::MemoryInstance &MemInst, |
56 | 0 | const AST::Instruction &Instr) { |
57 | 0 | static_assert(sizeof(TOut) == sizeof(TIn) * 2); |
58 | | // Calculate EA |
59 | 0 | ValVariant &Val = StackMgr.getTop(); |
60 | 0 | const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType(); |
61 | 0 | uint64_t EA = extractAddr(Val, AddrType); |
62 | 0 | EXPECTED_TRY(checkOffsetOverflow(MemInst, Instr, EA, 8)); |
63 | 0 | EA += Instr.getMemoryOffset(); |
64 | | |
65 | | // Value = Mem.Data[EA : N / 8] |
66 | 0 | uint64_t Buffer; |
67 | 0 | return MemInst.loadValue<decltype(Buffer), 8>(Buffer, EA) |
68 | 0 | .map_error([&Instr](auto E) { |
69 | 0 | spdlog::error( |
70 | 0 | ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset())); |
71 | 0 | return E; |
72 | 0 | }) Unexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadExpandOp<signed char, short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadExpandOp<unsigned char, unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadExpandOp<short, int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadExpandOp<unsigned short, unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadExpandOp<int, long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadExpandOp<unsigned int, unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) const |
73 | 0 | .map([&]() { |
74 | 0 | using VTIn = SIMDArray<TIn, 8>; |
75 | 0 | using VTOut = SIMDArray<TOut, 16>; |
76 | |
|
77 | 0 | VTIn Value; |
78 | 0 | std::memcpy(&Value, &Buffer, 8); |
79 | |
|
80 | 0 | if constexpr (sizeof(TOut) == 2) { |
81 | 0 | Val.emplace<VTOut>(VTOut{Value[0], Value[1], Value[2], Value[3], |
82 | 0 | Value[4], Value[5], Value[6], Value[7]}); |
83 | 0 | } else if constexpr (sizeof(TOut) == 4) { |
84 | 0 | Val.emplace<VTOut>(VTOut{Value[0], Value[1], Value[2], Value[3]}); |
85 | 0 | } else if constexpr (sizeof(TOut) == 8) { |
86 | 0 | Val.emplace<VTOut>(VTOut{Value[0], Value[1]}); |
87 | 0 | } |
88 | 0 | }); Unexecuted instantiation: WasmEdge::Executor::Executor::runLoadExpandOp<signed char, short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadExpandOp<unsigned char, unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadExpandOp<short, int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadExpandOp<unsigned short, unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadExpandOp<int, long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadExpandOp<unsigned int, unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() const |
89 | 0 | } Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadExpandOp<signed char, short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadExpandOp<unsigned char, unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadExpandOp<short, int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadExpandOp<unsigned short, unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadExpandOp<int, long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadExpandOp<unsigned int, unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) |
90 | | |
91 | | template <typename T> |
92 | | Expect<void> |
93 | | Executor::runLoadSplatOp(Runtime::StackManager &StackMgr, |
94 | | Runtime::Instance::MemoryInstance &MemInst, |
95 | 0 | const AST::Instruction &Instr) { |
96 | | // Calculate EA |
97 | 0 | ValVariant &Val = StackMgr.getTop(); |
98 | 0 | const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType(); |
99 | 0 | uint64_t EA = extractAddr(Val, AddrType); |
100 | 0 | EXPECTED_TRY(checkOffsetOverflow(MemInst, Instr, EA, sizeof(T))); |
101 | 0 | EA += Instr.getMemoryOffset(); |
102 | | |
103 | | // Value = Mem.Data[EA : N / 8] |
104 | 0 | using VT = SIMDArray<T, 16>; |
105 | 0 | uint64_t Buffer; |
106 | 0 | return MemInst.loadValue<decltype(Buffer), sizeof(T)>(Buffer, EA) |
107 | 0 | .map_error([&Instr](auto E) { |
108 | 0 | spdlog::error( |
109 | 0 | ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset())); |
110 | 0 | return E; |
111 | 0 | }) Unexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadSplatOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadSplatOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadSplatOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadSplatOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) const |
112 | 0 | .map([&]() { |
113 | 0 | const T Part = static_cast<T>(Buffer); |
114 | |
|
115 | 0 | if constexpr (sizeof(T) == 1) { |
116 | 0 | Val.emplace<VT>(VT{Part, Part, Part, Part, Part, Part, Part, Part, |
117 | 0 | Part, Part, Part, Part, Part, Part, Part, Part}); |
118 | 0 | } else if constexpr (sizeof(T) == 2) { |
119 | 0 | Val.emplace<VT>(VT{Part, Part, Part, Part, Part, Part, Part, Part}); |
120 | 0 | } else if constexpr (sizeof(T) == 4) { |
121 | 0 | Val.emplace<VT>(VT{Part, Part, Part, Part}); |
122 | 0 | } else if constexpr (sizeof(T) == 8) { |
123 | 0 | Val.emplace<VT>(VT{Part, Part}); |
124 | 0 | } |
125 | 0 | }); Unexecuted instantiation: WasmEdge::Executor::Executor::runLoadSplatOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadSplatOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadSplatOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadSplatOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() const |
126 | 0 | } Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadSplatOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadSplatOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadSplatOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadSplatOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) |
127 | | |
128 | | template <typename T> |
129 | | Expect<void> Executor::runLoadLaneOp(Runtime::StackManager &StackMgr, |
130 | | Runtime::Instance::MemoryInstance &MemInst, |
131 | 0 | const AST::Instruction &Instr) { |
132 | 0 | using VT = SIMDArray<T, 16>; |
133 | 0 | VT Result = StackMgr.pop().get<VT>(); |
134 | 0 | const uint32_t Lane = Endian::native == Endian::little |
135 | 0 | ? Instr.getMemoryLane() |
136 | 0 | : (16 / sizeof(T)) - 1 - Instr.getMemoryLane(); |
137 | | // Calculate EA |
138 | 0 | ValVariant &Val = StackMgr.getTop(); |
139 | 0 | const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType(); |
140 | 0 | uint64_t EA = extractAddr(Val, AddrType); |
141 | 0 | EXPECTED_TRY(checkOffsetOverflow(MemInst, Instr, EA, sizeof(T))); |
142 | 0 | EA += Instr.getMemoryOffset(); |
143 | | |
144 | | // Value = Mem.Data[EA : N / 8] |
145 | 0 | uint64_t Buffer; |
146 | 0 | return MemInst.loadValue<decltype(Buffer), sizeof(T)>(Buffer, EA) |
147 | 0 | .map_error([&Instr](auto E) { |
148 | 0 | spdlog::error( |
149 | 0 | ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset())); |
150 | 0 | return E; |
151 | 0 | }) Unexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadLaneOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadLaneOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadLaneOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runLoadLaneOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) const |
152 | 0 | .map([&]() { |
153 | 0 | Result[Lane] = static_cast<T>(Buffer); |
154 | 0 | Val.emplace<VT>(Result); |
155 | 0 | }); Unexecuted instantiation: WasmEdge::Executor::Executor::runLoadLaneOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadLaneOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadLaneOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() constUnexecuted instantiation: WasmEdge::Executor::Executor::runLoadLaneOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda()#1}::operator()() const |
156 | 0 | } Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadLaneOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadLaneOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadLaneOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runLoadLaneOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) |
157 | | |
158 | | template <typename T> |
159 | | Expect<void> |
160 | | Executor::runStoreLaneOp(Runtime::StackManager &StackMgr, |
161 | | Runtime::Instance::MemoryInstance &MemInst, |
162 | 0 | const AST::Instruction &Instr) { |
163 | 0 | using VT = SIMDArray<T, 16>; |
164 | 0 | using TBuf = std::conditional_t<sizeof(T) < 4, uint32_t, T>; |
165 | 0 | const uint32_t Lane = Endian::native == Endian::little |
166 | 0 | ? Instr.getMemoryLane() |
167 | 0 | : (16 / sizeof(T)) - 1 - Instr.getMemoryLane(); |
168 | 0 | const TBuf C = StackMgr.pop().get<VT>()[Lane]; |
169 | | |
170 | | // Calculate EA = i + offset |
171 | 0 | const auto AddrType = MemInst.getMemoryType().getLimit().getAddrType(); |
172 | 0 | uint64_t I = extractAddr(StackMgr.pop(), AddrType); |
173 | 0 | EXPECTED_TRY(checkOffsetOverflow(MemInst, Instr, I, sizeof(T))); |
174 | 0 | uint64_t EA = I + Instr.getMemoryOffset(); |
175 | | |
176 | | // Store value to bytes. |
177 | 0 | return MemInst.storeValue<decltype(C), sizeof(T)>(C, EA).map_error( |
178 | 0 | [&Instr](auto E) { |
179 | 0 | spdlog::error( |
180 | 0 | ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset())); |
181 | 0 | return E; |
182 | 0 | }); Unexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreLaneOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreLaneOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreLaneOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) constUnexecuted instantiation: auto WasmEdge::Executor::Executor::runStoreLaneOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&)::{lambda(auto:1)#1}::operator()<WasmEdge::ErrCode>(WasmEdge::ErrCode) const |
183 | 0 | } Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runStoreLaneOp<unsigned char>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runStoreLaneOp<unsigned short>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runStoreLaneOp<unsigned int>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) Unexecuted instantiation: cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::runStoreLaneOp<unsigned long>(WasmEdge::Runtime::StackManager&, WasmEdge::Runtime::Instance::MemoryInstance&, WasmEdge::AST::Instruction const&) |
184 | | |
185 | | } // namespace Executor |
186 | | } // namespace WasmEdge |