Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8fbc91cf
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,发现更多精彩内容 >>
提交
8fbc91cf
编写于
11月 22, 2017
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
incr.comp.: Make MIR encoding fit for incr.comp. caching.
上级
436ac892
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
81 addition
and
27 deletion
+81
-27
src/librustc/ich/impls_mir.rs
src/librustc/ich/impls_mir.rs
+3
-3
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+8
-17
src/librustc/ty/maps/on_disk_cache.rs
src/librustc/ty/maps/on_disk_cache.rs
+45
-0
src/librustc_metadata/decoder.rs
src/librustc_metadata/decoder.rs
+9
-0
src/librustc_metadata/encoder.rs
src/librustc_metadata/encoder.rs
+9
-0
src/librustc_mir/build/mod.rs
src/librustc_mir/build/mod.rs
+1
-1
src/librustc_mir/shim.rs
src/librustc_mir/shim.rs
+4
-4
src/librustc_mir/transform/check_unsafety.rs
src/librustc_mir/transform/check_unsafety.rs
+2
-2
未找到文件。
src/librustc/ich/impls_mir.rs
浏览文件 @
8fbc91cf
...
...
@@ -98,7 +98,7 @@ fn hash_stable<W: StableHasherResult>(&self,
}
}
impl
<
'gcx
,
T
>
HashStable
<
StableHashingContext
<
'gcx
>>
for
mir
::
Clear
OnDecod
e
<
T
>
impl
<
'gcx
,
T
>
HashStable
<
StableHashingContext
<
'gcx
>>
for
mir
::
Clear
CrossCrat
e
<
T
>
where
T
:
HashStable
<
StableHashingContext
<
'gcx
>>
{
#[inline]
...
...
@@ -107,8 +107,8 @@ fn hash_stable<W: StableHasherResult>(&self,
hasher
:
&
mut
StableHasher
<
W
>
)
{
mem
::
discriminant
(
self
)
.hash_stable
(
hcx
,
hasher
);
match
*
self
{
mir
::
Clear
OnDecod
e
::
Clear
=>
{}
mir
::
Clear
OnDecod
e
::
Set
(
ref
value
)
=>
{
mir
::
Clear
CrossCrat
e
::
Clear
=>
{}
mir
::
Clear
CrossCrat
e
::
Set
(
ref
value
)
=>
{
value
.hash_stable
(
hcx
,
hasher
);
}
}
...
...
src/librustc/mir/mod.rs
浏览文件 @
8fbc91cf
...
...
@@ -75,7 +75,7 @@ pub struct Mir<'tcx> {
/// Crate-local information for each visibility scope, that can't (and
/// needn't) be tracked across crates.
pub
visibility_scope_info
:
Clear
OnDecod
e
<
IndexVec
<
VisibilityScope
,
VisibilityScopeInfo
>>
,
pub
visibility_scope_info
:
Clear
CrossCrat
e
<
IndexVec
<
VisibilityScope
,
VisibilityScopeInfo
>>
,
/// Rvalues promoted from this function, such as borrows of constants.
/// Each of them is the Mir of a constant with the fn's type parameters
...
...
@@ -129,8 +129,8 @@ pub struct Mir<'tcx> {
impl
<
'tcx
>
Mir
<
'tcx
>
{
pub
fn
new
(
basic_blocks
:
IndexVec
<
BasicBlock
,
BasicBlockData
<
'tcx
>>
,
visibility_scopes
:
IndexVec
<
VisibilityScope
,
VisibilityScopeData
>
,
visibility_scope_info
:
Clear
OnDecod
e
<
IndexVec
<
VisibilityScope
,
VisibilityScopeInfo
>>
,
visibility_scope_info
:
Clear
CrossCrat
e
<
IndexVec
<
VisibilityScope
,
VisibilityScopeInfo
>>
,
promoted
:
IndexVec
<
Promoted
,
Mir
<
'tcx
>>
,
yield_ty
:
Option
<
Ty
<
'tcx
>>
,
local_decls
:
IndexVec
<
Local
,
LocalDecl
<
'tcx
>>
,
...
...
@@ -283,7 +283,7 @@ pub fn return_ty(&self) -> Ty<'tcx> {
}
}
#[derive(Clone,
Debug)]
#[derive(Clone,
Debug
,
RustcEncodable,
RustcDecodable
)]
pub
struct
VisibilityScopeInfo
{
/// A NodeId with lint levels equivalent to this scope's lint levels.
pub
lint_root
:
ast
::
NodeId
,
...
...
@@ -291,7 +291,7 @@ pub struct VisibilityScopeInfo {
pub
safety
:
Safety
,
}
#[derive(Copy,
Clone,
Debug)]
#[derive(Copy,
Clone,
Debug
,
RustcEncodable,
RustcDecodable
)]
pub
enum
Safety
{
Safe
,
/// Unsafe because of a PushUnsafeBlock
...
...
@@ -335,22 +335,13 @@ fn index_mut(&mut self, index: BasicBlock) -> &mut BasicBlockData<'tcx> {
}
#[derive(Clone,
Debug)]
pub
enum
Clear
OnDecod
e
<
T
>
{
pub
enum
Clear
CrossCrat
e
<
T
>
{
Clear
,
Set
(
T
)
}
impl
<
T
>
serialize
::
Encodable
for
ClearOnDecode
<
T
>
{
fn
encode
<
S
:
serialize
::
Encoder
>
(
&
self
,
s
:
&
mut
S
)
->
Result
<
(),
S
::
Error
>
{
serialize
::
Encodable
::
encode
(
&
(),
s
)
}
}
impl
<
T
>
serialize
::
Decodable
for
ClearOnDecode
<
T
>
{
fn
decode
<
D
:
serialize
::
Decoder
>
(
d
:
&
mut
D
)
->
Result
<
Self
,
D
::
Error
>
{
serialize
::
Decodable
::
decode
(
d
)
.map
(|()|
ClearOnDecode
::
Clear
)
}
}
impl
<
T
:
serialize
::
Encodable
>
serialize
::
UseSpecializedEncodable
for
ClearCrossCrate
<
T
>
{}
impl
<
T
:
serialize
::
Decodable
>
serialize
::
UseSpecializedDecodable
for
ClearCrossCrate
<
T
>
{}
/// Grouped information about the source code origin of a MIR entity.
/// Intended to be inspected by diagnostics and debuginfo.
...
...
src/librustc/ty/maps/on_disk_cache.rs
浏览文件 @
8fbc91cf
...
...
@@ -15,6 +15,7 @@
RESERVED_FOR_INCR_COMP_CACHE
,
LOCAL_CRATE
};
use
hir
::
map
::
definitions
::
DefPathHash
;
use
middle
::
cstore
::
CrateStore
;
use
mir
;
use
rustc_data_structures
::
fx
::
FxHashMap
;
use
rustc_data_structures
::
indexed_vec
::{
IndexVec
,
Idx
};
use
rustc_serialize
::{
Decodable
,
Decoder
,
Encodable
,
Encoder
,
opaque
,
...
...
@@ -36,6 +37,9 @@
const
PREV_DIAGNOSTICS_TAG
:
u64
=
0x1234_5678_A1A1_A1A1
;
const
QUERY_RESULT_INDEX_TAG
:
u64
=
0x1234_5678_C3C3_C3C3
;
const
TAG_CLEAR_CROSS_CRATE_CLEAR
:
u8
=
0
;
const
TAG_CLEAR_CROSS_CRATE_SET
:
u8
=
1
;
/// `OnDiskCache` provides an interface to incr. comp. data cached from the
/// previous compilation session. This data will eventually include the results
/// of a few selected queries (like `typeck_tables_of` and `mir_optimized`) and
...
...
@@ -518,12 +522,32 @@ fn specialized_decode(&mut self) -> Result<hir::HirId, Self::Error> {
// NodeIds are not stable across compilation sessions, so we store them in their
// HirId representation. This allows use to map them to the current NodeId.
impl
<
'a
,
'tcx
,
'x
>
SpecializedDecoder
<
NodeId
>
for
CacheDecoder
<
'a
,
'tcx
,
'x
>
{
#[inline]
fn
specialized_decode
(
&
mut
self
)
->
Result
<
NodeId
,
Self
::
Error
>
{
let
hir_id
=
hir
::
HirId
::
decode
(
self
)
?
;
Ok
(
self
.tcx
()
.hir
.hir_to_node_id
(
hir_id
))
}
}
impl
<
'a
,
'tcx
,
'x
,
T
:
Decodable
>
SpecializedDecoder
<
mir
::
ClearCrossCrate
<
T
>>
for
CacheDecoder
<
'a
,
'tcx
,
'x
>
{
#[inline]
fn
specialized_decode
(
&
mut
self
)
->
Result
<
mir
::
ClearCrossCrate
<
T
>
,
Self
::
Error
>
{
let
discr
=
u8
::
decode
(
self
)
?
;
match
discr
{
TAG_CLEAR_CROSS_CRATE_CLEAR
=>
Ok
(
mir
::
ClearCrossCrate
::
Clear
),
TAG_CLEAR_CROSS_CRATE_SET
=>
{
let
val
=
T
::
decode
(
self
)
?
;
Ok
(
mir
::
ClearCrossCrate
::
Set
(
val
))
}
_
=>
{
unreachable!
()
}
}
}
}
//- ENCODING -------------------------------------------------------------------
struct
CacheEncoder
<
'enc
,
'a
,
'tcx
,
E
>
...
...
@@ -658,6 +682,27 @@ fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> {
}
}
impl
<
'enc
,
'a
,
'tcx
,
E
,
T
>
SpecializedEncoder
<
mir
::
ClearCrossCrate
<
T
>>
for
CacheEncoder
<
'enc
,
'a
,
'tcx
,
E
>
where
E
:
'enc
+
ty_codec
::
TyEncoder
,
T
:
Encodable
,
{
#[inline]
fn
specialized_encode
(
&
mut
self
,
val
:
&
mir
::
ClearCrossCrate
<
T
>
)
->
Result
<
(),
Self
::
Error
>
{
match
*
val
{
mir
::
ClearCrossCrate
::
Clear
=>
{
TAG_CLEAR_CROSS_CRATE_CLEAR
.encode
(
self
)
}
mir
::
ClearCrossCrate
::
Set
(
ref
val
)
=>
{
TAG_CLEAR_CROSS_CRATE_SET
.encode
(
self
)
?
;
val
.encode
(
self
)
}
}
}
}
macro_rules!
encoder_methods
{
(
$
(
$name:ident
(
$ty:ty
);)
*
)
=>
{
$
(
fn
$name
(
&
mut
self
,
value
:
$ty
)
->
Result
<
(),
Self
::
Error
>
{
...
...
src/librustc_metadata/decoder.rs
浏览文件 @
8fbc91cf
...
...
@@ -21,6 +21,7 @@
use
rustc
::
hir
::
def_id
::{
CrateNum
,
DefId
,
DefIndex
,
CRATE_DEF_INDEX
,
LOCAL_CRATE
};
use
rustc
::
ich
::
Fingerprint
;
use
rustc
::
middle
::
lang_items
;
use
rustc
::
mir
;
use
rustc
::
session
::
Session
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc
::
ty
::
codec
::
TyDecoder
;
...
...
@@ -327,6 +328,14 @@ fn specialized_decode(&mut self) -> Result<Span, Self::Error> {
}
}
impl
<
'a
,
'tcx
,
T
:
Decodable
>
SpecializedDecoder
<
mir
::
ClearCrossCrate
<
T
>>
for
DecodeContext
<
'a
,
'tcx
>
{
#[inline]
fn
specialized_decode
(
&
mut
self
)
->
Result
<
mir
::
ClearCrossCrate
<
T
>
,
Self
::
Error
>
{
Ok
(
mir
::
ClearCrossCrate
::
Clear
)
}
}
implement_ty_decoder!
(
DecodeContext
<
'a
,
'tcx
>
);
impl
<
'a
,
'tcx
>
MetadataBlob
{
...
...
src/librustc_metadata/encoder.rs
浏览文件 @
8fbc91cf
...
...
@@ -157,6 +157,15 @@ fn specialized_encode(&mut self,
}
}
impl
<
'a
,
'tcx
,
T
:
Encodable
>
SpecializedEncoder
<
mir
::
ClearCrossCrate
<
T
>>
for
EncodeContext
<
'a
,
'tcx
>
{
fn
specialized_encode
(
&
mut
self
,
_
:
&
mir
::
ClearCrossCrate
<
T
>
)
->
Result
<
(),
Self
::
Error
>
{
Ok
(())
}
}
impl
<
'a
,
'tcx
>
TyEncoder
for
EncodeContext
<
'a
,
'tcx
>
{
fn
position
(
&
self
)
->
usize
{
self
.opaque
.position
()
...
...
src/librustc_mir/build/mod.rs
浏览文件 @
8fbc91cf
...
...
@@ -543,7 +543,7 @@ fn finish(self,
Mir
::
new
(
self
.cfg.basic_blocks
,
self
.visibility_scopes
,
Clear
OnDecod
e
::
Set
(
self
.visibility_scope_info
),
Clear
CrossCrat
e
::
Set
(
self
.visibility_scope_info
),
IndexVec
::
new
(),
yield_ty
,
self
.local_decls
,
...
...
src/librustc_mir/shim.rs
浏览文件 @
8fbc91cf
...
...
@@ -198,7 +198,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
IndexVec
::
from_elem_n
(
VisibilityScopeData
{
span
:
span
,
parent_scope
:
None
},
1
),
Clear
OnDecod
e
::
Clear
,
Clear
CrossCrat
e
::
Clear
,
IndexVec
::
new
(),
None
,
local_decls_for_sig
(
&
sig
,
span
),
...
...
@@ -345,7 +345,7 @@ fn into_mir(self) -> Mir<'tcx> {
IndexVec
::
from_elem_n
(
VisibilityScopeData
{
span
:
self
.span
,
parent_scope
:
None
},
1
),
Clear
OnDecod
e
::
Clear
,
Clear
CrossCrat
e
::
Clear
,
IndexVec
::
new
(),
None
,
self
.local_decls
,
...
...
@@ -807,7 +807,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
IndexVec
::
from_elem_n
(
VisibilityScopeData
{
span
:
span
,
parent_scope
:
None
},
1
),
Clear
OnDecod
e
::
Clear
,
Clear
CrossCrat
e
::
Clear
,
IndexVec
::
new
(),
None
,
local_decls
,
...
...
@@ -885,7 +885,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
IndexVec
::
from_elem_n
(
VisibilityScopeData
{
span
:
span
,
parent_scope
:
None
},
1
),
Clear
OnDecod
e
::
Clear
,
Clear
CrossCrat
e
::
Clear
,
IndexVec
::
new
(),
None
,
local_decls
,
...
...
src/librustc_mir/transform/check_unsafety.rs
浏览文件 @
8fbc91cf
...
...
@@ -320,8 +320,8 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
let
mir
=
&
tcx
.mir_built
(
def_id
)
.borrow
();
let
visibility_scope_info
=
match
mir
.visibility_scope_info
{
Clear
OnDecod
e
::
Set
(
ref
data
)
=>
data
,
Clear
OnDecod
e
::
Clear
=>
{
Clear
CrossCrat
e
::
Set
(
ref
data
)
=>
data
,
Clear
CrossCrat
e
::
Clear
=>
{
debug!
(
"unsafety_violations: {:?} - remote, skipping"
,
def_id
);
return
UnsafetyCheckResult
{
violations
:
Rc
::
new
([]),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录