Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
870dd167
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,发现更多精彩内容 >>
提交
870dd167
编写于
1月 28, 2023
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use OnDrop.
上级
e33e2d6e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
39 deletion
+32
-39
compiler/rustc_query_system/src/dep_graph/graph.rs
compiler/rustc_query_system/src/dep_graph/graph.rs
+32
-39
未找到文件。
compiler/rustc_query_system/src/dep_graph/graph.rs
浏览文件 @
870dd167
...
...
@@ -6,6 +6,7 @@
use
rustc_data_structures
::
stable_hasher
::{
HashStable
,
StableHasher
};
use
rustc_data_structures
::
steal
::
Steal
;
use
rustc_data_structures
::
sync
::{
AtomicU32
,
AtomicU64
,
Lock
,
Lrc
,
Ordering
};
use
rustc_data_structures
::
OnDrop
;
use
rustc_index
::
vec
::
IndexVec
;
use
rustc_serialize
::
opaque
::{
FileEncodeResult
,
FileEncoder
};
use
smallvec
::{
smallvec
,
SmallVec
};
...
...
@@ -676,49 +677,19 @@ pub fn try_mark_green<Qcx: QueryContext<DepKind = K>>(
None
=>
{}
}
let
mut
stack
=
smallvec!
[
prev_index
];
let
_
backtrace_print
=
MarkingStack
{
stack
:
&
mut
stack
,
sess
:
qcx
.dep_context
()
.sess
(),
graph
:
data
};
let
backtrace
=
backtrace_printer
(
qcx
.dep_context
()
.sess
(),
data
,
prev_index
);
// This DepNode and the corresponding query invocation existed
// in the previous compilation session too, so we can try to
// mark it as green by recursively marking all of its
// dependencies green.
let
ret
=
self
.try_mark_previous_green
(
qcx
,
data
,
prev_index
,
&
dep_node
,
_
backtrace_print
.stack
)
.try_mark_previous_green
(
qcx
,
data
,
prev_index
,
&
dep_node
)
.map
(|
dep_node_index
|
(
prev_index
,
dep_node_index
));
// We succeeded, no backtrace.
std
::
mem
::
forget
(
_
backtrace_print
);
backtrace
.disable
(
);
return
ret
;
/// Remember the stack of queries we are forcing in the event of an incr. comp. panic.
struct
MarkingStack
<
'a
,
'v
,
K
:
DepKind
>
{
stack
:
&
'v
mut
SmallVec
<
[
SerializedDepNodeIndex
;
8
]
>
,
sess
:
&
'a
rustc_session
::
Session
,
graph
:
&
'a
DepGraphData
<
K
>
,
}
impl
<
'a
,
'v
,
K
:
DepKind
>
Drop
for
MarkingStack
<
'a
,
'v
,
K
>
{
/// Print the forcing backtrace.
#[inline(never)]
#[cold]
fn
drop
(
&
mut
self
)
{
for
&
frame
in
self
.stack
.iter
()
.rev
()
{
let
node
=
self
.graph.previous
.index_to_node
(
frame
);
// Do not try to rely on DepNode's Debug implementation,
// since it may panic.
let
diag
=
rustc_errors
::
Diagnostic
::
new
(
rustc_errors
::
Level
::
FailureNote
,
&
format!
(
"encountered while trying to mark dependency green: {:?}({})"
,
node
.kind
,
node
.hash
),
);
self
.sess
.diagnostic
()
.force_print_diagnostic
(
diag
);
}
}
}
}
#[instrument(skip(self,
qcx,
data,
parent_dep_node_index),
level
=
"debug"
)]
...
...
@@ -728,7 +699,6 @@ fn try_mark_parent_green<Qcx: QueryContext<DepKind = K>>(
data
:
&
DepGraphData
<
K
>
,
parent_dep_node_index
:
SerializedDepNodeIndex
,
dep_node
:
&
DepNode
<
K
>
,
stack
:
&
mut
SmallVec
<
[
SerializedDepNodeIndex
;
8
]
>
,
)
->
Option
<
()
>
{
let
dep_dep_node_color
=
data
.colors
.get
(
parent_dep_node_index
);
let
dep_dep_node
=
&
data
.previous
.index_to_node
(
parent_dep_node_index
);
...
...
@@ -761,7 +731,7 @@ fn try_mark_parent_green<Qcx: QueryContext<DepKind = K>>(
);
let
node_index
=
self
.try_mark_previous_green
(
qcx
,
data
,
parent_dep_node_index
,
dep_dep_node
,
stack
);
self
.try_mark_previous_green
(
qcx
,
data
,
parent_dep_node_index
,
dep_dep_node
);
if
node_index
.is_some
()
{
debug!
(
"managed to MARK dependency {dep_dep_node:?} as green"
,);
...
...
@@ -817,7 +787,6 @@ fn try_mark_previous_green<Qcx: QueryContext<DepKind = K>>(
data
:
&
DepGraphData
<
K
>
,
prev_dep_node_index
:
SerializedDepNodeIndex
,
dep_node
:
&
DepNode
<
K
>
,
stack
:
&
mut
SmallVec
<
[
SerializedDepNodeIndex
;
8
]
>
,
)
->
Option
<
DepNodeIndex
>
{
#[cfg(not(parallel_compiler))]
{
...
...
@@ -833,9 +802,10 @@ fn try_mark_previous_green<Qcx: QueryContext<DepKind = K>>(
let
prev_deps
=
data
.previous
.edge_targets_from
(
prev_dep_node_index
);
for
&
dep_dep_node_index
in
prev_deps
{
stack
.push
(
dep_dep_node_index
);
self
.try_mark_parent_green
(
qcx
,
data
,
dep_dep_node_index
,
dep_node
,
stack
)
?
;
stack
.pop
();
let
backtrace
=
backtrace_printer
(
qcx
.dep_context
()
.sess
(),
data
,
dep_dep_node_index
);
let
success
=
self
.try_mark_parent_green
(
qcx
,
data
,
dep_dep_node_index
,
dep_node
);
backtrace
.disable
();
success
?
;
}
// If we got here without hitting a `return` that means that all
...
...
@@ -1405,3 +1375,26 @@ fn insert(&self, index: SerializedDepNodeIndex, color: DepNodeColor) {
)
}
}
fn
backtrace_printer
<
'a
,
K
:
DepKind
>
(
sess
:
&
'a
rustc_session
::
Session
,
graph
:
&
'a
DepGraphData
<
K
>
,
node
:
SerializedDepNodeIndex
,
)
->
OnDrop
<
impl
Fn
()
+
'a
>
{
OnDrop
(
#[inline(never)]
#[cold]
move
||
{
let
node
=
graph
.previous
.index_to_node
(
node
);
// Do not try to rely on DepNode's Debug implementation, since it may panic.
let
diag
=
rustc_errors
::
Diagnostic
::
new
(
rustc_errors
::
Level
::
FailureNote
,
&
format!
(
"encountered while trying to mark dependency green: {:?}({})"
,
node
.kind
,
node
.hash
),
);
sess
.diagnostic
()
.force_print_diagnostic
(
diag
);
},
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录