提交 4775dc27 编写于 作者: B Bart Wyatt

rename jit to wavm to better reflect the implementation that uses

上级 90ce83bd
...@@ -27,7 +27,7 @@ add_library( eosio_chain ...@@ -27,7 +27,7 @@ add_library( eosio_chain
contracts/genesis_state.cpp contracts/genesis_state.cpp
contracts/abi_serializer.cpp contracts/abi_serializer.cpp
webassembly/jit.cpp webassembly/wavm.cpp
${HEADERS} ${HEADERS}
transaction_metadata.cpp) transaction_metadata.cpp)
......
#pragma once #pragma once
#include <eosio/chain/wasm_interface.hpp> #include <eosio/chain/wasm_interface.hpp>
#include <eosio/chain/webassembly/jit.hpp> #include <eosio/chain/webassembly/wavm.hpp>
using namespace fc; using namespace fc;
using namespace eosio::chain::webassembly; using namespace eosio::chain::webassembly;
...@@ -9,12 +9,12 @@ using namespace eosio::chain::webassembly; ...@@ -9,12 +9,12 @@ using namespace eosio::chain::webassembly;
namespace eosio { namespace chain { namespace eosio { namespace chain {
struct wasm_cache::entry { struct wasm_cache::entry {
entry(jit::entry&& jit) entry(wavm::entry&& wavm)
: jit(std::forward<jit::entry>(jit)) : wavm(std::forward<wavm::entry>(wavm))
{ {
} }
jit::entry jit; wavm::entry wavm;
}; };
struct wasm_interface_impl { struct wasm_interface_impl {
...@@ -22,7 +22,7 @@ namespace eosio { namespace chain { ...@@ -22,7 +22,7 @@ namespace eosio { namespace chain {
}; };
#define _REGISTER_INTRINSIC_EXPLICIT(CLS, METHOD, WASM_SIG, NAME, SIG)\ #define _REGISTER_INTRINSIC_EXPLICIT(CLS, METHOD, WASM_SIG, NAME, SIG)\
_REGISTER_JIT_INTRINSIC(CLS, METHOD, WASM_SIG, NAME, SIG) _REGISTER_WAVM_INTRINSIC(CLS, METHOD, WASM_SIG, NAME, SIG)
#define _REGISTER_INTRINSIC4(CLS, METHOD, WASM_SIG, NAME, SIG)\ #define _REGISTER_INTRINSIC4(CLS, METHOD, WASM_SIG, NAME, SIG)\
_REGISTER_INTRINSIC_EXPLICIT(CLS, METHOD, WASM_SIG, NAME, SIG ) _REGISTER_INTRINSIC_EXPLICIT(CLS, METHOD, WASM_SIG, NAME, SIG )
......
...@@ -10,7 +10,7 @@ using namespace Runtime; ...@@ -10,7 +10,7 @@ using namespace Runtime;
using namespace fc; using namespace fc;
using namespace eosio::chain::webassembly::common; using namespace eosio::chain::webassembly::common;
namespace eosio { namespace chain { namespace webassembly { namespace jit { namespace eosio { namespace chain { namespace webassembly { namespace wavm {
struct info; struct info;
class entry { class entry {
...@@ -42,14 +42,14 @@ class entry { ...@@ -42,14 +42,14 @@ class entry {
}; };
struct info { struct info {
info( const entry &jit ) info( const entry &wavm )
{ {
MemoryInstance* current_memory = Runtime::getDefaultMemory(jit.instance); MemoryInstance* current_memory = Runtime::getDefaultMemory(wavm.instance);
default_sbrk_bytes = jit.sbrk_bytes; default_sbrk_bytes = wavm.sbrk_bytes;
if(current_memory) { if(current_memory) {
char *mem_ptr = &memoryRef<char>(current_memory, 0); char *mem_ptr = &memoryRef<char>(current_memory, 0);
const auto allocated_memory = Runtime::getDefaultMemorySize(jit.instance); const auto allocated_memory = Runtime::getDefaultMemorySize(wavm.instance);
for (uint64_t i = 0; i < allocated_memory; ++i) { for (uint64_t i = 0; i < allocated_memory; ++i) {
if (mem_ptr[i]) if (mem_ptr[i])
mem_end = i + 1; mem_end = i + 1;
...@@ -658,12 +658,12 @@ struct intrinsic_function_invoker_wrapper<WasmSig, Ret (Cls::*)(Params...) const ...@@ -658,12 +658,12 @@ struct intrinsic_function_invoker_wrapper<WasmSig, Ret (Cls::*)(Params...) const
#define __INTRINSIC_NAME(LABEL, SUFFIX) LABEL##SUFFIX #define __INTRINSIC_NAME(LABEL, SUFFIX) LABEL##SUFFIX
#define _INTRINSIC_NAME(LABEL, SUFFIX) __INTRINSIC_NAME(LABEL,SUFFIX) #define _INTRINSIC_NAME(LABEL, SUFFIX) __INTRINSIC_NAME(LABEL,SUFFIX)
#define _REGISTER_JIT_INTRINSIC(CLS, METHOD, WASM_SIG, NAME, SIG)\ #define _REGISTER_WAVM_INTRINSIC(CLS, METHOD, WASM_SIG, NAME, SIG)\
static Intrinsics::Function _INTRINSIC_NAME(__intrinsic_fn, __COUNTER__) (\ static Intrinsics::Function _INTRINSIC_NAME(__intrinsic_fn, __COUNTER__) (\
"env." NAME,\ "env." NAME,\
eosio::chain::webassembly::jit::wasm_function_type_provider<WASM_SIG>::type(),\ eosio::chain::webassembly::wavm::wasm_function_type_provider<WASM_SIG>::type(),\
(void *)eosio::chain::webassembly::jit::intrinsic_function_invoker_wrapper<WASM_SIG, SIG>::type::fn<&CLS::METHOD>()\ (void *)eosio::chain::webassembly::wavm::intrinsic_function_invoker_wrapper<WASM_SIG, SIG>::type::fn<&CLS::METHOD>()\
);\ );\
} } } }// eosio::chain::webassembly::jit } } } }// eosio::chain::webassembly::wavm
...@@ -73,8 +73,8 @@ namespace eosio { namespace chain { ...@@ -73,8 +73,8 @@ namespace eosio { namespace chain {
* the instance handed out to other threads * the instance handed out to other threads
*/ */
struct code_info { struct code_info {
explicit code_info(jit::info&& jit_info) :jit_info(jit_info) {} explicit code_info(wavm::info&& wavm_info) :wavm_info(wavm_info) {}
jit::info jit_info; wavm::info wavm_info;
// all existing instances of this code // all existing instances of this code
vector<unique_ptr<wasm_cache::entry>> instances; vector<unique_ptr<wasm_cache::entry>> instances;
...@@ -156,13 +156,13 @@ namespace eosio { namespace chain { ...@@ -156,13 +156,13 @@ namespace eosio { namespace chain {
if (!pending_result) { if (!pending_result) {
// time to compile a brand new (maybe first) copy of this code // time to compile a brand new (maybe first) copy of this code
fc::optional<jit::entry> jit; fc::optional<wavm::entry> wavm;
fc::optional<jit::info> jit_info; fc::optional<wavm::info> wavm_info;
try { try {
/// TODO: make validation generic /// TODO: make validation generic
jit = jit::entry::build(wasm_binary, wasm_binary_size); wavm = wavm::entry::build(wasm_binary, wasm_binary_size);
jit_info.emplace(*jit); wavm_info.emplace(*wavm);
} catch (...) { } catch (...) {
pending_error = std::current_exception(); pending_error = std::current_exception();
...@@ -172,9 +172,9 @@ namespace eosio { namespace chain { ...@@ -172,9 +172,9 @@ namespace eosio { namespace chain {
// grab the lock and put this in the cache as unavailble // grab the lock and put this in the cache as unavailble
with_lock(_cache_lock, [&,this]() { with_lock(_cache_lock, [&,this]() {
// find or create a new entry // find or create a new entry
auto iter = _cache.emplace(code_id, code_info(std::move(*jit_info))).first; auto iter = _cache.emplace(code_id, code_info(std::move(*wavm_info))).first;
iter->second.instances.emplace_back(std::make_unique<wasm_cache::entry>(std::move(*jit))); iter->second.instances.emplace_back(std::make_unique<wasm_cache::entry>(std::move(*wavm)));
pending_result = optional_entry_ref(*iter->second.instances.back().get()); pending_result = optional_entry_ref(*iter->second.instances.back().get());
}); });
} }
...@@ -209,7 +209,7 @@ namespace eosio { namespace chain { ...@@ -209,7 +209,7 @@ namespace eosio { namespace chain {
void return_entry(const digest_type& code_id, wasm_cache::entry& entry) { void return_entry(const digest_type& code_id, wasm_cache::entry& entry) {
// sanitize by reseting the memory that may now be dirty // sanitize by reseting the memory that may now be dirty
auto& info = (*fetch_info(code_id)).get(); auto& info = (*fetch_info(code_id)).get();
entry.jit.reset(info.jit_info); entry.wavm.reset(info.wavm_info);
// under a lock, put this entry back in the available instances side of the instances vector // under a lock, put this entry back in the available instances side of the instances vector
with_lock(_cache_lock, [&,this](){ with_lock(_cache_lock, [&,this](){
...@@ -254,7 +254,7 @@ namespace eosio { namespace chain { ...@@ -254,7 +254,7 @@ namespace eosio { namespace chain {
void wasm_cache::checkin(const digest_type& code_id, entry& code ) { void wasm_cache::checkin(const digest_type& code_id, entry& code ) {
MemoryInstance* default_mem = Runtime::getDefaultMemory(code.jit.instance); MemoryInstance* default_mem = Runtime::getDefaultMemory(code.wavm.instance);
if(default_mem) if(default_mem)
Runtime::shrinkMemory(default_mem, Runtime::getMemoryNumPages(default_mem) - 1); Runtime::shrinkMemory(default_mem, Runtime::getMemoryNumPages(default_mem) - 1);
_my->return_entry(code_id, code); _my->return_entry(code_id, code);
...@@ -292,12 +292,12 @@ namespace eosio { namespace chain { ...@@ -292,12 +292,12 @@ namespace eosio { namespace chain {
void wasm_interface::apply( wasm_cache::entry& code, apply_context& context ) { void wasm_interface::apply( wasm_cache::entry& code, apply_context& context ) {
auto context_guard = scoped_context(my->current_context, code, context); auto context_guard = scoped_context(my->current_context, code, context);
code.jit.call_apply(context); code.wavm.call_apply(context);
} }
void wasm_interface::error( wasm_cache::entry& code, apply_context& context ) { void wasm_interface::error( wasm_cache::entry& code, apply_context& context ) {
auto context_guard = scoped_context(my->current_context, code, context); auto context_guard = scoped_context(my->current_context, code, context);
code.jit.call_error(context); code.wavm.call_error(context);
} }
wasm_context& common::intrinsics_accessor::get_context(wasm_interface &wasm) { wasm_context& common::intrinsics_accessor::get_context(wasm_interface &wasm) {
...@@ -305,8 +305,8 @@ namespace eosio { namespace chain { ...@@ -305,8 +305,8 @@ namespace eosio { namespace chain {
return *wasm.my->current_context; return *wasm.my->current_context;
} }
const jit::entry& jit::entry::get(wasm_interface& wasm) { const wavm::entry& wavm::entry::get(wasm_interface& wasm) {
return common::intrinsics_accessor::get_context(wasm).code.jit; return common::intrinsics_accessor::get_context(wasm).code.wavm;
} }
#if defined(assert) #if defined(assert)
...@@ -833,7 +833,7 @@ class memory_api : public context_aware_api { ...@@ -833,7 +833,7 @@ class memory_api : public context_aware_api {
} }
uint32_t sbrk(int num_bytes) { uint32_t sbrk(int num_bytes) {
return code.jit.sbrk(num_bytes); return code.wavm.sbrk(num_bytes);
} }
}; };
......
#include <eosio/chain/webassembly/jit.hpp> #include <eosio/chain/webassembly/wavm.hpp>
#include <eosio/chain/wasm_eosio_constraints.hpp> #include <eosio/chain/wasm_eosio_constraints.hpp>
#include <eosio/chain/apply_context.hpp> #include <eosio/chain/apply_context.hpp>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
using namespace IR; using namespace IR;
using namespace Runtime; using namespace Runtime;
namespace eosio { namespace chain { namespace webassembly { namespace jit { namespace eosio { namespace chain { namespace webassembly { namespace wavm {
/** /**
* Integration with the WASM Linker to resolve our intrinsics * Integration with the WASM Linker to resolve our intrinsics
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册