Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
94697ba4
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,发现更多精彩内容 >>
提交
94697ba4
编写于
8月 20, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename `LocalWithRegion` to `LiveVar`
上级
43748552
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
22 deletion
+22
-22
src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs
..._mir/borrow_check/nll/type_check/liveness/liveness_map.rs
+8
-8
src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs
...mir/borrow_check/nll/type_check/liveness/local_use_map.rs
+10
-10
src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
...ibrustc_mir/borrow_check/nll/type_check/liveness/trace.rs
+4
-4
未找到文件。
src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs
浏览文件 @
94697ba4
...
...
@@ -10,9 +10,9 @@
//! For the NLL computation, we need to compute liveness, but only for those
//! local variables whose types contain regions. The others are not of interest
//! to us. This file defines a new index type (L
ocalWithRegion
) that indexes into
//! to us. This file defines a new index type (L
iveVar
) that indexes into
//! a list of "variables whose type contain regions". It also defines a map from
//! Local to L
ocalWithRegion
and vice versa -- this map can be given to the
//! Local to L
iveVar
and vice versa -- this map can be given to the
//! liveness code so that it only operates over variables with regions in their
//! types, instead of all variables.
...
...
@@ -23,7 +23,7 @@
use
rustc_data_structures
::
indexed_vec
::{
Idx
,
IndexVec
};
use
util
::
liveness
::
LiveVariableMap
;
/// Map between Local and L
ocalWithRegion
indices: the purpose of this
/// Map between Local and L
iveVar
indices: the purpose of this
/// map is to define the subset of local variables for which we need
/// to do a liveness computation. We only need to compute whether a
/// variable `X` is live if that variable contains some region `R` in
...
...
@@ -32,10 +32,10 @@
crate
struct
NllLivenessMap
{
/// For each local variable, contains `Some(i)` if liveness is
/// needed for this variable.
pub
from_local
:
IndexVec
<
Local
,
Option
<
L
ocalWithRegion
>>
,
pub
from_local
:
IndexVec
<
Local
,
Option
<
L
iveVar
>>
,
/// For each `L
ocalWithRegion
`, maps back to the original `Local` index.
pub
to_local
:
IndexVec
<
L
ocalWithRegion
,
Local
>
,
/// For each `L
iveVar
`, maps back to the original `Local` index.
pub
to_local
:
IndexVec
<
L
iveVar
,
Local
>
,
}
impl
LiveVariableMap
for
NllLivenessMap
{
...
...
@@ -43,7 +43,7 @@ fn from_local(&self, local: Local) -> Option<Self::LiveVar> {
self
.from_local
[
local
]
}
type
LiveVar
=
L
ocalWithRegion
;
type
LiveVar
=
L
iveVar
;
fn
from_live_var
(
&
self
,
local
:
Self
::
LiveVar
)
->
Local
{
self
.to_local
[
local
]
...
...
@@ -94,4 +94,4 @@ impl NllLivenessMap {
}
/// Index given to each local variable whose type contains a region.
newtype_index!
(
L
ocalWithRegion
);
newtype_index!
(
L
iveVar
);
src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs
浏览文件 @
94697ba4
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
borrow_check
::
nll
::
region_infer
::
values
::{
PointIndex
,
RegionValueElements
};
use
borrow_check
::
nll
::
type_check
::
liveness
::
liveness_map
::{
L
ocalWithRegion
,
NllLivenessMap
};
use
borrow_check
::
nll
::
type_check
::
liveness
::
liveness_map
::{
L
iveVar
,
NllLivenessMap
};
use
rustc
::
mir
::
visit
::{
PlaceContext
,
Visitor
};
use
rustc
::
mir
::{
Local
,
Location
,
Mir
};
use
rustc_data_structures
::
indexed_vec
::{
Idx
,
IndexVec
};
...
...
@@ -27,18 +27,18 @@
/// defined in `x = y` but not `y`; that first def is the head of
/// a linked list that lets you enumerate all places the variable
/// is assigned.
first_def_at
:
IndexVec
<
L
ocalWithRegion
,
Option
<
AppearanceIndex
>>
,
first_def_at
:
IndexVec
<
L
iveVar
,
Option
<
AppearanceIndex
>>
,
/// Head of a linked list of **uses** of each variable -- use in
/// this context means that the existing value of the variable is
/// read or modified. e.g., `y` is used in `x = y` but not `x`.
/// Note that `DROP(x)` terminators are excluded from this list.
first_use_at
:
IndexVec
<
L
ocalWithRegion
,
Option
<
AppearanceIndex
>>
,
first_use_at
:
IndexVec
<
L
iveVar
,
Option
<
AppearanceIndex
>>
,
/// Head of a linked list of **drops** of each variable -- these
/// are a special category of uses corresponding to the drop that
/// we add for each local variable.
first_drop_at
:
IndexVec
<
L
ocalWithRegion
,
Option
<
AppearanceIndex
>>
,
first_drop_at
:
IndexVec
<
L
iveVar
,
Option
<
AppearanceIndex
>>
,
appearances
:
IndexVec
<
AppearanceIndex
,
Appearance
>
,
}
...
...
@@ -81,17 +81,17 @@ impl LocalUseMap<'me> {
local_use_map
}
crate
fn
defs
(
&
self
,
local
:
L
ocalWithRegion
)
->
impl
Iterator
<
Item
=
PointIndex
>
+
'_
{
crate
fn
defs
(
&
self
,
local
:
L
iveVar
)
->
impl
Iterator
<
Item
=
PointIndex
>
+
'_
{
vll
::
iter
(
self
.first_def_at
[
local
],
&
self
.appearances
)
.map
(
move
|
aa
|
self
.appearances
[
aa
]
.point_index
)
}
crate
fn
uses
(
&
self
,
local
:
L
ocalWithRegion
)
->
impl
Iterator
<
Item
=
PointIndex
>
+
'_
{
crate
fn
uses
(
&
self
,
local
:
L
iveVar
)
->
impl
Iterator
<
Item
=
PointIndex
>
+
'_
{
vll
::
iter
(
self
.first_use_at
[
local
],
&
self
.appearances
)
.map
(
move
|
aa
|
self
.appearances
[
aa
]
.point_index
)
}
crate
fn
drops
(
&
self
,
local
:
L
ocalWithRegion
)
->
impl
Iterator
<
Item
=
PointIndex
>
+
'_
{
crate
fn
drops
(
&
self
,
local
:
L
iveVar
)
->
impl
Iterator
<
Item
=
PointIndex
>
+
'_
{
vll
::
iter
(
self
.first_drop_at
[
local
],
&
self
.appearances
)
.map
(
move
|
aa
|
self
.appearances
[
aa
]
.point_index
)
}
...
...
@@ -103,7 +103,7 @@ struct LocalUseMapBuild<'me, 'map> {
}
impl
LocalUseMapBuild
<
'_
,
'_
>
{
fn
insert_def
(
&
mut
self
,
local
:
L
ocalWithRegion
,
location
:
Location
)
{
fn
insert_def
(
&
mut
self
,
local
:
L
iveVar
,
location
:
Location
)
{
Self
::
insert
(
self
.elements
,
&
mut
self
.local_use_map.first_def_at
[
local
],
...
...
@@ -112,7 +112,7 @@ fn insert_def(&mut self, local: LocalWithRegion, location: Location) {
);
}
fn
insert_use
(
&
mut
self
,
local
:
L
ocalWithRegion
,
location
:
Location
)
{
fn
insert_use
(
&
mut
self
,
local
:
L
iveVar
,
location
:
Location
)
{
Self
::
insert
(
self
.elements
,
&
mut
self
.local_use_map.first_use_at
[
local
],
...
...
@@ -121,7 +121,7 @@ fn insert_use(&mut self, local: LocalWithRegion, location: Location) {
);
}
fn
insert_drop
(
&
mut
self
,
local
:
L
ocalWithRegion
,
location
:
Location
)
{
fn
insert_drop
(
&
mut
self
,
local
:
L
iveVar
,
location
:
Location
)
{
Self
::
insert
(
self
.elements
,
&
mut
self
.local_use_map.first_drop_at
[
local
],
...
...
src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
浏览文件 @
94697ba4
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
borrow_check
::
nll
::
region_infer
::
values
::{
self
,
PointIndex
,
RegionValueElements
};
use
borrow_check
::
nll
::
type_check
::
liveness
::
liveness_map
::{
L
ocalWithRegion
,
NllLivenessMap
};
use
borrow_check
::
nll
::
type_check
::
liveness
::
liveness_map
::{
L
iveVar
,
NllLivenessMap
};
use
borrow_check
::
nll
::
type_check
::
liveness
::
local_use_map
::
LocalUseMap
;
use
borrow_check
::
nll
::
type_check
::
liveness
::
point_index_map
::
PointIndexMap
;
use
borrow_check
::
nll
::
type_check
::
AtLocation
;
...
...
@@ -194,7 +194,7 @@ fn reset_local_state(&mut self) {
}
/// Adds the definitions of `local` into `self.defs`.
fn
add_defs_for
(
&
mut
self
,
live_local
:
L
ocalWithRegion
)
{
fn
add_defs_for
(
&
mut
self
,
live_local
:
L
iveVar
)
{
for
def
in
self
.cx.local_use_map
.defs
(
live_local
)
{
debug!
(
"- defined at {:?}"
,
def
);
self
.defs
.insert
(
def
);
...
...
@@ -207,7 +207,7 @@ fn add_defs_for(&mut self, live_local: LocalWithRegion) {
/// find a `def` of local.
///
/// Requires `add_defs_for(live_local)` to have been executed.
fn
compute_use_live_points_for
(
&
mut
self
,
live_local
:
L
ocalWithRegion
)
{
fn
compute_use_live_points_for
(
&
mut
self
,
live_local
:
L
iveVar
)
{
debug!
(
"compute_use_live_points_for(live_local={:?})"
,
live_local
);
self
.stack
.extend
(
self
.cx.local_use_map
.uses
(
live_local
));
...
...
@@ -233,7 +233,7 @@ fn compute_use_live_points_for(&mut self, live_local: LocalWithRegion) {
///
/// Requires `compute_use_live_points_for` and `add_defs_for` to
/// have been executed.
fn
compute_drop_live_points_for
(
&
mut
self
,
live_local
:
L
ocalWithRegion
)
{
fn
compute_drop_live_points_for
(
&
mut
self
,
live_local
:
L
iveVar
)
{
debug!
(
"compute_drop_live_points_for(live_local={:?})"
,
live_local
);
let
local
=
self
.cx.liveness_map
.from_live_var
(
live_local
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录