4#ifdef SYSIO_SYS_VM_OC_RUNTIME_ENABLED
7#define _REGISTER_SYSVMOC_INTRINSIC(CLS, MOD, METHOD, WASM_SIG, NAME, SIG)
24#include <sysio/vm/allocator.hpp>
31using boost::multi_index_container;
33namespace sysio {
namespace chain {
35 namespace eosvmoc {
struct config; }
42 std::unique_ptr<wasm_instantiated_module_interface>
module;
47 struct by_first_block_num;
48 struct by_last_block_num;
50#ifdef SYSIO_SYS_VM_OC_RUNTIME_ENABLED
53 : cc(
d, c, db), exec(cc),
62#ifdef SYSIO_SYS_VM_RUNTIME_ENABLED
63 if(vm == wasm_interface::vm_type::eos_vm)
66#ifdef SYSIO_SYS_VM_JIT_RUNTIME_ENABLED
67 if(vm == wasm_interface::vm_type::eos_vm_jit && profile) {
69 runtime_interface = std::make_unique<webassembly::eos_vm_runtime::eos_vm_profile_runtime>();
71 if(vm == wasm_interface::vm_type::eos_vm_jit && !profile)
74#ifdef SYSIO_SYS_VM_OC_RUNTIME_ENABLED
75 if(vm == wasm_interface::vm_type::eos_vm_oc)
76 runtime_interface = std::make_unique<webassembly::eosvmoc::eosvmoc_runtime>(data_dir, eosvmoc_config,
d);
81#ifdef SYSIO_SYS_VM_OC_RUNTIME_ENABLED
83 SYS_ASSERT(vm != wasm_interface::vm_type::eos_vm_oc,
wasm_exception,
"You can't use SYS VM OC as the base runtime when tier up is activated");
84 eosvmoc.emplace(data_dir, eosvmoc_config,
d);
93 e.
module.release()->fast_shutdown();
98 std::vector<uint8_t> mem_image;
104 const Uptr memory_size = (
module.memories.defs[0].type.size.min << IR::numBytesPerPageLog2);
105 if(base_offset >= memory_size || base_offset + data_segment.
data.size() > memory_size)
106 FC_THROW_EXCEPTION(wasm_execution_error,
"WASM data segment outside of valid memory range");
107 if(base_offset + data_segment.
data.size() > mem_image.size())
108 mem_image.resize(base_offset + data_segment.
data.size(), 0x00);
109 memcpy(mem_image.data() + base_offset, data_segment.
data.data(), data_segment.
data.size());
127#ifdef SYSIO_SYS_VM_OC_RUNTIME_ENABLED
128 if(eosvmoc)
for(
auto it = first_it; it != last_it; it++)
129 eosvmoc->cc.free_code(it->code_hash, it->vm_version);
138 boost::make_tuple(code_hash,
vm_type, vm_version) );
144 .code_hash = code_hash,
145 .first_block_num_used = codeobject->first_block_used,
149 .vm_version = vm_version
162 std::vector<U8>
bytes = {
163 (
const U8*)codeobject->code.
data(),
164 (
const U8*)codeobject->code.
data() + codeobject->code.
size()};
170 module.userSections.clear();
187 typedef boost::multi_index_container<
190 ordered_unique<tag<by_hash>,
192 member<wasm_cache_entry, digest_type, &wasm_cache_entry::code_hash>,
193 member<wasm_cache_entry, uint8_t, &wasm_cache_entry::vm_type>,
194 member<wasm_cache_entry, uint8_t, &wasm_cache_entry::vm_version>
197 ordered_non_unique<tag<by_first_block_num>, member<wasm_cache_entry, uint32_t, &wasm_cache_entry::first_block_num_used>>,
198 ordered_non_unique<tag<by_last_block_num>, member<wasm_cache_entry, uint32_t, &wasm_cache_entry::last_block_num_used>>
206#ifdef SYSIO_SYS_VM_OC_RUNTIME_ENABLED
207 std::optional<eosvmoc_tier> eosvmoc;
PointerIntHelper< sizeof(size_t)>::UnsignedIntType Uptr
#define SYS_THROW(exc_type, FORMAT,...)
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
const ObjectType & get(CompatibleKey &&key) const
const char * data() const
void pause_billing_timer()
void resume_billing_timer()
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
void serialize(Stream &stream, U8 &i)
scoped_exit< Callback > make_scoped_exit(Callback &&c)
key Invalid authority Invalid transaction Invalid block ID Invalid packed transaction Invalid chain ID Invalid symbol Signature type is not a currently activated type Block can not be found Unlinkable block Block does not guarantee concurrent execution without conflicts Block exhausted allowed resources Block is from the future Block is not signed by expected producer Block includes an ill formed protocol feature activation extension Block includes an ill formed additional block signature extension Error decompressing transaction Transaction should have at least one required authority Expired Transaction Invalid Reference Block Duplicate deferred transaction The transaction can not be found Transaction is too big Invalid transaction extension Transaction includes disallowed Transaction exceeded transient resource limit Account name already exists sysio_assert_message assertion failure Action can not be found Attempt to use unaccessible API Inline Action exceeds maximum size limit sysio_assert_code assertion failure uses restricted error code value action return value size too big Permission Query Exception Contract Table Query Exception Database is an unknown or unsupported version Database usage is at unsafe levels wasm_exception
void set_profile_interval_us(uint32_t value)
wasm_interface::vm_type vm_type
InitializerExpression baseOffset
std::unique_ptr< wasm_instantiated_module_interface > module
uint32_t last_block_num_used
uint32_t first_block_num_used
void current_lib(uint32_t lib)
const std::unique_ptr< wasm_instantiated_module_interface > & get_instantiated_module(const digest_type &code_hash, const uint8_t &vm_type, const uint8_t &vm_version, transaction_context &trx_context)
const wasm_interface::vm_type wasm_runtime_time
wasm_interface_impl(wasm_interface::vm_type vm, bool eosvmoc_tierup, const chainbase::database &d, const boost::filesystem::path data_dir, const eosvmoc::config &eosvmoc_config, bool profile)
wasm_cache_index wasm_instantiation_cache
const chainbase::database & db
void code_block_num_last_used(const digest_type &code_hash, const uint8_t &vm_type, const uint8_t &vm_version, const uint32_t &block_num)
boost::multi_index_container< wasm_cache_entry, indexed_by< ordered_unique< tag< by_hash >, composite_key< wasm_cache_entry, member< wasm_cache_entry, digest_type, &wasm_cache_entry::code_hash >, member< wasm_cache_entry, uint8_t, &wasm_cache_entry::vm_type >, member< wasm_cache_entry, uint8_t, &wasm_cache_entry::vm_version > > >, ordered_non_unique< tag< by_first_block_num >, member< wasm_cache_entry, uint32_t, &wasm_cache_entry::first_block_num_used > >, ordered_non_unique< tag< by_last_block_num >, member< wasm_cache_entry, uint32_t, &wasm_cache_entry::last_block_num_used > > > > wasm_cache_index
std::vector< uint8_t > parse_initial_memory(const Module &module)
std::unique_ptr< wasm_runtime_interface > runtime_interface
memcpy((char *) pInfo->slotDescription, s, l)