Kagome
Polkadot Runtime Engine in C++17
module.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_RUNTIME_WAVM_IMPL_MODULE_HPP
7 #define KAGOME_CORE_RUNTIME_WAVM_IMPL_MODULE_HPP
8 
9 #include "runtime/module.hpp"
10 
11 #include <memory>
12 
13 #include "common/blob.hpp"
14 #include "log/logger.hpp"
15 
16 namespace WAVM::Runtime {
17  struct Compartment;
18  struct Module;
19  struct Object;
20  using ImportBindings = std::vector<Object *>;
21 } // namespace WAVM::Runtime
22 
23 namespace kagome::runtime::wavm {
24 
25  class IntrinsicResolver;
26  class InstanceEnvironmentFactory;
27  class CompartmentWrapper;
28  class IntrinsicModule;
29  struct ModuleParams;
30 
31  class ModuleImpl final : public runtime::Module {
32  public:
33  static std::unique_ptr<ModuleImpl> compileFrom(
34  std::shared_ptr<CompartmentWrapper> compartment,
35  ModuleParams &module_params,
36  std::shared_ptr<IntrinsicModule> intrinsic_module,
37  std::shared_ptr<const InstanceEnvironmentFactory> env_factory,
38  gsl::span<const uint8_t> code,
39  const common::Hash256 &code_hash);
40 
41  outcome::result<std::shared_ptr<ModuleInstance>> instantiate()
42  const override;
43 
44  private:
45  ModuleImpl(std::shared_ptr<CompartmentWrapper> compartment,
46  std::shared_ptr<const IntrinsicModule> intrinsic_module,
47  std::shared_ptr<const InstanceEnvironmentFactory> env_factory,
48  std::shared_ptr<WAVM::Runtime::Module> module,
49  const common::Hash256 &code_hash);
50 
52 
53  std::shared_ptr<const InstanceEnvironmentFactory> env_factory_;
54  std::shared_ptr<CompartmentWrapper> compartment_;
55  std::shared_ptr<const IntrinsicModule> intrinsic_module_;
56  std::shared_ptr<WAVM::Runtime::Module> module_;
59  };
60 
61 } // namespace kagome::runtime::wavm
62 
63 #endif // KAGOME_CORE_RUNTIME_WAVM_IMPL_MODULE_HPP
std::vector< Object * > ImportBindings
Definition: module.hpp:20
Global parameters for module instantiation. Currently contains only memory type that may be changed o...
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
std::shared_ptr< const InstanceEnvironmentFactory > env_factory_
Definition: module.hpp:53
std::shared_ptr< CompartmentWrapper > compartment_
Definition: module.hpp:54
std::shared_ptr< const IntrinsicModule > intrinsic_module_
Definition: module.hpp:55
std::shared_ptr< WAVM::Runtime::Module > module_
Definition: module.hpp:56
const common::Hash256 code_hash_
Definition: module.hpp:57