Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5b5499d5
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
5b5499d5
编写于
6月 12, 2017
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
incr.comp.: Make DepNode's std::fmt::Debug implementation useful again.
上级
3f8b9369
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
150 addition
and
4 deletion
+150
-4
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/dep_node.rs
+120
-4
src/librustc/dep_graph/graph.rs
src/librustc/dep_graph/graph.rs
+19
-0
src/librustc/ich/fingerprint.rs
src/librustc/ich/fingerprint.rs
+11
-0
未找到文件。
src/librustc/dep_graph/dep_node.rs
浏览文件 @
5b5499d5
...
...
@@ -67,6 +67,7 @@
use
ty
::
TyCtxt
;
use
rustc_data_structures
::
stable_hasher
::{
StableHasher
,
HashStable
};
use
ich
::
StableHashingContext
;
use
std
::
fmt
;
use
std
::
hash
::
Hash
;
// erase!() just makes tokens go away. It's used to specify which macro argument
...
...
@@ -145,7 +146,7 @@ pub enum DepConstructor {
),
*
}
#[derive(Clone,
Copy,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
#[derive(Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
RustcEncodable,
RustcDecodable)]
pub
struct
DepNode
{
pub
kind
:
DepKind
,
...
...
@@ -166,10 +167,22 @@ pub fn new(tcx: TyCtxt, dep: DepConstructor) -> DepNode {
let
tupled_args
=
(
$
(
$tuple_arg
,)
*
);
let
hash
=
DepNodeParams
::
to_fingerprint
(
&
tupled_args
,
tcx
);
return
DepNode
{
let
dep_node
=
DepNode
{
kind
:
DepKind
::
$variant
,
hash
};
if
cfg!
(
debug_assertions
)
&&
!
dep_node
.kind
.can_reconstruct_query_key
()
&&
(
tcx
.sess.opts.debugging_opts.incremental_info
||
tcx
.sess.opts.debugging_opts.query_dep_graph
)
{
tcx
.dep_graph
.register_dep_node_debug_str
(
dep_node
,
||
{
tupled_args
.to_debug_str
(
tcx
)
});
}
return
dep_node
;
})
*
// struct args
...
...
@@ -177,10 +190,22 @@ pub fn new(tcx: TyCtxt, dep: DepConstructor) -> DepNode {
let
tupled_args
=
(
$
(
$struct_arg_name
,)
*
);
let
hash
=
DepNodeParams
::
to_fingerprint
(
&
tupled_args
,
tcx
);
return
DepNode
{
let
dep_node
=
DepNode
{
kind
:
DepKind
::
$variant
,
hash
};
if
cfg!
(
debug_assertions
)
&&
!
dep_node
.kind
.can_reconstruct_query_key
()
&&
(
tcx
.sess.opts.debugging_opts.incremental_info
||
tcx
.sess.opts.debugging_opts.query_dep_graph
)
{
tcx
.dep_graph
.register_dep_node_debug_str
(
dep_node
,
||
{
tupled_args
.to_debug_str
(
tcx
)
});
}
return
dep_node
;
})
*
DepNode
{
...
...
@@ -267,6 +292,36 @@ pub fn from_label_string(label: &str,
);
}
impl
fmt
::
Debug
for
DepNode
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
write!
(
f
,
"{:?}"
,
self
.kind
)
?
;
if
!
self
.kind
.has_params
()
{
return
Ok
(());
}
write!
(
f
,
"("
)
?
;
::
ty
::
tls
::
with_opt
(|
opt_tcx
|
{
if
let
Some
(
tcx
)
=
opt_tcx
{
if
let
Some
(
def_id
)
=
self
.extract_def_id
(
tcx
)
{
write!
(
f
,
"{}"
,
tcx
.item_path_str
(
def_id
))
?
;
}
else
if
let
Some
(
ref
s
)
=
tcx
.dep_graph
.dep_node_debug_str
(
*
self
)
{
write!
(
f
,
"{}"
,
s
)
?
;
}
else
{
write!
(
f
,
"{:?}"
,
self
.hash
)
?
;
}
}
else
{
write!
(
f
,
"{:?}"
,
self
.hash
)
?
;
}
Ok
(())
})
?
;
write!
(
f
,
")"
)
}
}
impl
DefPathHash
{
#[inline]
pub
fn
to_dep_node
(
self
,
kind
:
DepKind
)
->
DepNode
{
...
...
@@ -434,10 +489,11 @@ pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
trait
DepNodeParams
<
'a
,
'gcx
:
'tcx
+
'a
,
'tcx
:
'a
>
{
const
CAN_RECONSTRUCT_QUERY_KEY
:
bool
;
fn
to_fingerprint
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
)
->
Fingerprint
;
fn
to_debug_str
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
)
->
String
;
}
impl
<
'a
,
'gcx
:
'tcx
+
'a
,
'tcx
:
'a
,
T
>
DepNodeParams
<
'a
,
'gcx
,
'tcx
>
for
T
where
T
:
HashStable
<
StableHashingContext
<
'a
,
'gcx
,
'tcx
>>
where
T
:
HashStable
<
StableHashingContext
<
'a
,
'gcx
,
'tcx
>>
+
fmt
::
Debug
{
default
const
CAN_RECONSTRUCT_QUERY_KEY
:
bool
=
false
;
...
...
@@ -449,6 +505,10 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a, T> DepNodeParams<'a, 'gcx, 'tcx> for T
hasher
.finish
()
}
default
fn
to_debug_str
(
&
self
,
_
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
)
->
String
{
format!
(
"{:?}"
,
*
self
)
}
}
impl
<
'a
,
'gcx
:
'tcx
+
'a
,
'tcx
:
'a
>
DepNodeParams
<
'a
,
'gcx
,
'tcx
>
for
(
DefId
,)
{
...
...
@@ -457,6 +517,62 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId,) {
fn
to_fingerprint
(
&
self
,
tcx
:
TyCtxt
)
->
Fingerprint
{
tcx
.def_path_hash
(
self
.0
)
.0
}
fn
to_debug_str
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
)
->
String
{
tcx
.item_path_str
(
self
.0
)
}
}
impl
<
'a
,
'gcx
:
'tcx
+
'a
,
'tcx
:
'a
>
DepNodeParams
<
'a
,
'gcx
,
'tcx
>
for
(
DefId
,
DefId
)
{
const
CAN_RECONSTRUCT_QUERY_KEY
:
bool
=
false
;
fn
to_fingerprint
(
&
self
,
tcx
:
TyCtxt
)
->
Fingerprint
{
let
(
def_id_0
,
def_id_1
)
=
*
self
;
let
def_path_hash_0
=
tcx
.def_path_hash
(
def_id_0
);
let
def_path_hash_1
=
tcx
.def_path_hash
(
def_id_1
);
def_path_hash_0
.0
.combine
(
def_path_hash_1
.0
)
}
fn
to_debug_str
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
)
->
String
{
let
(
def_id_0
,
def_id_1
)
=
*
self
;
format!
(
"({}, {})"
,
tcx
.def_path
(
def_id_0
)
.to_string
(
tcx
),
tcx
.def_path
(
def_id_1
)
.to_string
(
tcx
))
}
}
impl
<
'a
,
'gcx
:
'tcx
+
'a
,
'tcx
:
'a
>
DepNodeParams
<
'a
,
'gcx
,
'tcx
>
for
(
DefIdList
,)
{
const
CAN_RECONSTRUCT_QUERY_KEY
:
bool
=
false
;
fn
to_fingerprint
(
&
self
,
tcx
:
TyCtxt
)
->
Fingerprint
{
let
mut
fingerprint
=
Fingerprint
::
zero
();
for
&
def_id
in
self
.0
.iter
()
{
let
def_path_hash
=
tcx
.def_path_hash
(
def_id
);
fingerprint
=
fingerprint
.combine
(
def_path_hash
.0
);
}
fingerprint
}
fn
to_debug_str
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
)
->
String
{
use
std
::
fmt
::
Write
;
let
mut
s
=
String
::
new
();
write!
(
&
mut
s
,
"["
)
.unwrap
();
for
&
def_id
in
self
.0
.iter
()
{
write!
(
&
mut
s
,
"{}"
,
tcx
.def_path
(
def_id
)
.to_string
(
tcx
))
.unwrap
();
}
write!
(
&
mut
s
,
"]"
)
.unwrap
();
s
}
}
/// A "work product" corresponds to a `.o` (or other) file that we
...
...
src/librustc/dep_graph/graph.rs
浏览文件 @
5b5499d5
...
...
@@ -37,6 +37,8 @@ struct DepGraphData {
/// Work-products that we generate in this run.
work_products
:
RefCell
<
FxHashMap
<
WorkProductId
,
WorkProduct
>>
,
dep_node_debug
:
RefCell
<
FxHashMap
<
DepNode
,
String
>>
,
}
impl
DepGraph
{
...
...
@@ -46,6 +48,7 @@ pub fn new(enabled: bool) -> DepGraph {
thread
:
DepGraphThreadData
::
new
(
enabled
),
previous_work_products
:
RefCell
::
new
(
FxHashMap
()),
work_products
:
RefCell
::
new
(
FxHashMap
()),
dep_node_debug
:
RefCell
::
new
(
FxHashMap
()),
})
}
}
...
...
@@ -152,6 +155,22 @@ pub fn work_products(&self) -> Ref<FxHashMap<WorkProductId, WorkProduct>> {
pub
fn
previous_work_products
(
&
self
)
->
Ref
<
FxHashMap
<
WorkProductId
,
WorkProduct
>>
{
self
.data.previous_work_products
.borrow
()
}
#[inline(always)]
pub
(
super
)
fn
register_dep_node_debug_str
<
F
>
(
&
self
,
dep_node
:
DepNode
,
debug_str_gen
:
F
)
where
F
:
FnOnce
()
->
String
{
let
mut
dep_node_debug
=
self
.data.dep_node_debug
.borrow_mut
();
dep_node_debug
.entry
(
dep_node
)
.or_insert_with
(
debug_str_gen
);
}
pub
(
super
)
fn
dep_node_debug_str
(
&
self
,
dep_node
:
DepNode
)
->
Option
<
String
>
{
self
.data.dep_node_debug
.borrow
()
.get
(
&
dep_node
)
.cloned
()
}
}
/// A "work product" is an intermediate result that we save into the
...
...
src/librustc/ich/fingerprint.rs
浏览文件 @
5b5499d5
...
...
@@ -31,9 +31,20 @@ pub fn to_smaller_hash(&self) -> u64 {
self
.0
}
#[inline]
pub
fn
combine
(
self
,
other
:
Fingerprint
)
->
Fingerprint
{
// See https://stackoverflow.com/a/27952689 on why this function is
// implemented this way.
Fingerprint
(
self
.0
.wrapping_mul
(
3
)
.wrapping_add
(
other
.0
),
self
.1
.wrapping_mul
(
3
)
.wrapping_add
(
other
.1
)
)
}
pub
fn
to_hex
(
&
self
)
->
String
{
format!
(
"{:x}{:x}"
,
self
.0
,
self
.1
)
}
}
impl
::
std
::
fmt
::
Display
for
Fingerprint
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录