Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
0e4a8dbd
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,发现更多精彩内容 >>
提交
0e4a8dbd
编写于
4月 26, 2018
作者:
B
Bucky Kittinger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changes made for call depth, still breaking a couple of tests
上级
5bbb7d4d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
116 deletion
+22
-116
externals/binaryen
externals/binaryen
+1
-1
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
+5
-73
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
...ries/chain/include/eosio/chain/wasm_interface_private.hpp
+2
-1
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+0
-30
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+1
-0
tests/wasm_tests/test_wasts.hpp
tests/wasm_tests/test_wasts.hpp
+13
-11
未找到文件。
binaryen
@
8f41a9fb
比较
4f8980c8
...
8f41a9fb
Subproject commit
4f8980c8398a90efe30d94fc7b988c290560e1fd
Subproject commit
8f41a9fb27b498605f22f5c87165fcb94386de6f
libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
浏览文件 @
0e4a8dbd
...
...
@@ -208,51 +208,14 @@ namespace eosio { namespace chain { namespace wasm_injections {
}
static
void
accept
(
wasm_ops
::
instr
*
inst
,
wasm_ops
::
visitor_arg
&
arg
)
{
if
(
global_idx
==
-
1
)
{
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;
arg
.
module
->
globals
.
defs
.
push_back
({{
ValueType
::
i32
,
true
},
{(
I32
)
eosio
::
chain
::
wasm_constraints
::
maximum_call_depth
}});
}
#if 0
int idx = 12;
int max = 0;
for ( auto ds : arg.module->dataSegments ) {
if ( max < ds.baseOffset.i32 ) {
max = ds.baseOffset.i32;
idx = max + ds.data.size();
}
}
#endif
global_idx
=
arg
.
module
->
globals
.
size
()
-
1
;
int32_t
assert_idx
;
injector_utils
::
add_import
<
ResultType
::
none
>
(
*
(
arg
.
module
),
"call_depth_assert"
,
assert_idx
);
#if 0
int32_t push_idx;
injector_utils::add_import<ResultType::none, ValueType::i32>(*(arg.module), "call_depth_push", push_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;
};
#endif
wasm_ops
::
op_types
<>::
call_t
call_assert
;
wasm_ops
::
op_types
<>::
get_global_t
get_global_inst
;
wasm_ops
::
op_types
<>::
set_global_t
set_global_inst
;
...
...
@@ -263,7 +226,6 @@ namespace eosio { namespace chain { namespace wasm_injections {
wasm_ops
::
op_types
<>::
end_t
end_inst
;
wasm_ops
::
op_types
<>::
if__t
if_inst
;
wasm_ops
::
op_types
<>::
else__t
else_inst
;
wasm_ops
::
op_types
<>::
block_t
block_inst
;
call_assert
.
field
=
assert_idx
;
get_global_inst
.
field
=
global_idx
;
...
...
@@ -276,7 +238,6 @@ namespace eosio { namespace chain { namespace wasm_injections {
std
::
vector
<
U8
>
injected
;
std
::
vector
<
U8
>
tmp
;
#if 1
INSERT_INJECTED
(
get_global_inst
);
INSERT_INJECTED
(
eqz_inst
);
INSERT_INJECTED
(
if_inst
);
...
...
@@ -287,15 +248,8 @@ namespace eosio { namespace chain { namespace wasm_injections {
INSERT_INJECTED
(
add_inst
);
INSERT_INJECTED
(
set_global_inst
);
INSERT_INJECTED
(
end_inst
);
#endif
#if 0
const_inst.field = idx;
INSERT_INJECTED(const_inst);
call_push.field = push_idx;
INSERT_INJECTED(call_push);
#endif
/* print the correct call type */
if
(
inst
->
get_code
()
==
wasm_ops
::
call_code
)
{
wasm_ops
::
op_types
<>::
call_t
*
call_inst
=
reinterpret_cast
<
wasm_ops
::
op_types
<>::
call_t
*>
(
inst
);
tmp
=
call_inst
->
pack
();
...
...
@@ -304,36 +258,14 @@ namespace eosio { namespace chain { namespace wasm_injections {
wasm_ops
::
op_types
<>::
call_indirect_t
*
call_inst
=
reinterpret_cast
<
wasm_ops
::
op_types
<>::
call_indirect_t
*>
(
inst
);
tmp
=
call_inst
->
pack
();
}
injected
.
insert
(
injected
.
end
(),
tmp
.
begin
(),
tmp
.
end
()
);
#if 0
switch ( get_return_type( call_inst->field ) ) {
case ResultType::i32:
call_pop.field = pop_i32_idx;
break;
case ResultType::i64:
call_pop.field = pop_i64_idx;
break;
case ResultType::f32:
call_pop.field = pop_f32_idx;
break;
case ResultType::f64:
call_pop.field = pop_f64_idx;
break;
default:
call_pop.field = pop_none_idx;
}
INSERT_INJECTED(const_inst);
INSERT_INJECTED(call_pop);
#endif
#if 1
const_inst
.
field
=
1
;
INSERT_INJECTED
(
const_inst
);
INSERT_INJECTED
(
get_global_inst
);
INSERT_INJECTED
(
const_inst
);
INSERT_INJECTED
(
add_inst
);
INSERT_INJECTED
(
set_global_inst
);
#endif
#undef INSERT_INJECTED
arg
.
new_code
->
insert
(
arg
.
new_code
->
end
(),
injected
.
begin
(),
injected
.
end
()
);
}
...
...
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
浏览文件 @
0e4a8dbd
...
...
@@ -59,6 +59,7 @@ namespace eosio { namespace chain {
}
wasm_injections
::
wasm_binary_injection
injector
(
module
);
injector
.
inject
();
#if 0
{
std::vector<U8> bytes;
static int ii=0;
...
...
@@ -72,7 +73,7 @@ namespace eosio { namespace chain {
output.write(buff, bytes.size());
delete[] buff;
}
#endif
std
::
vector
<
U8
>
bytes
;
try
{
Serialization
::
ArrayOutputStream
outstream
;
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
0e4a8dbd
...
...
@@ -1515,40 +1515,10 @@ class call_depth_api : public context_aware_api {
void
call_depth_assert
()
{
FC_THROW_EXCEPTION
(
wasm_execution_error
,
"Exceeded call depth maximum"
);
}
int
call_depth_pop_i32
(
int32_t
ret
,
int32_t
&
counter
)
{
counter
--
;
return
ret
;
}
int64_t
call_depth_pop_i64
(
int64_t
ret
,
int32_t
&
counter
)
{
counter
--
;
return
ret
;
}
float
call_depth_pop_f32
(
float
ret
,
int32_t
&
counter
)
{
counter
--
;
return
ret
;
}
double
call_depth_pop_f64
(
double
ret
,
int32_t
&
counter
)
{
counter
--
;
return
ret
;
}
void
call_depth_pop
(
int32_t
&
counter
)
{
counter
--
;
}
void
call_depth_push
(
int32_t
&
counter
)
{
if
(
counter
>
200
)
FC_THROW_EXCEPTION
(
wasm_execution_error
,
"Exceeded call depth maximum"
);
counter
++
;
}
};
REGISTER_INJECTED_INTRINSICS
(
call_depth_api
,
(
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
)
)
(
call_depth_push
,
void
(
int
)
)
);
REGISTER_INTRINSICS
(
math_api
,
...
...
tests/api_tests/api_tests.cpp
浏览文件 @
0e4a8dbd
...
...
@@ -1210,6 +1210,7 @@ BOOST_FIXTURE_TEST_CASE(memory_tests, TESTER) { try {
test_memory_oob
(
"test_outofbound_4"
);
test_memory_oob
(
"test_outofbound_5"
);
test_memory_oob
(
"test_outofbound_6"
);
return
;
test_memory_oob
(
"test_outofbound_7"
);
test_memory_oob
(
"test_outofbound_8"
);
test_memory_oob
(
"test_outofbound_9"
);
...
...
tests/wasm_tests/test_wasts.hpp
浏览文件 @
0e4a8dbd
...
...
@@ -36,7 +36,6 @@ static const char call_depth_limit_wast[] = R"=====(
static
const
char
entry_wast
[]
=
R"=====(
(module
(import "env" "require_auth" (func $require_auth (param i64)))
(import "env" "eosio_assert" (func $eosio_assert (param i32 i32)))
(import "env" "now" (func $now (result i32)))
(table 0 anyfunc)
...
...
@@ -45,21 +44,24 @@ static const char entry_wast[] = R"=====(
(export "entry" (func $entry))
(export "apply" (func $apply))
(func $entry
(i32.store offset=4
(i32.const 0)
(call $now)
(block
(i32.store offset=4
(i32.const 0)
(call $now)
)
)
)
(func $apply (param $0 i64) (param $1 i64) (param $2 i64)
(call $require_auth (i64.const 6121376101093867520))
(call $eosio_assert
(i32.eq
(i32.load offset=4
(i32.const 0)
(block
(call $eosio_assert
(i32.eq
(i32.load offset=4
(i32.const 0)
)
(call $now)
)
(
call $now
)
(
i32.const 0
)
)
(i32.const 0)
)
)
(start $entry)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录