Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8f3e96d6
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,发现更多精彩内容 >>
提交
8f3e96d6
编写于
3月 28, 2020
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Monomorphise try_execute_query.
上级
1c7376e7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
43 deletion
+38
-43
src/librustc_query_system/query/config.rs
src/librustc_query_system/query/config.rs
+6
-0
src/librustc_query_system/query/plumbing.rs
src/librustc_query_system/query/plumbing.rs
+32
-43
未找到文件。
src/librustc_query_system/query/config.rs
浏览文件 @
8f3e96d6
...
...
@@ -28,6 +28,7 @@ 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
,
...
...
@@ -39,6 +40,10 @@ 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
compute
(
&
self
,
tcx
:
CTX
,
key
:
K
)
->
V
{
(
self
.compute
)(
tcx
,
key
)
}
...
...
@@ -112,6 +117,7 @@ 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
浏览文件 @
8f3e96d6
...
...
@@ -382,17 +382,21 @@ fn try_get_cached<CTX, C, R, OnHit, OnMiss>(
}
#[inline(always)]
fn
try_execute_query
<
Q
,
CTX
>
(
fn
try_execute_query
<
CTX
,
C
>
(
tcx
:
CTX
,
state
:
&
QueryState
<
CTX
,
C
>
,
span
:
Span
,
key
:
Q
::
Key
,
lookup
:
QueryLookup
<
'_
,
CTX
,
Q
::
Key
,
<
Q
::
Cache
as
QueryCache
>
::
Sharded
>
,
)
->
Q
::
Stored
key
:
C
::
Key
,
lookup
:
QueryLookup
<
'_
,
CTX
,
C
::
Key
,
C
::
Sharded
>
,
query
:
&
QueryVtable
<
CTX
,
C
::
Key
,
C
::
Value
>
,
)
->
C
::
Stored
where
Q
:
QueryDescription
<
CTX
>
,
C
:
QueryCache
,
C
::
Key
:
Eq
+
Clone
+
Debug
,
C
::
Stored
:
Clone
,
CTX
:
QueryContext
,
{
let
job
=
match
JobOwner
::
try_start
(
tcx
,
Q
::
query_state
(
tcx
),
span
,
&
key
,
lookup
,
&
Q
::
VTABLE
)
{
let
job
=
match
JobOwner
::
try_start
(
tcx
,
state
,
span
,
&
key
,
lookup
,
query
)
{
TryGetJob
::
NotYetStarted
(
job
)
=>
job
,
TryGetJob
::
Cycle
(
result
)
=>
return
result
,
#[cfg(parallel_compiler)]
...
...
@@ -406,18 +410,32 @@ fn try_execute_query<Q, CTX>(
// expensive for some `DepKind`s.
if
!
tcx
.dep_graph
()
.is_fully_enabled
()
{
let
null_dep_node
=
DepNode
::
new_no_params
(
DepKind
::
NULL
);
return
force_query_with_job
(
tcx
,
key
,
job
,
null_dep_node
,
&
Q
::
VTABLE
)
.0
;
return
force_query_with_job
(
tcx
,
key
,
job
,
null_dep_node
,
query
)
.0
;
}
if
Q
::
ANON
{
let
(
result
,
dep_node_index
)
=
try_execute_anon_query
(
tcx
,
key
,
job
.id
,
&
Q
::
VTABLE
);
if
query
.anon
{
let
prof_timer
=
tcx
.profiler
()
.query_provider
();
let
((
result
,
dep_node_index
),
diagnostics
)
=
with_diagnostics
(|
diagnostics
|
{
tcx
.start_query
(
job
.id
,
diagnostics
,
|
tcx
|
{
tcx
.dep_graph
()
.with_anon_task
(
query
.dep_kind
,
||
query
.compute
(
tcx
,
key
))
})
});
prof_timer
.finish_with_query_invocation_id
(
dep_node_index
.into
());
tcx
.dep_graph
()
.read_index
(
dep_node_index
);
if
unlikely!
(
!
diagnostics
.is_empty
())
{
tcx
.store_diagnostics_for_anon_node
(
dep_node_index
,
diagnostics
);
}
return
job
.complete
(
tcx
,
result
,
dep_node_index
);
}
let
dep_node
=
Q
::
to_dep_node
(
tcx
,
&
key
);
let
dep_node
=
query
.
to_dep_node
(
tcx
,
&
key
);
if
!
Q
::
EVAL_ALWAYS
{
if
!
query
.eval_always
{
// The diagnostics for this query will be
// promoted to the current session during
// `try_mark_green()`, so we can ignore them here.
...
...
@@ -431,7 +449,7 @@ fn try_execute_query<Q, CTX>(
prev_dep_node_index
,
dep_node_index
,
&
dep_node
,
&
Q
::
VTABLE
,
query
,
),
dep_node_index
,
)
...
...
@@ -442,40 +460,11 @@ fn try_execute_query<Q, CTX>(
}
}
let
(
result
,
dep_node_index
)
=
force_query_with_job
(
tcx
,
key
,
job
,
dep_node
,
&
Q
::
VTABLE
);
let
(
result
,
dep_node_index
)
=
force_query_with_job
(
tcx
,
key
,
job
,
dep_node
,
query
);
tcx
.dep_graph
()
.read_index
(
dep_node_index
);
result
}
fn
try_execute_anon_query
<
CTX
,
K
,
V
>
(
tcx
:
CTX
,
key
:
K
,
job_id
:
QueryJobId
<
CTX
::
DepKind
>
,
query
:
&
QueryVtable
<
CTX
,
K
,
V
>
,
)
->
(
V
,
DepNodeIndex
)
where
CTX
:
QueryContext
,
{
debug_assert!
(
query
.anon
);
let
prof_timer
=
tcx
.profiler
()
.query_provider
();
let
((
result
,
dep_node_index
),
diagnostics
)
=
with_diagnostics
(|
diagnostics
|
{
tcx
.start_query
(
job_id
,
diagnostics
,
|
tcx
|
{
tcx
.dep_graph
()
.with_anon_task
(
query
.dep_kind
,
||
query
.compute
(
tcx
,
key
))
})
});
prof_timer
.finish_with_query_invocation_id
(
dep_node_index
.into
());
tcx
.dep_graph
()
.read_index
(
dep_node_index
);
if
unlikely!
(
!
diagnostics
.is_empty
())
{
tcx
.store_diagnostics_for_anon_node
(
dep_node_index
,
diagnostics
);
}
(
result
,
dep_node_index
)
}
fn
load_from_disk_and_cache_in_memory
<
CTX
,
K
,
V
>
(
tcx
:
CTX
,
key
:
K
,
...
...
@@ -639,7 +628,7 @@ pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key) -> Q::Stored
tcx
.dep_graph
()
.read_index
(
index
);
value
.clone
()
},
|
key
,
lookup
|
try_execute_query
::
<
Q
,
_
>
(
tcx
,
span
,
key
,
lookup
),
|
key
,
lookup
|
try_execute_query
(
tcx
,
Q
::
query_state
(
tcx
),
span
,
key
,
lookup
,
&
Q
::
VTABLE
),
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录