Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
aa404c24
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,发现更多精彩内容 >>
提交
aa404c24
编写于
10月 16, 2021
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make hash_result an Option.
上级
e53404cc
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
39 addition
and
41 deletion
+39
-41
compiler/rustc_codegen_cranelift/src/driver/aot.rs
compiler/rustc_codegen_cranelift/src/driver/aot.rs
+1
-1
compiler/rustc_codegen_gcc/src/base.rs
compiler/rustc_codegen_gcc/src/base.rs
+7
-1
compiler/rustc_codegen_llvm/src/base.rs
compiler/rustc_codegen_llvm/src/base.rs
+7
-2
compiler/rustc_query_impl/src/plumbing.rs
compiler/rustc_query_impl/src/plumbing.rs
+6
-12
compiler/rustc_query_system/src/dep_graph/graph.rs
compiler/rustc_query_system/src/dep_graph/graph.rs
+8
-7
compiler/rustc_query_system/src/query/config.rs
compiler/rustc_query_system/src/query/config.rs
+5
-13
compiler/rustc_query_system/src/query/plumbing.rs
compiler/rustc_query_system/src/query/plumbing.rs
+5
-5
未找到文件。
compiler/rustc_codegen_cranelift/src/driver/aot.rs
浏览文件 @
aa404c24
...
...
@@ -224,7 +224,7 @@ pub(crate) fn run_aot(
tcx
,
(
backend_config
.clone
(),
cgu
.name
()),
module_codegen
,
rustc_middle
::
dep_graph
::
hash_result
,
Some
(
rustc_middle
::
dep_graph
::
hash_result
)
,
);
if
let
Some
((
id
,
product
))
=
work_product
{
...
...
compiler/rustc_codegen_gcc/src/base.rs
浏览文件 @
aa404c24
...
...
@@ -59,7 +59,13 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol) -> (Modul
let
start_time
=
Instant
::
now
();
let
dep_node
=
tcx
.codegen_unit
(
cgu_name
)
.codegen_dep_node
(
tcx
);
let
(
module
,
_
)
=
tcx
.dep_graph
.with_task
(
dep_node
,
tcx
,
cgu_name
,
module_codegen
,
dep_graph
::
hash_result
);
let
(
module
,
_
)
=
tcx
.dep_graph
.with_task
(
dep_node
,
tcx
,
cgu_name
,
module_codegen
,
Some
(
dep_graph
::
hash_result
),
);
let
time_to_codegen
=
start_time
.elapsed
();
drop
(
prof_timer
);
...
...
compiler/rustc_codegen_llvm/src/base.rs
浏览文件 @
aa404c24
...
...
@@ -113,8 +113,13 @@ pub fn compile_codegen_unit(
let
start_time
=
Instant
::
now
();
let
dep_node
=
tcx
.codegen_unit
(
cgu_name
)
.codegen_dep_node
(
tcx
);
let
(
module
,
_
)
=
tcx
.dep_graph
.with_task
(
dep_node
,
tcx
,
cgu_name
,
module_codegen
,
dep_graph
::
hash_result
);
let
(
module
,
_
)
=
tcx
.dep_graph
.with_task
(
dep_node
,
tcx
,
cgu_name
,
module_codegen
,
Some
(
dep_graph
::
hash_result
),
);
let
time_to_codegen
=
start_time
.elapsed
();
// We assume that the cost to run LLVM on a CGU is proportional to
...
...
compiler/rustc_query_impl/src/plumbing.rs
浏览文件 @
aa404c24
...
...
@@ -291,14 +291,14 @@ pub struct QueryStruct {
}
macro_rules!
hash_result
{
([]
[
$hcx:expr
,
$result:expr
]
)
=>
{{
dep_graph
::
hash_result
(
$hcx
,
&
$
result
)
([])
=>
{{
Some
(
dep_graph
::
hash_
result
)
}};
([(
no_hash
)
$
(
$rest:tt
)
*
]
[
$hcx:expr
,
$result:expr
]
)
=>
{{
([(
no_hash
)
$
(
$rest:tt
)
*
])
=>
{{
None
}};
([
$other:tt
$
(
$modifiers:tt
)
*
]
[
$
(
$args:tt
)
*
]
)
=>
{
hash_result!
([
$
(
$modifiers
)
*
]
[
$
(
$args
)
*
]
)
([
$other:tt
$
(
$modifiers:tt
)
*
])
=>
{
hash_result!
([
$
(
$modifiers
)
*
])
};
}
...
...
@@ -378,6 +378,7 @@ impl<$tcx> QueryAccessors<QueryCtxt<$tcx>> for queries::$name<$tcx> {
const
ANON
:
bool
=
is_anon!
([
$
(
$modifiers
)
*
]);
const
EVAL_ALWAYS
:
bool
=
is_eval_always!
([
$
(
$modifiers
)
*
]);
const
DEP_KIND
:
dep_graph
::
DepKind
=
dep_graph
::
DepKind
::
$name
;
const
HASH_RESULT
:
Option
<
fn
(
&
mut
StableHashingContext
<
'_
>
,
&
Self
::
Value
)
->
Fingerprint
>
=
hash_result!
([
$
(
$modifiers
)
*
]);
type
Cache
=
query_storage
::
$name
<
$tcx
>
;
...
...
@@ -406,13 +407,6 @@ fn compute_fn(tcx: QueryCtxt<'tcx>, key: &Self::Key) ->
}
}
fn
hash_result
(
_
hcx
:
&
mut
StableHashingContext
<
'_
>
,
_
result
:
&
Self
::
Value
)
->
Option
<
Fingerprint
>
{
hash_result!
([
$
(
$modifiers
)
*
][
_
hcx
,
_
result
])
}
fn
handle_cycle_error
(
tcx
:
QueryCtxt
<
'tcx
>
,
mut
error
:
DiagnosticBuilder
<
'_
>
,
...
...
compiler/rustc_query_system/src/dep_graph/graph.rs
浏览文件 @
aa404c24
...
...
@@ -96,14 +96,13 @@ struct DepGraphData<K: DepKind> {
dep_node_debug
:
Lock
<
FxHashMap
<
DepNode
<
K
>
,
String
>>
,
}
pub
fn
hash_result
<
R
>
(
hcx
:
&
mut
StableHashingContext
<
'_
>
,
result
:
&
R
)
->
Option
<
Fingerprint
>
pub
fn
hash_result
<
R
>
(
hcx
:
&
mut
StableHashingContext
<
'_
>
,
result
:
&
R
)
->
Fingerprint
where
R
:
for
<
'a
>
HashStable
<
StableHashingContext
<
'a
>>
,
{
let
mut
stable_hasher
=
StableHasher
::
new
();
result
.hash_stable
(
hcx
,
&
mut
stable_hasher
);
Some
(
stable_hasher
.finish
())
stable_hasher
.finish
()
}
impl
<
K
:
DepKind
>
DepGraph
<
K
>
{
...
...
@@ -215,7 +214,7 @@ pub fn with_task<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
cx
:
Ctxt
,
arg
:
A
,
task
:
fn
(
Ctxt
,
A
)
->
R
,
hash_result
:
fn
(
&
mut
StableHashingContext
<
'_
>
,
&
R
)
->
Option
<
Fingerprint
>
,
hash_result
:
Option
<
fn
(
&
mut
StableHashingContext
<
'_
>
,
&
R
)
->
Fingerprint
>
,
)
->
(
R
,
DepNodeIndex
)
{
if
self
.is_fully_enabled
()
{
self
.with_task_impl
(
key
,
cx
,
arg
,
task
,
hash_result
)
...
...
@@ -234,7 +233,7 @@ fn with_task_impl<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
cx
:
Ctxt
,
arg
:
A
,
task
:
fn
(
Ctxt
,
A
)
->
R
,
hash_result
:
fn
(
&
mut
StableHashingContext
<
'_
>
,
&
R
)
->
Option
<
Fingerprint
>
,
hash_result
:
Option
<
fn
(
&
mut
StableHashingContext
<
'_
>
,
&
R
)
->
Fingerprint
>
,
)
->
(
R
,
DepNodeIndex
)
{
// This function is only called when the graph is enabled.
let
data
=
self
.data
.as_ref
()
.unwrap
();
...
...
@@ -268,9 +267,11 @@ fn with_task_impl<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
let
edges
=
task_deps
.map_or_else
(||
smallvec!
[],
|
lock
|
lock
.into_inner
()
.reads
);
let
dcx
=
cx
.dep_context
();
let
mut
hcx
=
dcx
.create_stable_hashing_context
();
let
hashing_timer
=
dcx
.profiler
()
.incr_result_hashing
();
let
current_fingerprint
=
hash_result
(
&
mut
hcx
,
&
result
);
let
current_fingerprint
=
hash_result
.map
(|
f
|
{
let
mut
hcx
=
dcx
.create_stable_hashing_context
();
f
(
&
mut
hcx
,
&
result
)
});
let
print_status
=
cfg!
(
debug_assertions
)
&&
dcx
.sess
()
.opts.debugging_opts.dep_tasks
;
...
...
compiler/rustc_query_system/src/query/config.rs
浏览文件 @
aa404c24
...
...
@@ -24,7 +24,7 @@ pub(crate) struct QueryVtable<CTX: QueryContext, K, V> {
pub
dep_kind
:
CTX
::
DepKind
,
pub
eval_always
:
bool
,
pub
hash_result
:
fn
(
&
mut
StableHashingContext
<
'_
>
,
&
V
)
->
Option
<
Fingerprint
>
,
pub
hash_result
:
Option
<
fn
(
&
mut
StableHashingContext
<
'_
>
,
&
V
)
->
Fingerprint
>
,
pub
handle_cycle_error
:
fn
(
CTX
,
DiagnosticBuilder
<
'_
>
)
->
V
,
pub
cache_on_disk
:
fn
(
CTX
,
&
K
,
Option
<&
V
>
)
->
bool
,
pub
try_load_from_disk
:
fn
(
CTX
,
SerializedDepNodeIndex
)
->
Option
<
V
>
,
...
...
@@ -38,14 +38,6 @@ pub(crate) fn to_dep_node(&self, tcx: CTX::DepContext, key: &K) -> DepNode<CTX::
DepNode
::
construct
(
tcx
,
self
.dep_kind
,
key
)
}
pub
(
crate
)
fn
hash_result
(
&
self
,
hcx
:
&
mut
StableHashingContext
<
'_
>
,
value
:
&
V
,
)
->
Option
<
Fingerprint
>
{
(
self
.hash_result
)(
hcx
,
value
)
}
pub
(
crate
)
fn
cache_on_disk
(
&
self
,
tcx
:
CTX
,
key
:
&
K
,
value
:
Option
<&
V
>
)
->
bool
{
(
self
.cache_on_disk
)(
tcx
,
key
,
value
)
}
...
...
@@ -59,6 +51,9 @@ pub trait QueryAccessors<CTX: QueryContext>: QueryConfig {
const
ANON
:
bool
;
const
EVAL_ALWAYS
:
bool
;
const
DEP_KIND
:
CTX
::
DepKind
;
const
HASH_RESULT
:
Option
<
fn
(
hcx
:
&
mut
StableHashingContext
<
'_
>
,
result
:
&
Self
::
Value
)
->
Fingerprint
,
>
;
type
Cache
:
QueryCache
<
Key
=
Self
::
Key
,
Stored
=
Self
::
Stored
,
Value
=
Self
::
Value
>
;
...
...
@@ -75,9 +70,6 @@ fn query_cache<'a>(tcx: CTX) -> &'a QueryCacheStore<Self::Cache>
// Don't use this method to compute query results, instead use the methods on TyCtxt
fn
compute_fn
(
tcx
:
CTX
,
key
:
&
Self
::
Key
)
->
fn
(
CTX
::
DepContext
,
Self
::
Key
)
->
Self
::
Value
;
fn
hash_result
(
hcx
:
&
mut
StableHashingContext
<
'_
>
,
result
:
&
Self
::
Value
)
->
Option
<
Fingerprint
>
;
fn
handle_cycle_error
(
tcx
:
CTX
,
diag
:
DiagnosticBuilder
<
'_
>
)
->
Self
::
Value
;
}
...
...
@@ -107,7 +99,7 @@ impl<CTX, Q> QueryVtableExt<CTX, Q::Key, Q::Value> for Q
anon
:
Q
::
ANON
,
dep_kind
:
Q
::
DEP_KIND
,
eval_always
:
Q
::
EVAL_ALWAYS
,
hash_result
:
Q
::
hash_result
,
hash_result
:
Q
::
HASH_RESULT
,
handle_cycle_error
:
Q
::
handle_cycle_error
,
cache_on_disk
:
Q
::
cache_on_disk
,
try_load_from_disk
:
Q
::
try_load_from_disk
,
...
...
compiler/rustc_query_system/src/query/plumbing.rs
浏览文件 @
aa404c24
...
...
@@ -577,12 +577,12 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
);
debug!
(
"BEGIN verify_ich({:?})"
,
dep_node
);
let
mut
hcx
=
tcx
.create_stable_hashing_context
();
let
new_hash
=
query
.hash_result
(
&
mut
hcx
,
result
)
.unwrap_or
(
Fingerprint
::
ZERO
);
debug!
(
"END verify_ich({:?})"
,
dep_node
);
let
new_hash
=
query
.hash_result
.map_or
(
Fingerprint
::
ZERO
,
|
f
|
{
let
mut
hcx
=
tcx
.create_stable_hashing_context
();
f
(
&
mut
hcx
,
result
)
});
let
old_hash
=
tcx
.dep_graph
()
.prev_fingerprint_of
(
dep_node
);
debug!
(
"END verify_ich({:?})"
,
dep_node
);
if
Some
(
new_hash
)
!=
old_hash
{
let
run_cmd
=
if
let
Some
(
crate_name
)
=
&
tcx
.sess
()
.opts.crate_name
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录