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

rename jit to wavm to better reflect the implementation that uses

上级 90ce83bd
......@@ -27,7 +27,7 @@ add_library( eosio_chain
contracts/genesis_state.cpp
contracts/abi_serializer.cpp
webassembly/jit.cpp
webassembly/wavm.cpp
${HEADERS}
transaction_metadata.cpp)
......
#pragma once
#include <eosio/chain/wasm_interface.hpp>
#include <eosio/chain/webassembly/jit.hpp>
#include <eosio/chain/webassembly/wavm.hpp>
using namespace fc;
using namespace eosio::chain::webassembly;
......@@ -9,12 +9,12 @@ using namespace eosio::chain::webassembly;
namespace eosio { namespace chain {
struct wasm_cache::entry {
entry(jit::entry&& jit)
: jit(std::forward<jit::entry>(jit))
entry(wavm::entry&& wavm)
: wavm(std::forward<wavm::entry>(wavm))
{
}
jit::entry jit;
wavm::entry wavm;
};
struct wasm_interface_impl {
......@@ -22,7 +22,7 @@ namespace eosio { namespace chain {
};
#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)\
_REGISTER_INTRINSIC_EXPLICIT(CLS, METHOD, WASM_SIG, NAME, SIG )
......
......@@ -10,7 +10,7 @@ using namespace Runtime;
using namespace fc;
using namespace eosio::chain::webassembly::common;
namespace eosio { namespace chain { namespace webassembly { namespace jit {
namespace eosio { namespace chain { namespace webassembly { namespace wavm {
struct info;
class entry {
......@@ -42,14 +42,14 @@ class entry {
};
struct info {
info( const entry &jit )
info( const entry &wavm )
{
MemoryInstance* current_memory = Runtime::getDefaultMemory(jit.instance);
default_sbrk_bytes = jit.sbrk_bytes;
MemoryInstance* current_memory = Runtime::getDefaultMemory(wavm.instance);
default_sbrk_bytes = wavm.sbrk_bytes;
if(current_memory) {
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) {
if (mem_ptr[i])
mem_end = i + 1;
......@@ -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) __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__) (\
"env." NAME,\
eosio::chain::webassembly::jit::wasm_function_type_provider<WASM_SIG>::type(),\
(void *)eosio::chain::webassembly::jit::intrinsic_function_invoker_wrapper<WASM_SIG, SIG>::type::fn<&CLS::METHOD>()\
eosio::chain::webassembly::wavm::wasm_function_type_provider<WASM_SIG>::type(),\
(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 {
* the instance handed out to other threads
*/
struct code_info {
explicit code_info(jit::info&& jit_info) :jit_info(jit_info) {}
jit::info jit_info;
explicit code_info(wavm::info&& wavm_info) :wavm_info(wavm_info) {}
wavm::info wavm_info;
// all existing instances of this code
vector<unique_ptr<wasm_cache::entry>> instances;
......@@ -156,13 +156,13 @@ namespace eosio { namespace chain {
if (!pending_result) {
// time to compile a brand new (maybe first) copy of this code
fc::optional<jit::entry> jit;
fc::optional<jit::info> jit_info;
fc::optional<wavm::entry> wavm;
fc::optional<wavm::info> wavm_info;
try {
/// TODO: make validation generic
jit = jit::entry::build(wasm_binary, wasm_binary_size);
jit_info.emplace(*jit);
wavm = wavm::entry::build(wasm_binary, wasm_binary_size);
wavm_info.emplace(*wavm);
} catch (...) {
pending_error = std::current_exception();
......@@ -172,9 +172,9 @@ namespace eosio { namespace chain {
// grab the lock and put this in the cache as unavailble
with_lock(_cache_lock, [&,this]() {
// 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());
});
}
......@@ -209,7 +209,7 @@ namespace eosio { namespace chain {
void return_entry(const digest_type& code_id, wasm_cache::entry& entry) {
// sanitize by reseting the memory that may now be dirty
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
with_lock(_cache_lock, [&,this](){
......@@ -254,7 +254,7 @@ namespace eosio { namespace chain {
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)
Runtime::shrinkMemory(default_mem, Runtime::getMemoryNumPages(default_mem) - 1);
_my->return_entry(code_id, code);
......@@ -292,12 +292,12 @@ namespace eosio { namespace chain {
void wasm_interface::apply( wasm_cache::entry& code, apply_context& 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 ) {
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) {
......@@ -305,8 +305,8 @@ namespace eosio { namespace chain {
return *wasm.my->current_context;
}
const jit::entry& jit::entry::get(wasm_interface& wasm) {
return common::intrinsics_accessor::get_context(wasm).code.jit;
const wavm::entry& wavm::entry::get(wasm_interface& wasm) {
return common::intrinsics_accessor::get_context(wasm).code.wavm;
}
#if defined(assert)
......@@ -833,7 +833,7 @@ class memory_api : public context_aware_api {
}
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/apply_context.hpp>
......@@ -14,7 +14,7 @@
using namespace IR;
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册