Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4775dc27
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4775dc27
编写于
2月 13, 2018
作者:
B
Bart Wyatt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename jit to wavm to better reflect the implementation that uses
上级
90ce83bd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
32 deletion
+32
-32
libraries/chain/CMakeLists.txt
libraries/chain/CMakeLists.txt
+1
-1
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
...ries/chain/include/eosio/chain/wasm_interface_private.hpp
+5
-5
libraries/chain/include/eosio/chain/webassembly/wavm.hpp
libraries/chain/include/eosio/chain/webassembly/wavm.hpp
+9
-9
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+15
-15
libraries/chain/webassembly/wavm.cpp
libraries/chain/webassembly/wavm.cpp
+2
-2
未找到文件。
libraries/chain/CMakeLists.txt
浏览文件 @
4775dc27
...
@@ -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
)
...
...
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
浏览文件 @
4775dc27
#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 )
...
...
libraries/chain/include/eosio/chain/webassembly/
jit
.hpp
→
libraries/chain/include/eosio/chain/webassembly/
wavm
.hpp
浏览文件 @
4775dc27
...
@@ -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
libraries/chain/wasm_interface.cpp
浏览文件 @
4775dc27
...
@@ -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
);
}
}
};
};
...
...
libraries/chain/webassembly/
jit
.cpp
→
libraries/chain/webassembly/
wavm
.cpp
浏览文件 @
4775dc27
#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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录