Skip to content

Commit

Permalink
GH-1251 Restore #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED removed in ref…
Browse files Browse the repository at this point in the history
…actor
  • Loading branch information
heifner committed Jun 28, 2023
1 parent b260447 commit a8f20ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2682,9 +2682,11 @@ struct controller_impl {
return app_window == app_window_type::write;
}

#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
bool is_eos_vm_oc_enabled() const {
return wasm_if_collect.is_eos_vm_oc_enabled();
}
#endif

void init_thread_local_data() {
wasm_if_collect.init_thread_local_data(db, conf.state_dir, conf.eosvmoc_config, !conf.profile_accounts.empty());
Expand Down Expand Up @@ -3572,10 +3574,11 @@ vm::wasm_allocator& controller::get_wasm_allocator() {
return my->wasm_alloc;
}
#endif

#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
bool controller::is_eos_vm_oc_enabled() const {
return my->is_eos_vm_oc_enabled();
}
#endif

std::optional<uint64_t> controller::convert_exception_to_error_code( const fc::exception& e ) {
const chain_exception* e_ptr = dynamic_cast<const chain_exception*>( &e );
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ namespace eosio { namespace chain {
#if defined(EOSIO_EOS_VM_RUNTIME_ENABLED) || defined(EOSIO_EOS_VM_JIT_RUNTIME_ENABLED)
vm::wasm_allocator& get_wasm_allocator();
#endif
#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
bool is_eos_vm_oc_enabled() const;
#endif

static std::optional<uint64_t> convert_exception_to_error_code( const fc::exception& e );

Expand Down
15 changes: 11 additions & 4 deletions libraries/chain/include/eosio/chain/wasm_interface_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ namespace eosio::chain {
{}

wasm_interface& get_wasm_interface() {
if (is_on_main_thread() || is_eos_vm_oc_enabled()) {
if (is_on_main_thread()
#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
|| is_eos_vm_oc_enabled()
#endif
)
return wasmif;
}
return *threaded_wasmifs[std::this_thread::get_id()];
}


// update current lib of all wasm interfaces
void current_lib(const uint32_t lib) {
// producer_plugin has already asserted irreversible_block signal is called in write window
Expand All @@ -38,19 +40,24 @@ namespace eosio::chain {
void init_thread_local_data(const chainbase::database& d, const std::filesystem::path& data_dir,
const eosvmoc::config& eosvmoc_config, bool profile) {
EOS_ASSERT(!is_on_main_thread(), misc_exception, "init_thread_local_data called on the main thread");
#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
if (is_eos_vm_oc_enabled()) {
// EOSVMOC needs further initialization of its thread local data
wasmif.init_thread_local_data();
} else {
} else
#endif
{
std::lock_guard g(threaded_wasmifs_mtx);
// Non-EOSVMOC needs a wasmif per thread
threaded_wasmifs[std::this_thread::get_id()] = std::make_unique<wasm_interface>(wasm_runtime, eosvmoc_tierup, d, data_dir, eosvmoc_config, profile);
}
}

#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
bool is_eos_vm_oc_enabled() const {
return ((eosvmoc_tierup != wasm_interface::vm_oc_enable::oc_none) || wasm_runtime == wasm_interface::vm_type::eos_vm_oc);
}
#endif

void code_block_num_last_used(const digest_type& code_hash, uint8_t vm_type, uint8_t vm_version, uint32_t block_num) {
// The caller of this function apply_eosio_setcode has already asserted that
Expand Down

0 comments on commit a8f20ce

Please sign in to comment.