Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e15383cc
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,发现更多精彩内容 >>
提交
e15383cc
编写于
3月 28, 2020
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move the DepNode construction to librustc_query_system.
上级
8f3e96d6
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
46 addition
and
36 deletion
+46
-36
src/librustc_middle/dep_graph/dep_node.rs
src/librustc_middle/dep_graph/dep_node.rs
+2
-23
src/librustc_middle/dep_graph/mod.rs
src/librustc_middle/dep_graph/mod.rs
+4
-0
src/librustc_middle/ty/query/mod.rs
src/librustc_middle/ty/query/mod.rs
+1
-1
src/librustc_middle/ty/query/plumbing.rs
src/librustc_middle/ty/query/plumbing.rs
+0
-6
src/librustc_query_system/dep_graph/dep_node.rs
src/librustc_query_system/dep_graph/dep_node.rs
+24
-0
src/librustc_query_system/dep_graph/mod.rs
src/librustc_query_system/dep_graph/mod.rs
+1
-0
src/librustc_query_system/query/config.rs
src/librustc_query_system/query/config.rs
+11
-5
src/librustc_query_system/query/plumbing.rs
src/librustc_query_system/query/plumbing.rs
+3
-1
未找到文件。
src/librustc_middle/dep_graph/dep_node.rs
浏览文件 @
e15383cc
...
...
@@ -183,31 +183,10 @@ pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
// tuple args
$
({
erase!
(
$tuple_arg_ty
);
let
hash
=
DepNodeParams
::
to_fingerprint
(
&
arg
,
_
tcx
);
let
dep_node
=
DepNode
{
kind
:
DepKind
::
$variant
,
hash
};
#[cfg(debug_assertions)]
{
if
!
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
,
||
{
arg
.to_debug_str
(
_
tcx
)
});
}
}
return
dep_node
;
return
DepNode
::
construct
(
_
tcx
,
DepKind
::
$variant
,
&
arg
)
})
*
DepNode
{
kind
:
DepKind
::
$variant
,
hash
:
Fingerprint
::
ZERO
,
}
return
DepNode
::
construct
(
_
tcx
,
DepKind
::
$variant
,
&
())
}
)
*
}
...
...
src/librustc_middle/dep_graph/mod.rs
浏览文件 @
e15383cc
...
...
@@ -98,6 +98,10 @@ fn create_stable_hashing_context(&self) -> Self::StableHashingContext {
fn
debug_dep_tasks
(
&
self
)
->
bool
{
self
.sess.opts.debugging_opts.dep_tasks
}
fn
debug_dep_node
(
&
self
)
->
bool
{
self
.sess.opts.debugging_opts.incremental_info
||
self
.sess.opts.debugging_opts.query_dep_graph
}
fn
try_force_from_dep_node
(
&
self
,
dep_node
:
&
DepNode
)
->
bool
{
// FIXME: This match is just a workaround for incremental bugs and should
...
...
src/librustc_middle/ty/query/mod.rs
浏览文件 @
e15383cc
use
crate
::
dep_graph
::{
self
,
Dep
Constructor
,
Dep
Node
,
DepNodeParams
};
use
crate
::
dep_graph
::{
self
,
DepNode
,
DepNodeParams
};
use
crate
::
hir
::
exports
::
Export
;
use
crate
::
hir
::
map
;
use
crate
::
infer
::
canonical
::{
self
,
Canonical
};
...
...
src/librustc_middle/ty/query/plumbing.rs
浏览文件 @
e15383cc
...
...
@@ -348,12 +348,6 @@ fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState<TyCtxt<$tcx>, Self::Cach
&
tcx
.queries
.
$name
}
#[allow(unused)]
#[inline(always)]
fn
to_dep_node
(
tcx
:
TyCtxt
<
$tcx
>
,
key
:
&
Self
::
Key
)
->
DepNode
{
DepConstructor
::
$node
(
tcx
,
*
key
)
}
#[inline]
fn
compute
(
tcx
:
TyCtxt
<
'tcx
>
,
key
:
Self
::
Key
)
->
Self
::
Value
{
let
provider
=
tcx
.queries.providers
.get
(
key
.query_crate
())
...
...
src/librustc_query_system/dep_graph/dep_node.rs
浏览文件 @
e15383cc
...
...
@@ -64,6 +64,24 @@ pub fn new_no_params(kind: K) -> DepNode<K> {
debug_assert!
(
!
kind
.has_params
());
DepNode
{
kind
,
hash
:
Fingerprint
::
ZERO
}
}
pub
fn
construct
<
Ctxt
,
Key
>
(
tcx
:
Ctxt
,
kind
:
K
,
arg
:
&
Key
)
->
DepNode
<
K
>
where
Ctxt
:
crate
::
query
::
QueryContext
<
DepKind
=
K
>
,
Key
:
DepNodeParams
<
Ctxt
>
,
{
let
hash
=
arg
.to_fingerprint
(
tcx
);
let
dep_node
=
DepNode
{
kind
,
hash
};
#[cfg(debug_assertions)]
{
if
!
kind
.can_reconstruct_query_key
()
&&
tcx
.debug_dep_node
()
{
tcx
.dep_graph
()
.register_dep_node_debug_str
(
dep_node
,
||
arg
.to_debug_str
(
tcx
));
}
}
return
dep_node
;
}
}
impl
<
K
:
DepKind
>
fmt
::
Debug
for
DepNode
<
K
>
{
...
...
@@ -120,6 +138,12 @@ impl<Ctxt: DepContext, T> DepNodeParams<Ctxt> for T
}
}
impl
<
Ctxt
:
DepContext
>
DepNodeParams
<
Ctxt
>
for
()
{
fn
to_fingerprint
(
&
self
,
_
:
Ctxt
)
->
Fingerprint
{
Fingerprint
::
ZERO
}
}
/// A "work product" corresponds to a `.o` (or other) file that we
/// save in between runs. These IDs do not have a `DefId` but rather
/// some independent path or string that persists between runs without
...
...
src/librustc_query_system/dep_graph/mod.rs
浏览文件 @
e15383cc
...
...
@@ -28,6 +28,7 @@ pub trait DepContext: Copy {
fn
create_stable_hashing_context
(
&
self
)
->
Self
::
StableHashingContext
;
fn
debug_dep_tasks
(
&
self
)
->
bool
;
fn
debug_dep_node
(
&
self
)
->
bool
;
/// Try to force a dep node to execute and see if it's green.
fn
try_force_from_dep_node
(
&
self
,
dep_node
:
&
DepNode
<
Self
::
DepKind
>
)
->
bool
;
...
...
src/librustc_query_system/query/config.rs
浏览文件 @
e15383cc
...
...
@@ -28,7 +28,6 @@ pub(crate) struct QueryVtable<CTX: QueryContext, K, V> {
pub
anon
:
bool
,
pub
dep_kind
:
CTX
::
DepKind
,
pub
eval_always
:
bool
,
pub
to_dep_node
:
fn
(
CTX
,
&
K
)
->
DepNode
<
CTX
::
DepKind
>
,
// Don't use this method to compute query results, instead use the methods on TyCtxt
pub
compute
:
fn
(
CTX
,
K
)
->
V
,
...
...
@@ -40,8 +39,11 @@ pub(crate) struct QueryVtable<CTX: QueryContext, K, V> {
}
impl
<
CTX
:
QueryContext
,
K
,
V
>
QueryVtable
<
CTX
,
K
,
V
>
{
pub
(
crate
)
fn
to_dep_node
(
&
self
,
tcx
:
CTX
,
key
:
&
K
)
->
DepNode
<
CTX
::
DepKind
>
{
(
self
.to_dep_node
)(
tcx
,
key
)
pub
(
crate
)
fn
to_dep_node
(
&
self
,
tcx
:
CTX
,
key
:
&
K
)
->
DepNode
<
CTX
::
DepKind
>
where
K
:
crate
::
dep_graph
::
DepNodeParams
<
CTX
>
,
{
DepNode
::
construct
(
tcx
,
self
.dep_kind
,
key
)
}
pub
(
crate
)
fn
compute
(
&
self
,
tcx
:
CTX
,
key
:
K
)
->
V
{
...
...
@@ -79,7 +81,12 @@ pub trait QueryAccessors<CTX: QueryContext>: QueryConfig<CTX> {
// Don't use this method to access query results, instead use the methods on TyCtxt
fn
query_state
<
'a
>
(
tcx
:
CTX
)
->
&
'a
QueryState
<
CTX
,
Self
::
Cache
>
;
fn
to_dep_node
(
tcx
:
CTX
,
key
:
&
Self
::
Key
)
->
DepNode
<
CTX
::
DepKind
>
;
fn
to_dep_node
(
tcx
:
CTX
,
key
:
&
Self
::
Key
)
->
DepNode
<
CTX
::
DepKind
>
where
Self
::
Key
:
crate
::
dep_graph
::
DepNodeParams
<
CTX
>
,
{
DepNode
::
construct
(
tcx
,
Self
::
DEP_KIND
,
key
)
}
// Don't use this method to compute query results, instead use the methods on TyCtxt
fn
compute
(
tcx
:
CTX
,
key
:
Self
::
Key
)
->
Self
::
Value
;
...
...
@@ -117,7 +124,6 @@ impl<CTX, Q> QueryVtableExt<CTX, Q::Key, Q::Value> for Q
const
VTABLE
:
QueryVtable
<
CTX
,
Q
::
Key
,
Q
::
Value
>
=
QueryVtable
{
anon
:
Q
::
ANON
,
dep_kind
:
Q
::
DEP_KIND
,
to_dep_node
:
Q
::
to_dep_node
,
eval_always
:
Q
::
EVAL_ALWAYS
,
compute
:
Q
::
compute
,
hash_result
:
Q
::
hash_result
,
...
...
src/librustc_query_system/query/plumbing.rs
浏览文件 @
e15383cc
...
...
@@ -392,7 +392,7 @@ fn try_execute_query<CTX, C>(
)
->
C
::
Stored
where
C
:
QueryCache
,
C
::
Key
:
Eq
+
Clone
+
Debug
,
C
::
Key
:
Eq
+
Clone
+
Debug
+
crate
::
dep_graph
::
DepNodeParams
<
CTX
>
,
C
::
Stored
:
Clone
,
CTX
:
QueryContext
,
{
...
...
@@ -616,6 +616,7 @@ fn force_query_with_job<C, CTX>(
pub
fn
get_query
<
Q
,
CTX
>
(
tcx
:
CTX
,
span
:
Span
,
key
:
Q
::
Key
)
->
Q
::
Stored
where
Q
:
QueryDescription
<
CTX
>
,
Q
::
Key
:
crate
::
dep_graph
::
DepNodeParams
<
CTX
>
,
CTX
:
QueryContext
,
{
debug!
(
"ty::query::get_query<{}>(key={:?}, span={:?})"
,
Q
::
NAME
,
key
,
span
);
...
...
@@ -642,6 +643,7 @@ pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key) -> Q::Stored
pub
fn
ensure_query
<
Q
,
CTX
>
(
tcx
:
CTX
,
key
:
Q
::
Key
)
where
Q
:
QueryDescription
<
CTX
>
,
Q
::
Key
:
crate
::
dep_graph
::
DepNodeParams
<
CTX
>
,
CTX
:
QueryContext
,
{
if
Q
::
EVAL_ALWAYS
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录