Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
1eb34a6e
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,发现更多精彩内容 >>
提交
1eb34a6e
编写于
1月 10, 2018
作者:
B
Bucky Kittinger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
@DAWN-391 house cleaning
上级
a1a2dcfa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
43 deletion
+38
-43
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
...ries/chain/include/eosio/chain/wasm_interface_private.hpp
+0
-2
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+38
-41
未找到文件。
libraries/chain/include/eosio/chain/wasm_interface_private.hpp
浏览文件 @
1eb34a6e
...
...
@@ -421,9 +421,7 @@ struct intrinsic_invoker_impl<Ret, std::tuple<array_ptr<T>, array_ptr<U>, size_t
*/
template
<
typename
Ret
>
struct
intrinsic_invoker_impl
<
Ret
,
std
::
tuple
<
array_ptr
<
char
>
,
int
,
size_t
>
,
std
::
tuple
<>>
{
//using next_step = intrinsic_invoker_impl<void_type, std::tuple<>, std::tuple<I32, I32, I32>>;
using
next_step
=
intrinsic_invoker_impl
<
Ret
,
std
::
tuple
<>
,
std
::
tuple
<
I32
,
I32
,
I32
>>
;
//using then_type = void_type(*)(wasm_interface &, array_ptr<char>, int, size_t);
using
then_type
=
Ret
(
*
)(
wasm_interface
&
,
array_ptr
<
char
>
,
int
,
size_t
);
template
<
then_type
Then
>
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
1eb34a6e
...
...
@@ -23,7 +23,6 @@
#include <mutex>
#include <thread>
#include <condition_variable>
//#include <iostream>
...
...
@@ -627,8 +626,8 @@ class context_aware_api {
{}
protected:
wasm_cache
::
entry
&
code
;
apply_context
&
context
;
wasm_cache
::
entry
&
code
;
apply_context
&
context
;
};
class
system_api
:
public
context_aware_api
{
...
...
@@ -822,44 +821,42 @@ class memory_api : public context_aware_api {
return
::
memcmp
(
dest
,
src
,
length
);
}
char
*
memset
(
array_ptr
<
char
>
dest
,
int
value
,
size_t
length
)
{
return
(
char
*
)
::
memset
(
dest
,
value
,
length
);
}
uint32_t
sbrk
(
int
num_bytes
)
{
// TODO: omitted checktime function from previous version of sbrk, may need to be put back in at some point
constexpr
uint32_t
NBPPL2
=
IR
::
numBytesPerPageLog2
;
constexpr
uint32_t
max_mem
=
1024
*
1024
;
const
auto
default_mem
=
Runtime
::
getDefaultMemory
(
code
.
instance
);
const
uint32_t
num_pages
=
Runtime
::
getMemoryNumPages
(
default_mem
);
// limit this min to 32 bit space
const
uint32_t
min_bytes
=
(
num_pages
<<
NBPPL2
)
>
UINT32_MAX
?
UINT32_MAX
:
num_pages
<<
NBPPL2
;
static
uint32_t
_num_bytes
=
min_bytes
;
const
uint32_t
prev_num_bytes
=
_num_bytes
;
if
(
Runtime
::
getMemoryNumPages
(
default_mem
)
!=
num_pages
)
throw
eosio
::
chain
::
page_memory_error
();
// round the absolute value of num_bytes to an alignment boundary
num_bytes
=
(
num_bytes
+
7
)
&
~
7
;
if
((
num_bytes
>
0
)
&&
(
prev_num_bytes
>
(
max_mem
-
num_bytes
)))
// test if allocating too much memory (overflowed)
throw
eosio
::
chain
::
page_memory_error
();
else
if
((
num_bytes
<
0
)
&&
(
prev_num_bytes
<
(
min_bytes
-
num_bytes
)))
// test for underflow
throw
eosio
::
chain
::
page_memory_error
();
// update the number of bytes allocated, and compute the number of pages needed
_num_bytes
+=
num_bytes
;
const
uint32_t
num_desired_pages
=
(
_num_bytes
+
IR
::
numBytesPerPage
-
1
)
>>
NBPPL2
;
// grow or shrink the memory to the desired number of pages
if
(
num_desired_pages
>
num_pages
)
Runtime
::
growMemory
(
default_mem
,
num_desired_pages
-
num_pages
);
else
if
(
num_desired_pages
<
num_pages
)
Runtime
::
shrinkMemory
(
default_mem
,
num_pages
-
num_desired_pages
);
return
prev_num_bytes
;
}
char
*
memset
(
array_ptr
<
char
>
dest
,
int
value
,
size_t
length
)
{
return
(
char
*
)
::
memset
(
dest
,
value
,
length
);
}
uint32_t
sbrk
(
int
num_bytes
)
{
// TODO: omitted checktime function from previous version of sbrk, may need to be put back in at some point
constexpr
uint32_t
NBPPL2
=
IR
::
numBytesPerPageLog2
;
constexpr
uint32_t
max_mem
=
1024
*
1024
;
const
auto
default_mem
=
Runtime
::
getDefaultMemory
(
code
.
instance
);
const
uint32_t
num_pages
=
Runtime
::
getMemoryNumPages
(
default_mem
);
// limit this min to 32 bit space
const
uint32_t
min_bytes
=
(
num_pages
<<
NBPPL2
)
>
UINT32_MAX
?
UINT32_MAX
:
num_pages
<<
NBPPL2
;
static
uint32_t
_num_bytes
=
min_bytes
;
const
uint32_t
prev_num_bytes
=
_num_bytes
;
// round the absolute value of num_bytes to an alignment boundary
num_bytes
=
(
num_bytes
+
7
)
&
~
7
;
if
((
num_bytes
>
0
)
&&
(
prev_num_bytes
>
(
max_mem
-
num_bytes
)))
// test if allocating too much memory (overflowed)
throw
eosio
::
chain
::
page_memory_error
();
else
if
((
num_bytes
<
0
)
&&
(
prev_num_bytes
<
(
min_bytes
-
num_bytes
)))
// test for underflow
throw
eosio
::
chain
::
page_memory_error
();
// update the number of bytes allocated, and compute the number of pages needed
_num_bytes
+=
num_bytes
;
const
uint32_t
num_desired_pages
=
(
_num_bytes
+
IR
::
numBytesPerPage
-
1
)
>>
NBPPL2
;
// grow or shrink the memory to the desired number of pages
if
(
num_desired_pages
>
num_pages
)
Runtime
::
growMemory
(
default_mem
,
num_desired_pages
-
num_pages
);
else
if
(
num_desired_pages
<
num_pages
)
Runtime
::
shrinkMemory
(
default_mem
,
num_pages
-
num_desired_pages
);
return
prev_num_bytes
;
}
};
class
transaction_api
:
public
context_aware_api
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录