Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
15919774
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
15919774
编写于
9月 09, 2017
作者:
R
Ralf Jung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up suspensions when function ends
上级
bc2f9259
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
24 deletion
+33
-24
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/eval_context.rs
+4
-6
src/librustc_mir/interpret/memory.rs
src/librustc_mir/interpret/memory.rs
+1
-5
src/librustc_mir/interpret/step.rs
src/librustc_mir/interpret/step.rs
+1
-1
src/librustc_mir/interpret/validation.rs
src/librustc_mir/interpret/validation.rs
+27
-12
未找到文件。
src/librustc_mir/interpret/eval_context.rs
浏览文件 @
15919774
...
...
@@ -508,8 +508,7 @@ fn collect_storage_annotations<'tcx>(mir: &'tcx mir::Mir<'tcx>) -> HashSet<mir::
stmt
:
0
,
});
let
cur_frame
=
self
.cur_frame
();
self
.memory
.set_cur_frame
(
cur_frame
);
self
.memory.cur_frame
=
self
.cur_frame
();
if
self
.stack
.len
()
>
self
.stack_limit
{
err!
(
StackFrameLimitReached
)
...
...
@@ -520,14 +519,13 @@ fn collect_storage_annotations<'tcx>(mir: &'tcx mir::Mir<'tcx>) -> HashSet<mir::
pub
(
super
)
fn
pop_stack_frame
(
&
mut
self
)
->
EvalResult
<
'tcx
>
{
::
log_settings
::
settings
()
.indentation
-=
1
;
self
.
memory
.locks_lifetime_ended
(
None
)
;
self
.
end_region
(
None
)
?
;
let
frame
=
self
.stack
.pop
()
.expect
(
"tried to pop a stack frame, but there were none"
,
);
if
!
self
.stack
.is_empty
()
{
// TODO: IS this the correct time to start considering these accesses as originating from the returned-to stack frame?
let
cur_frame
=
self
.cur_frame
();
self
.memory
.set_cur_frame
(
cur_frame
);
// TODO: Is this the correct time to start considering these accesses as originating from the returned-to stack frame?
self
.memory.cur_frame
=
self
.cur_frame
();
}
match
frame
.return_to_block
{
StackPopCleanup
::
MarkStatic
(
mutable
)
=>
{
...
...
src/librustc_mir/interpret/memory.rs
浏览文件 @
15919774
...
...
@@ -268,7 +268,7 @@ pub struct Memory<'a, 'tcx, M: Machine<'tcx>> {
writes_are_aligned
:
Cell
<
bool
>
,
/// The current stack frame. Used to check accesses against locks.
cur_frame
:
usize
,
pub
cur_frame
:
usize
,
}
impl
<
'a
,
'tcx
,
M
:
Machine
<
'tcx
>>
Memory
<
'a
,
'tcx
,
M
>
{
...
...
@@ -530,10 +530,6 @@ pub fn check_bounds(&self, ptr: MemoryPointer, access: bool) -> EvalResult<'tcx>
}
Ok
(())
}
pub
(
crate
)
fn
set_cur_frame
(
&
mut
self
,
cur_frame
:
usize
)
{
self
.cur_frame
=
cur_frame
;
}
}
/// Locking
...
...
src/librustc_mir/interpret/step.rs
浏览文件 @
15919774
...
...
@@ -164,7 +164,7 @@ fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx> {
}
}
EndRegion
(
ce
)
=>
{
self
.end_region
(
ce
)
?
;
self
.end_region
(
Some
(
ce
)
)
?
;
}
// Defined to do nothing. These are added by optimization passes, to avoid changing the
...
...
src/librustc_mir/interpret/validation.rs
浏览文件 @
15919774
...
...
@@ -45,6 +45,7 @@ pub(crate) fn validation_op(
if
self
.tcx.sess.opts.debugging_opts.mir_emit_validate
==
0
{
return
Ok
(());
}
debug_assert!
(
self
.memory.cur_frame
==
self
.cur_frame
());
// HACK: Determine if this method is whitelisted and hence we do not perform any validation.
// We currently insta-UB on anything passing around uninitialized memory, so we have to whitelist
...
...
@@ -93,7 +94,8 @@ pub(crate) fn validation_op(
if
query
.mutbl
==
MutMutable
{
let
lft
=
DynamicLifetime
{
frame
:
self
.cur_frame
(),
region
:
Some
(
scope
),
region
:
Some
(
scope
),
// Notably, we only ever suspend things for given regions.
// Suspending for the entire function does not make any sense.
};
trace!
(
"Suspending {:?} until {:?}"
,
query
,
scope
);
self
.suspended
.entry
(
lft
)
.or_insert_with
(
Vec
::
new
)
.push
(
...
...
@@ -106,17 +108,30 @@ pub(crate) fn validation_op(
self
.validate
(
query
,
mode
)
}
pub
(
crate
)
fn
end_region
(
&
mut
self
,
scope
:
region
::
Scope
)
->
EvalResult
<
'tcx
>
{
self
.memory
.locks_lifetime_ended
(
Some
(
scope
));
// Recover suspended lvals
let
lft
=
DynamicLifetime
{
frame
:
self
.cur_frame
(),
region
:
Some
(
scope
),
};
if
let
Some
(
queries
)
=
self
.suspended
.remove
(
&
lft
)
{
for
query
in
queries
{
trace!
(
"Recovering {:?} from suspension"
,
query
);
self
.validate
(
query
,
ValidationMode
::
Recover
(
scope
))
?
;
/// Release locks and executes suspensions of the given region (or the entire fn, in case of None).
pub
(
crate
)
fn
end_region
(
&
mut
self
,
scope
:
Option
<
region
::
Scope
>
)
->
EvalResult
<
'tcx
>
{
debug_assert!
(
self
.memory.cur_frame
==
self
.cur_frame
());
self
.memory
.locks_lifetime_ended
(
scope
);
match
scope
{
Some
(
scope
)
=>
{
// Recover suspended lvals
let
lft
=
DynamicLifetime
{
frame
:
self
.cur_frame
(),
region
:
Some
(
scope
),
};
if
let
Some
(
queries
)
=
self
.suspended
.remove
(
&
lft
)
{
for
query
in
queries
{
trace!
(
"Recovering {:?} from suspension"
,
query
);
self
.validate
(
query
,
ValidationMode
::
Recover
(
scope
))
?
;
}
}
}
None
=>
{
// Clean suspension table of current frame
let
cur_frame
=
self
.cur_frame
();
self
.suspended
.retain
(|
lft
,
_
|
{
lft
.frame
!=
cur_frame
// keep only what is in the other (lower) frames
});
}
}
Ok
(())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录