Line | Count | Source (jump to first uncovered line) |
1 | // SPDX-License-Identifier: Apache-2.0 | |
2 | // SPDX-FileCopyrightText: 2019-2024 Second State INC | |
3 | ||
4 | //===-- wasmedge/common/executable.h - Executable Code definition ---------===// | |
5 | // | |
6 | // Part of the WasmEdge Project. | |
7 | // | |
8 | //===----------------------------------------------------------------------===// | |
9 | /// | |
10 | /// \file | |
11 | /// This file contains the declaration of the Executable, which holds interface | |
12 | /// to executable binary objects. | |
13 | /// | |
14 | //===----------------------------------------------------------------------===// | |
15 | #pragma once | |
16 | ||
17 | #include "common/defines.h" | |
18 | #include "common/symbol.h" | |
19 | #include "common/types.h" | |
20 | ||
21 | #include <cstdint> | |
22 | #include <memory> | |
23 | #include <vector> | |
24 | ||
25 | namespace WasmEdge { | |
26 | ||
27 | /// Holder class for library handle | |
28 | class Executable : public std::enable_shared_from_this<Executable> { | |
29 | Executable(const Executable &) = delete; | |
30 | Executable &operator=(const Executable &) = delete; | |
31 | Executable(Executable &&) = delete; | |
32 | Executable &operator=(Executable &&) = delete; | |
33 | ||
34 | public: | |
35 | 0 | Executable() noexcept = default; |
36 | 0 | virtual ~Executable() noexcept = default; |
37 | ||
38 | /// Function type wrapper for symbols. | |
39 | using Wrapper = void(void *ExecCtx, void *Function, const ValVariant *Args, | |
40 | ValVariant *Rets); | |
41 | ||
42 | enum class Intrinsics : uint32_t { | |
43 | kTrap, | |
44 | kCall, | |
45 | kCallIndirect, | |
46 | kCallRef, | |
47 | kRefFunc, | |
48 | kStructNew, | |
49 | kStructGet, | |
50 | kStructSet, | |
51 | kArrayNew, | |
52 | kArrayNewData, | |
53 | kArrayNewElem, | |
54 | kArrayGet, | |
55 | kArraySet, | |
56 | kArrayLen, | |
57 | kArrayFill, | |
58 | kArrayCopy, | |
59 | kArrayInitData, | |
60 | kArrayInitElem, | |
61 | kRefTest, | |
62 | kRefCast, | |
63 | kTableGet, | |
64 | kTableSet, | |
65 | kTableInit, | |
66 | kElemDrop, | |
67 | kTableCopy, | |
68 | kTableGrow, | |
69 | kTableSize, | |
70 | kTableFill, | |
71 | kMemGrow, | |
72 | kMemSize, | |
73 | kMemInit, | |
74 | kDataDrop, | |
75 | kMemCopy, | |
76 | kMemFill, | |
77 | kMemAtomicNotify, | |
78 | kMemAtomicWait, | |
79 | kTableGetFuncSymbol, | |
80 | kRefGetFuncSymbol, | |
81 | kIntrinsicMax, | |
82 | }; | |
83 | using IntrinsicsTable = void * [uint32_t(Intrinsics::kIntrinsicMax)]; | |
84 | ||
85 | virtual Symbol<const IntrinsicsTable *> getIntrinsics() noexcept = 0; | |
86 | ||
87 | virtual std::vector<Symbol<Wrapper>> getTypes(size_t Size) noexcept = 0; | |
88 | ||
89 | virtual std::vector<Symbol<void>> getCodes(size_t Offset, | |
90 | size_t Size) noexcept = 0; | |
91 | ||
92 | protected: | |
93 | 0 | template <typename T> Symbol<T> createSymbol(T *Pointer) const noexcept { |
94 | 0 | return Symbol<T>(shared_from_this(), Pointer); |
95 | 0 | } Unexecuted instantiation: WasmEdge::Symbol<void* const (*) [38]> WasmEdge::Executable::createSymbol<void* const (*) [38]>(void* const (**) [38]) const Unexecuted instantiation: WasmEdge::Symbol<void (void*, void*, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant> const*, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>*)> WasmEdge::Executable::createSymbol<void (void*, void*, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant> const*, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>*)>(void (*)(void*, void*, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant> const*, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>*)) const Unexecuted instantiation: WasmEdge::Symbol<void> WasmEdge::Executable::createSymbol<void>(void*) const Unexecuted instantiation: WasmEdge::Symbol<unsigned int> WasmEdge::Executable::createSymbol<unsigned int>(unsigned int*) const Unexecuted instantiation: WasmEdge::Symbol<unsigned char> WasmEdge::Executable::createSymbol<unsigned char>(unsigned char*) const Unexecuted instantiation: WasmEdge::Symbol<WasmEdge::Plugin::Plugin::PluginDescriptor const* ()> WasmEdge::Executable::createSymbol<WasmEdge::Plugin::Plugin::PluginDescriptor const* ()>(WasmEdge::Plugin::Plugin::PluginDescriptor const* (*)()) const Unexecuted instantiation: WasmEdge::Symbol<WasmEdge_PluginDescriptor const* ()> WasmEdge::Executable::createSymbol<WasmEdge_PluginDescriptor const* ()>(WasmEdge_PluginDescriptor const* (*)()) const |
96 | }; | |
97 | ||
98 | } // namespace WasmEdge |