Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3f802ee8
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
3f802ee8
编写于
4月 25, 2018
作者:
J
John Kåre Alsaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move the Lock into OpenTask
上级
8ec629b3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
57 deletion
+52
-57
src/librustc/dep_graph/graph.rs
src/librustc/dep_graph/graph.rs
+49
-54
src/librustc/ty/context.rs
src/librustc/ty/context.rs
+3
-3
未找到文件。
src/librustc/dep_graph/graph.rs
浏览文件 @
3f802ee8
...
...
@@ -145,7 +145,7 @@ pub fn assert_ignored(&self)
if
let
Some
(
..
)
=
self
.data
{
ty
::
tls
::
with_context_opt
(|
icx
|
{
let
icx
=
if
let
Some
(
icx
)
=
icx
{
icx
}
else
{
return
};
match
*
icx
.task
.lock
()
{
match
*
icx
.task
{
OpenTask
::
Ignore
=>
{
// ignored
}
...
...
@@ -160,7 +160,7 @@ pub fn with_ignore<OP,R>(&self, op: OP) -> R
{
ty
::
tls
::
with_context
(|
icx
|
{
let
icx
=
ty
::
tls
::
ImplicitCtxt
{
task
:
&
Lock
::
new
(
OpenTask
::
Ignore
)
,
task
:
&
OpenTask
::
Ignore
,
..
icx
.clone
()
};
...
...
@@ -207,11 +207,11 @@ pub fn with_task<'gcx, C, A, R>(&self,
R
:
HashStable
<
StableHashingContext
<
'gcx
>>
,
{
self
.with_task_impl
(
key
,
cx
,
arg
,
false
,
task
,
|
key
|
OpenTask
::
Regular
{
|
key
|
OpenTask
::
Regular
(
Lock
::
new
(
RegularOpenTask
{
node
:
key
,
reads
:
Vec
::
new
(),
read_set
:
FxHashSet
(),
},
}
))
,
|
data
,
key
,
task
|
data
.borrow_mut
()
.complete_task
(
key
,
task
))
}
...
...
@@ -263,24 +263,18 @@ fn with_task_impl<'gcx, C, A, R>(
profq_msg
(
hcx
.sess
(),
ProfileQueriesMsg
::
TaskBegin
(
key
.clone
()))
};
let
(
result
,
open_task
)
=
if
no_tcx
{
(
task
(
cx
,
arg
),
open_task
)
let
result
=
if
no_tcx
{
task
(
cx
,
arg
)
}
else
{
ty
::
tls
::
with_context
(|
icx
|
{
let
open_task
=
Lock
::
new
(
open_task
);
let
r
=
{
let
icx
=
ty
::
tls
::
ImplicitCtxt
{
task
:
&
open_task
,
..
icx
.clone
()
};
ty
::
tls
::
enter_context
(
&
icx
,
|
_
|
{
task
(
cx
,
arg
)
})
let
icx
=
ty
::
tls
::
ImplicitCtxt
{
task
:
&
open_task
,
..
icx
.clone
()
};
(
r
,
open_task
.into_inner
())
ty
::
tls
::
enter_context
(
&
icx
,
|
_
|
{
task
(
cx
,
arg
)
})
})
};
...
...
@@ -358,10 +352,10 @@ pub fn with_anon_task<OP,R>(&self, dep_kind: DepKind, op: OP) -> (R, DepNodeInde
{
if
let
Some
(
ref
data
)
=
self
.data
{
let
(
result
,
open_task
)
=
ty
::
tls
::
with_context
(|
icx
|
{
let
task
=
Lock
::
new
(
OpenTask
::
Anon
{
let
task
=
OpenTask
::
Anon
(
Lock
::
new
(
AnonOpenTask
{
reads
:
Vec
::
new
(),
read_set
:
FxHashSet
(),
});
})
)
;
let
r
=
{
let
icx
=
ty
::
tls
::
ImplicitCtxt
{
...
...
@@ -374,7 +368,7 @@ pub fn with_anon_task<OP,R>(&self, dep_kind: DepKind, op: OP) -> (R, DepNodeInde
})
};
(
r
,
task
.into_inner
()
)
(
r
,
task
)
});
let
dep_node_index
=
data
.current
.borrow_mut
()
...
...
@@ -986,11 +980,12 @@ fn new() -> CurrentDepGraph {
}
fn
complete_task
(
&
mut
self
,
key
:
DepNode
,
task
:
OpenTask
)
->
DepNodeIndex
{
if
let
OpenTask
::
Regular
{
node
,
read_set
:
_
,
reads
}
=
task
{
if
let
OpenTask
::
Regular
(
task
)
=
task
{
let
RegularOpenTask
{
node
,
read_set
:
_
,
reads
}
=
task
.into_inner
();
assert_eq!
(
node
,
key
);
// If this is an input node, we expect that it either has no
...
...
@@ -1022,10 +1017,11 @@ fn complete_task(&mut self, key: DepNode, task: OpenTask) -> DepNodeIndex {
}
fn
pop_anon_task
(
&
mut
self
,
kind
:
DepKind
,
task
:
OpenTask
)
->
DepNodeIndex
{
if
let
OpenTask
::
Anon
{
read_set
:
_
,
reads
}
=
task
{
if
let
OpenTask
::
Anon
(
task
)
=
task
{
let
AnonOpenTask
{
read_set
:
_
,
reads
}
=
task
.into_inner
();
debug_assert!
(
!
kind
.is_input
());
let
mut
fingerprint
=
self
.anon_id_seed
;
...
...
@@ -1074,18 +1070,16 @@ fn complete_eval_always_task(&mut self, key: DepNode, task: OpenTask) -> DepNode
fn
read_index
(
&
mut
self
,
source
:
DepNodeIndex
)
{
ty
::
tls
::
with_context_opt
(|
icx
|
{
let
icx
=
if
let
Some
(
icx
)
=
icx
{
icx
}
else
{
return
};
match
*
icx
.task
.lock
()
{
OpenTask
::
Regular
{
ref
mut
reads
,
ref
mut
read_set
,
node
:
ref
target
,
}
=>
{
match
*
icx
.task
{
OpenTask
::
Regular
(
ref
task
)
=>
{
let
mut
task
=
task
.lock
();
self
.total_read_count
+=
1
;
if
read_set
.insert
(
source
)
{
reads
.push
(
source
);
if
task
.
read_set
.insert
(
source
)
{
task
.
reads
.push
(
source
);
if
cfg!
(
debug_assertions
)
{
if
let
Some
(
ref
forbidden_edge
)
=
self
.forbidden_edge
{
let
target
=
&
task
.node
;
let
source
=
self
.nodes
[
source
];
if
forbidden_edge
.test
(
&
source
,
&
target
)
{
bug!
(
"forbidden edge {:?} -> {:?} created"
,
...
...
@@ -1098,12 +1092,10 @@ fn read_index(&mut self, source: DepNodeIndex) {
self
.total_duplicate_read_count
+=
1
;
}
}
OpenTask
::
Anon
{
ref
mut
reads
,
ref
mut
read_set
,
}
=>
{
if
read_set
.insert
(
source
)
{
reads
.push
(
source
);
OpenTask
::
Anon
(
ref
task
)
=>
{
let
mut
task
=
task
.lock
();
if
task
.read_set
.insert
(
source
)
{
task
.reads
.push
(
source
);
}
}
OpenTask
::
Ignore
|
OpenTask
::
EvalAlways
{
..
}
=>
{
...
...
@@ -1128,17 +1120,20 @@ fn alloc_node(&mut self,
}
}
#[derive(Clone,
Debug,
PartialEq)]
pub
struct
RegularOpenTask
{
node
:
DepNode
,
reads
:
Vec
<
DepNodeIndex
>
,
read_set
:
FxHashSet
<
DepNodeIndex
>
,
}
pub
struct
AnonOpenTask
{
reads
:
Vec
<
DepNodeIndex
>
,
read_set
:
FxHashSet
<
DepNodeIndex
>
,
}
pub
enum
OpenTask
{
Regular
{
node
:
DepNode
,
reads
:
Vec
<
DepNodeIndex
>
,
read_set
:
FxHashSet
<
DepNodeIndex
>
,
},
Anon
{
reads
:
Vec
<
DepNodeIndex
>
,
read_set
:
FxHashSet
<
DepNodeIndex
>
,
},
Regular
(
Lock
<
RegularOpenTask
>
),
Anon
(
Lock
<
AnonOpenTask
>
),
Ignore
,
EvalAlways
{
node
:
DepNode
,
...
...
src/librustc/ty/context.rs
浏览文件 @
3f802ee8
...
...
@@ -1741,7 +1741,7 @@ pub mod tls {
use
ty
::
maps
;
use
errors
::{
Diagnostic
,
TRACK_DIAGNOSTICS
};
use
rustc_data_structures
::
OnDrop
;
use
rustc_data_structures
::
sync
::
{
Lrc
,
Lock
}
;
use
rustc_data_structures
::
sync
::
Lrc
;
use
dep_graph
::
OpenTask
;
/// This is the implicit state of rustc. It contains the current
...
...
@@ -1764,7 +1764,7 @@ pub struct ImplicitCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
/// The current dep graph task. This is used to add dependencies to queries
/// when executing them
pub
task
:
&
'a
Lock
<
OpenTask
>
,
pub
task
:
&
'a
OpenTask
,
}
// A thread local value which stores a pointer to the current ImplicitCtxt
...
...
@@ -1851,7 +1851,7 @@ pub fn enter_global<'gcx, F, R>(gcx: &GlobalCtxt<'gcx>, f: F) -> R
tcx
,
query
:
None
,
layout_depth
:
0
,
task
:
&
Lock
::
new
(
OpenTask
::
Ignore
)
,
task
:
&
OpenTask
::
Ignore
,
};
enter_context
(
&
icx
,
|
_
|
{
f
(
tcx
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录