Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
2fee3793
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,发现更多精彩内容 >>
提交
2fee3793
编写于
4月 25, 2018
作者:
B
Bucky Kittinger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Still problems with binaryen
上级
92e71d17
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
100 addition
and
6 deletion
+100
-6
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
+93
-5
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
...ries/chain/include/eosio/chain/wasm_interface_private.hpp
+1
-0
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+6
-1
未找到文件。
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
浏览文件 @
2fee3793
...
@@ -208,24 +208,59 @@ namespace eosio { namespace chain { namespace wasm_injections {
...
@@ -208,24 +208,59 @@ namespace eosio { namespace chain { namespace wasm_injections {
}
}
static
void
accept
(
wasm_ops
::
instr
*
inst
,
wasm_ops
::
visitor_arg
&
arg
)
{
static
void
accept
(
wasm_ops
::
instr
*
inst
,
wasm_ops
::
visitor_arg
&
arg
)
{
if
(
global_idx
==
-
1
)
{
if
(
global_idx
==
-
1
)
{
arg
.
module
->
globals
.
defs
.
push_back
({{
ValueType
::
i32
,
true
},
{(
I32
)
eosio
::
chain
::
wasm_constraints
::
maximum_call_depth
}});
arg
.
module
->
globals
.
defs
.
push_back
({{
ValueType
::
i32
,
true
},
{(
I32
)
-
1
}});
// eosio::chain::wasm_constraints::maximum_call_depth}});
//arg.function_def->nonParameterLocalTypes.push_back(ValueType::i32);
/*
arg.module->globals.defs.push_back({{ValueType::i32, true}, {(I32)0}});
arg.module->globals.defs.push_back({{ValueType::i64, true}, {(I64)0}});
arg.module->globals.defs.push_back({{ValueType::f32, true}, {(F32)0}});
arg.module->globals.defs.push_back({{ValueType::f64, true}, {(F64)0}});
*/
//call_return_idx = arg.function_def->nonParameterLocalTypes.size() + arg.module->types[arg.function_def->type.index]->parameters.size()-1;
}
}
global_idx
=
arg
.
module
->
globals
.
size
()
-
1
;
global_idx
=
arg
.
module
->
globals
.
size
()
-
1
;
/*
int32_t global_return_i32_idx = arg.module->globals.size()-4;
int32_t global_return_i64_idx = arg.module->globals.size()-3;
int32_t global_return_f32_idx = arg.module->globals.size()-2;
int32_t global_return_f64_idx = arg.module->globals.size()-1;
*/
wasm_ops
::
op_types
<>::
call_t
*
call_inst
=
reinterpret_cast
<
wasm_ops
::
op_types
<>::
call_t
*>
(
inst
);
wasm_ops
::
op_types
<>::
call_t
*
call_inst
=
reinterpret_cast
<
wasm_ops
::
op_types
<>::
call_t
*>
(
inst
);
int32_t
assert_idx
;
int32_t
assert_idx
;
injector_utils
::
add_import
<
ResultType
::
none
>
(
*
(
arg
.
module
),
"call_depth_assert"
,
assert_idx
);
injector_utils
::
add_import
<
ResultType
::
none
>
(
*
(
arg
.
module
),
"call_depth_assert"
,
assert_idx
);
int32_t
pop_none_idx
;
injector_utils
::
add_import
<
ResultType
::
none
,
ValueType
::
i32
>
(
*
(
arg
.
module
),
"call_depth_pop"
,
pop_none_idx
);
int32_t
pop_i32_idx
;
injector_utils
::
add_import
<
ResultType
::
i32
,
ValueType
::
i32
,
ValueType
::
i32
>
(
*
(
arg
.
module
),
"call_depth_pop_i32"
,
pop_i32_idx
);
int32_t
pop_i64_idx
;
injector_utils
::
add_import
<
ResultType
::
i64
,
ValueType
::
i64
,
ValueType
::
i32
>
(
*
(
arg
.
module
),
"call_depth_pop_i64"
,
pop_i64_idx
);
int32_t
pop_f32_idx
;
injector_utils
::
add_import
<
ResultType
::
f32
,
ValueType
::
f32
,
ValueType
::
i32
>
(
*
(
arg
.
module
),
"call_depth_pop_f32"
,
pop_f32_idx
);
int32_t
pop_f64_idx
;
injector_utils
::
add_import
<
ResultType
::
f64
,
ValueType
::
f64
,
ValueType
::
i32
>
(
*
(
arg
.
module
),
"call_depth_pop_f64"
,
pop_f64_idx
);
auto
get_return_type
=
[
&
](
int
idx
)
{
return
arg
.
module
->
types
[
arg
.
module
->
functions
.
getType
(
idx
).
index
]
->
ret
;
};
wasm_ops
::
op_types
<>::
call_t
call_assert
;
wasm_ops
::
op_types
<>::
call_t
call_assert
;
wasm_ops
::
op_types
<>::
call_t
call_pop
;
wasm_ops
::
op_types
<>::
get_global_t
get_global_inst
;
wasm_ops
::
op_types
<>::
get_global_t
get_global_inst
;
wasm_ops
::
op_types
<>::
set_global_t
set_global_inst
;
wasm_ops
::
op_types
<>::
set_global_t
set_global_inst
;
wasm_ops
::
op_types
<>::
get_global_t
get_call_return_inst
;
wasm_ops
::
op_types
<>::
set_global_t
set_call_return_inst
;
wasm_ops
::
op_types
<>::
i32_eqz_t
eqz_inst
;
wasm_ops
::
op_types
<>::
i32_eqz_t
eqz_inst
;
wasm_ops
::
op_types
<>::
i32_const_t
const_inst
;
wasm_ops
::
op_types
<>::
i32_const_t
const_inst
;
wasm_ops
::
op_types
<>::
i32_add_t
add_inst
;
wasm_ops
::
op_types
<>::
i32_add_t
add_inst
;
wasm_ops
::
op_types
<>::
end_t
end_inst
;
wasm_ops
::
op_types
<>::
end_t
end_inst
;
wasm_ops
::
op_types
<>::
if__t
if_inst
;
wasm_ops
::
op_types
<>::
if__t
if_inst
;
wasm_ops
::
op_types
<>::
else__t
else_inst
;
wasm_ops
::
op_types
<>::
else__t
else_inst
;
wasm_ops
::
op_types
<>::
block_t
block_inst
;
wasm_ops
::
op_types
<>::
block_t
returning_block_inst
;
call_assert
.
field
=
assert_idx
;
call_assert
.
field
=
assert_idx
;
get_global_inst
.
field
=
global_idx
;
get_global_inst
.
field
=
global_idx
;
...
@@ -247,16 +282,67 @@ namespace eosio { namespace chain { namespace wasm_injections {
...
@@ -247,16 +282,67 @@ namespace eosio { namespace chain { namespace wasm_injections {
INSERT_INJECTED
(
get_global_inst
);
INSERT_INJECTED
(
get_global_inst
);
INSERT_INJECTED
(
add_inst
);
INSERT_INJECTED
(
add_inst
);
INSERT_INJECTED
(
set_global_inst
);
INSERT_INJECTED
(
set_global_inst
);
INSERT_INJECTED
(
end_inst
);
std
::
cout
<<
"CALLING "
<<
call_inst
->
field
<<
" TYPE "
<<
(
int
)
get_return_type
(
call_inst
->
field
)
<<
std
::
endl
;
tmp
=
call_inst
->
pack
();
tmp
=
call_inst
->
pack
();
injected
.
insert
(
injected
.
end
(),
tmp
.
begin
(),
tmp
.
end
()
);
injected
.
insert
(
injected
.
end
(),
tmp
.
begin
(),
tmp
.
end
()
);
#if 1
if
(
get_return_type
(
call_inst
->
field
)
==
ResultType
::
i32
)
{
call_pop
.
field
=
pop_i32_idx
;
INSERT_INJECTED
(
call_pop
);
}
else
if
(
get_return_type
(
call_inst
->
field
)
==
ResultType
::
i64
)
{
call_pop
.
field
=
pop_i64_idx
;
INSERT_INJECTED
(
call_pop
);
}
else
if
(
get_return_type
(
call_inst
->
field
)
==
ResultType
::
f32
)
{
call_pop
.
field
=
pop_f32_idx
;
INSERT_INJECTED
(
call_pop
);
}
else
if
(
get_return_type
(
call_inst
->
field
)
==
ResultType
::
f64
)
{
call_pop
.
field
=
pop_f64_idx
;
INSERT_INJECTED
(
call_pop
);
}
else
{
call_pop
.
field
=
pop_none_idx
;
INSERT_INJECTED
(
call_pop
);
}
#endif
#if 0
const_inst.field = 1;
const_inst.field = 1;
INSERT_INJECTED
(
get_global_inst
);
INSERT_INJECTED(
block_inst);
INSERT_INJECTED(const_inst);
INSERT_INJECTED(const_inst);
INSERT_INJECTED(get_global_inst);
INSERT_INJECTED(add_inst);
INSERT_INJECTED(add_inst);
INSERT_INJECTED(set_global_inst);
INSERT_INJECTED(set_global_inst);
INSERT_INJECTED(end_inst);
#endif
#if 0
if ( get_return_type(call_inst->field) == ResultType::i32 ) {
std::cout << "I32 " << std::endl;
get_call_return_inst.field = global_return_i32_idx;
INSERT_INJECTED(get_call_return_inst);
}
else if ( get_return_type(call_inst->field) == ResultType::i64 ) {
std::cout << "I64 " << std::endl;
get_call_return_inst.field = global_return_i64_idx;
INSERT_INJECTED(get_call_return_inst);
}
else if ( get_return_type(call_inst->field) == ResultType::f32 ) {
std::cout << "F64 " << std::endl;
get_call_return_inst.field = global_return_f32_idx;
INSERT_INJECTED(get_call_return_inst);
}
else if ( get_return_type(call_inst->field) == ResultType::f64 ) {
std::cout << "F32 " << std::endl;
get_call_return_inst.field = global_return_f64_idx;
INSERT_INJECTED(get_call_return_inst);
}
#endif
#undef INSERT_INJECTED
#undef INSERT_INJECTED
arg
.
new_code
->
insert
(
arg
.
new_code
->
end
(),
injected
.
begin
(),
injected
.
end
()
);
arg
.
new_code
->
insert
(
arg
.
new_code
->
end
(),
injected
.
begin
(),
injected
.
end
()
);
}
}
...
@@ -853,6 +939,8 @@ namespace eosio { namespace chain { namespace wasm_injections {
...
@@ -853,6 +939,8 @@ namespace eosio { namespace chain { namespace wasm_injections {
void
inject
()
{
void
inject
()
{
_module_injectors
.
inject
(
*
_module
);
_module_injectors
.
inject
(
*
_module
);
for
(
auto
&
fd
:
_module
->
functions
.
defs
)
{
for
(
auto
&
fd
:
_module
->
functions
.
defs
)
{
// initialize call_return_local, for each function
// TODO clean this up
wasm_ops
::
EOSIO_OperatorDecoderStream
<
pre_op_injectors
>
pre_decoder
(
fd
.
code
);
wasm_ops
::
EOSIO_OperatorDecoderStream
<
pre_op_injectors
>
pre_decoder
(
fd
.
code
);
std
::
vector
<
U8
>
new_code
;
std
::
vector
<
U8
>
new_code
;
while
(
pre_decoder
)
{
while
(
pre_decoder
)
{
...
...
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
浏览文件 @
2fee3793
...
@@ -67,6 +67,7 @@ namespace eosio { namespace chain {
...
@@ -67,6 +67,7 @@ namespace eosio { namespace chain {
bytes
=
outstream
.
getBytes
();
bytes
=
outstream
.
getBytes
();
char
*
buff
=
new
char
[
bytes
.
size
()];
char
*
buff
=
new
char
[
bytes
.
size
()];
memcpy
(
buff
,
bytes
.
data
(),
bytes
.
size
());
memcpy
(
buff
,
bytes
.
data
(),
bytes
.
size
());
std
::
cout
<<
"WASM_FILE : "
<<
"wasm_"
+
std
::
to_string
(
ii
+
1
)
<<
std
::
endl
;
std
::
ofstream
output
(
std
::
string
(
"wasm_"
)
+
std
::
to_string
(
ii
++
)
+
std
::
string
(
".wasm"
));
std
::
ofstream
output
(
std
::
string
(
"wasm_"
)
+
std
::
to_string
(
ii
++
)
+
std
::
string
(
".wasm"
));
output
.
write
(
buff
,
bytes
.
size
());
output
.
write
(
buff
,
bytes
.
size
());
delete
[]
buff
;
delete
[]
buff
;
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
2fee3793
...
@@ -1518,7 +1518,12 @@ class call_depth_api : public context_aware_api {
...
@@ -1518,7 +1518,12 @@ class call_depth_api : public context_aware_api {
};
};
REGISTER_INJECTED_INTRINSICS
(
call_depth_api
,
REGISTER_INJECTED_INTRINSICS
(
call_depth_api
,
(
call_depth_assert
,
void
()
)
(
call_depth_assert
,
void
()
)
(
call_depth_pop_i32
,
int
(
int
,
int
)
)
(
call_depth_pop_i64
,
int64_t
(
int64_t
,
int
))
(
call_depth_pop_f32
,
float
(
float
,
int
)
)
(
call_depth_pop_f64
,
double
(
double
,
int
)
)
(
call_depth_pop
,
void
(
int
)
)
);
);
REGISTER_INTRINSICS
(
math_api
,
REGISTER_INTRINSICS
(
math_api
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录