Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6d387463
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,发现更多精彩内容 >>
提交
6d387463
编写于
5月 31, 2019
作者:
J
John Kåre Alsaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove GlobalArenas and use Arena instead
上级
3ade426e
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
33 addition
and
61 deletion
+33
-61
src/librustc/arena.rs
src/librustc/arena.rs
+8
-0
src/librustc/query/mod.rs
src/librustc/query/mod.rs
+3
-3
src/librustc/ty/context.rs
src/librustc/ty/context.rs
+10
-46
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+1
-1
src/librustc_metadata/cstore_impl.rs
src/librustc_metadata/cstore_impl.rs
+3
-3
src/librustc_mir/shim.rs
src/librustc_mir/shim.rs
+1
-1
src/librustc_mir/transform/mod.rs
src/librustc_mir/transform/mod.rs
+1
-1
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/check/writeback.rs
+1
-1
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+2
-2
src/libsyntax/attr/builtin.rs
src/libsyntax/attr/builtin.rs
+3
-3
未找到文件。
src/librustc/arena.rs
浏览文件 @
6d387463
...
...
@@ -19,6 +19,14 @@
macro_rules!
arena_types
{
(
$macro:path
,
$args:tt
,
$tcx:lifetime
)
=>
(
$macro
!
(
$args
,
[
[]
layouts
:
rustc
::
ty
::
layout
::
LayoutDetails
,
[]
generics
:
rustc
::
ty
::
Generics
,
[]
trait_def
:
rustc
::
ty
::
TraitDef
,
[]
adt_def
:
rustc
::
ty
::
AdtDef
,
[]
steal_mir
:
rustc
::
ty
::
steal
::
Steal
<
rustc
::
mir
::
Body
<
$tcx
>>
,
[]
mir
:
rustc
::
mir
::
Body
<
$tcx
>
,
[]
tables
:
rustc
::
ty
::
TypeckTables
<
$tcx
>
,
[]
const_allocs
:
rustc
::
mir
::
interpret
::
Allocation
,
[]
vtable_method
:
Option
<
(
rustc
::
hir
::
def_id
::
DefId
,
rustc
::
ty
::
subst
::
SubstsRef
<
$tcx
>
...
...
src/librustc/query/mod.rs
浏览文件 @
6d387463
...
...
@@ -42,7 +42,7 @@
load_cached
(
tcx
,
id
)
{
let
generics
:
Option
<
ty
::
Generics
>
=
tcx
.queries.on_disk_cache
.try_load_query_result
(
tcx
,
id
);
generics
.map
(|
x
|
tcx
.alloc_generics
(
x
))
generics
.map
(|
x
|
&*
tcx
.arena
.alloc
(
x
))
}
}
...
...
@@ -118,7 +118,7 @@
load_cached
(
tcx
,
id
)
{
let
mir
:
Option
<
crate
::
mir
::
Body
<
'tcx
>>
=
tcx
.queries.on_disk_cache
.try_load_query_result
(
tcx
,
id
);
mir
.map
(|
x
|
tcx
.alloc_mir
(
x
))
mir
.map
(|
x
|
&*
tcx
.arena
.alloc
(
x
))
}
}
}
...
...
@@ -353,7 +353,7 @@
.queries.on_disk_cache
.try_load_query_result
(
tcx
,
id
);
typeck_tables
.map
(|
tables
|
tcx
.alloc_tables
(
tables
))
typeck_tables
.map
(|
tables
|
&*
tcx
.arena
.alloc
(
tables
))
}
}
}
...
...
src/librustc/ty/context.rs
浏览文件 @
6d387463
...
...
@@ -53,7 +53,7 @@
use
rustc_data_structures
::
stable_hasher
::{
HashStable
,
hash_stable_hashmap
,
StableHasher
,
StableHasherResult
,
StableVec
};
use
arena
::
{
TypedArena
,
SyncDroplessArena
}
;
use
arena
::
SyncDroplessArena
;
use
rustc_data_structures
::
indexed_vec
::{
Idx
,
IndexVec
};
use
rustc_data_structures
::
sync
::{
Lrc
,
Lock
,
WorkerLocal
};
use
std
::
any
::
Any
;
...
...
@@ -79,37 +79,18 @@
use
crate
::
hir
;
pub
struct
AllArenas
<
'tcx
>
{
pub
global
:
WorkerLocal
<
GlobalArenas
<
'tcx
>>
,
pub
struct
AllArenas
{
pub
interner
:
SyncDroplessArena
,
}
impl
<
'tcx
>
AllArenas
<
'tcx
>
{
impl
AllArenas
{
pub
fn
new
()
->
Self
{
AllArenas
{
global
:
WorkerLocal
::
new
(|
_
|
GlobalArenas
::
default
()),
interner
:
SyncDroplessArena
::
default
(),
}
}
}
/// Internal storage
#[derive(Default)]
pub
struct
GlobalArenas
<
'tcx
>
{
// internings
layout
:
TypedArena
<
LayoutDetails
>
,
// references
generics
:
TypedArena
<
ty
::
Generics
>
,
trait_def
:
TypedArena
<
ty
::
TraitDef
>
,
adt_def
:
TypedArena
<
ty
::
AdtDef
>
,
steal_mir
:
TypedArena
<
Steal
<
Body
<
'tcx
>>>
,
mir
:
TypedArena
<
Body
<
'tcx
>>
,
tables
:
TypedArena
<
ty
::
TypeckTables
<
'tcx
>>
,
/// miri allocations
const_allocs
:
TypedArena
<
interpret
::
Allocation
>
,
}
type
InternedSet
<
'tcx
,
T
>
=
Lock
<
FxHashMap
<
Interned
<
'tcx
,
T
>
,
()
>>
;
pub
struct
CtxtInterners
<
'tcx
>
{
...
...
@@ -1043,7 +1024,7 @@ fn deref(&self) -> &Self::Target {
pub
struct
GlobalCtxt
<
'tcx
>
{
pub
arena
:
WorkerLocal
<
Arena
<
'tcx
>>
,
global_arenas
:
&
'tcx
WorkerLocal
<
GlobalArenas
<
'tcx
>>
,
global_interners
:
CtxtInterners
<
'tcx
>
,
cstore
:
&
'tcx
CrateStoreDyn
,
...
...
@@ -1150,24 +1131,8 @@ pub fn hir(self) -> &'a hir_map::Map<'gcx> {
&
self
.hir_map
}
pub
fn
alloc_generics
(
self
,
generics
:
ty
::
Generics
)
->
&
'gcx
ty
::
Generics
{
self
.global_arenas.generics
.alloc
(
generics
)
}
pub
fn
alloc_steal_mir
(
self
,
mir
:
Body
<
'gcx
>
)
->
&
'gcx
Steal
<
Body
<
'gcx
>>
{
self
.global_arenas.steal_mir
.alloc
(
Steal
::
new
(
mir
))
}
pub
fn
alloc_mir
(
self
,
mir
:
Body
<
'gcx
>
)
->
&
'gcx
Body
<
'gcx
>
{
self
.global_arenas.mir
.alloc
(
mir
)
}
pub
fn
alloc_tables
(
self
,
tables
:
ty
::
TypeckTables
<
'gcx
>
)
->
&
'gcx
ty
::
TypeckTables
<
'gcx
>
{
self
.global_arenas.tables
.alloc
(
tables
)
}
pub
fn
alloc_trait_def
(
self
,
def
:
ty
::
TraitDef
)
->
&
'gcx
ty
::
TraitDef
{
self
.global_arenas.trait_def
.alloc
(
def
)
self
.arena
.alloc
(
Steal
::
new
(
mir
))
}
pub
fn
alloc_adt_def
(
self
,
...
...
@@ -1177,12 +1142,12 @@ pub fn alloc_adt_def(self,
repr
:
ReprOptions
)
->
&
'gcx
ty
::
AdtDef
{
let
def
=
ty
::
AdtDef
::
new
(
self
,
did
,
kind
,
variants
,
repr
);
self
.
global_arenas.adt_def
.alloc
(
def
)
self
.
arena
.alloc
(
def
)
}
pub
fn
intern_const_alloc
(
self
,
alloc
:
Allocation
)
->
&
'gcx
Allocation
{
self
.allocation_interner
.borrow_mut
()
.intern
(
alloc
,
|
alloc
|
{
self
.
global_arenas.const_allocs
.alloc
(
alloc
)
self
.
arena
.alloc
(
alloc
)
})
}
...
...
@@ -1196,13 +1161,13 @@ pub fn allocate_bytes(self, bytes: &[u8]) -> interpret::AllocId {
pub
fn
intern_stability
(
self
,
stab
:
attr
::
Stability
)
->
&
'gcx
attr
::
Stability
{
self
.stability_interner
.borrow_mut
()
.intern
(
stab
,
|
stab
|
{
self
.
global_interners.
arena
.alloc
(
stab
)
self
.arena
.alloc
(
stab
)
})
}
pub
fn
intern_layout
(
self
,
layout
:
LayoutDetails
)
->
&
'gcx
LayoutDetails
{
self
.layout_interner
.borrow_mut
()
.intern
(
layout
,
|
layout
|
{
self
.
global_arenas.layout
.alloc
(
layout
)
self
.
arena
.alloc
(
layout
)
})
}
...
...
@@ -1250,7 +1215,7 @@ pub fn create_global_ctxt(
cstore
:
&
'tcx
CrateStoreDyn
,
local_providers
:
ty
::
query
::
Providers
<
'tcx
>
,
extern_providers
:
ty
::
query
::
Providers
<
'tcx
>
,
arenas
:
&
'tcx
AllArenas
<
'tcx
>
,
arenas
:
&
'tcx
AllArenas
,
resolutions
:
ty
::
Resolutions
,
hir
:
hir_map
::
Map
<
'tcx
>
,
on_disk_query_result_cache
:
query
::
OnDiskCache
<
'tcx
>
,
...
...
@@ -1319,7 +1284,6 @@ pub fn create_global_ctxt(
sess
:
s
,
cstore
,
arena
:
WorkerLocal
::
new
(|
_
|
Arena
::
default
()),
global_arenas
:
&
arenas
.global
,
global_interners
:
interners
,
dep_graph
,
common
,
...
...
src/librustc/ty/mod.rs
浏览文件 @
6d387463
...
...
@@ -75,7 +75,7 @@
pub
use
self
::
binding
::
BindingMode
;
pub
use
self
::
binding
::
BindingMode
::
*
;
pub
use
self
::
context
::{
TyCtxt
,
FreeRegionInfo
,
GlobalArenas
,
AllArenas
,
tls
,
keep_local
};
pub
use
self
::
context
::{
TyCtxt
,
FreeRegionInfo
,
AllArenas
,
tls
,
keep_local
};
pub
use
self
::
context
::{
Lift
,
TypeckTables
,
CtxtInterners
,
GlobalCtxt
};
pub
use
self
::
context
::{
UserTypeAnnotationIndex
,
UserType
,
CanonicalUserType
,
...
...
src/librustc_metadata/cstore_impl.rs
浏览文件 @
6d387463
...
...
@@ -94,7 +94,7 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) }
provide!
{
<
'tcx
>
tcx
,
def_id
,
other
,
cdata
,
type_of
=>
{
cdata
.get_type
(
def_id
.index
,
tcx
)
}
generics_of
=>
{
tcx
.a
lloc_generics
(
cdata
.get_generics
(
def_id
.index
,
tcx
.sess
))
tcx
.a
rena
.alloc
(
cdata
.get_generics
(
def_id
.index
,
tcx
.sess
))
}
predicates_of
=>
{
tcx
.arena
.alloc
(
cdata
.get_predicates
(
def_id
.index
,
tcx
))
}
predicates_defined_on
=>
{
...
...
@@ -102,7 +102,7 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) }
}
super_predicates_of
=>
{
tcx
.arena
.alloc
(
cdata
.get_super_predicates
(
def_id
.index
,
tcx
))
}
trait_def
=>
{
tcx
.a
lloc_trait_def
(
cdata
.get_trait_def
(
def_id
.index
,
tcx
.sess
))
tcx
.a
rena
.alloc
(
cdata
.get_trait_def
(
def_id
.index
,
tcx
.sess
))
}
adt_def
=>
{
cdata
.get_adt_def
(
def_id
.index
,
tcx
)
}
adt_destructor
=>
{
...
...
@@ -129,7 +129,7 @@ fn into_args(self) -> (DefId, DefId) { (self.0.as_def_id(), self.1) }
bug!
(
"get_optimized_mir: missing MIR for `{:?}`"
,
def_id
)
});
let
mir
=
tcx
.a
lloc_mir
(
mir
);
let
mir
=
tcx
.a
rena
.alloc
(
mir
);
mir
}
...
...
src/librustc_mir/shim.rs
浏览文件 @
6d387463
...
...
@@ -125,7 +125,7 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
debug!
(
"make_shim({:?}) = {:?}"
,
instance
,
result
);
tcx
.a
lloc_mir
(
result
)
tcx
.a
rena
.alloc
(
result
)
}
#[derive(Copy,
Clone,
Debug,
PartialEq)]
...
...
src/librustc_mir/transform/mod.rs
浏览文件 @
6d387463
...
...
@@ -290,5 +290,5 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
&
add_call_guards
::
CriticalCallEdges
,
&
dump_mir
::
Marker
(
"PreCodegen"
),
]);
tcx
.a
lloc_mir
(
mir
)
tcx
.a
rena
.alloc
(
mir
)
}
src/librustc_typeck/check/writeback.rs
浏览文件 @
6d387463
...
...
@@ -81,7 +81,7 @@ pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) -> &'gcx ty::Type
item_def_id
,
wbcx
.tables
);
self
.tcx
.a
lloc_tables
(
wbcx
.tables
)
self
.tcx.a
rena
.alloc
(
wbcx
.tables
)
}
}
...
...
src/librustc_typeck/collect.rs
浏览文件 @
6d387463
...
...
@@ -763,7 +763,7 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::
let
is_marker
=
tcx
.has_attr
(
def_id
,
sym
::
marker
);
let
def_path_hash
=
tcx
.def_path_hash
(
def_id
);
let
def
=
ty
::
TraitDef
::
new
(
def_id
,
unsafety
,
paren_sugar
,
is_auto
,
is_marker
,
def_path_hash
);
tcx
.a
lloc_trait_def
(
def
)
tcx
.a
rena
.alloc
(
def
)
}
fn
has_late_bound_regions
<
'a
,
'tcx
>
(
...
...
@@ -1110,7 +1110,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
.map
(|
param
|
(
param
.def_id
,
param
.index
))
.collect
();
tcx
.a
lloc_generics
(
ty
::
Generics
{
tcx
.a
rena
.alloc
(
ty
::
Generics
{
parent
:
parent_def_id
,
parent_count
,
params
,
...
...
src/libsyntax/attr/builtin.rs
浏览文件 @
6d387463
...
...
@@ -111,7 +111,7 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op
}
/// Represents the #[stable], #[unstable], #[rustc_{deprecated,const_unstable}] attributes.
#[derive(RustcEncodable,
RustcDecodable,
Clone,
Debug,
PartialEq,
Eq,
Hash)]
#[derive(RustcEncodable,
RustcDecodable,
C
opy,
C
lone,
Debug,
PartialEq,
Eq,
Hash)]
pub
struct
Stability
{
pub
level
:
StabilityLevel
,
pub
feature
:
Symbol
,
...
...
@@ -127,7 +127,7 @@ pub struct Stability {
}
/// The available stability levels.
#[derive(RustcEncodable,
RustcDecodable,
PartialEq,
PartialOrd,
Clone,
Debug,
Eq,
Hash)]
#[derive(RustcEncodable,
RustcDecodable,
PartialEq,
PartialOrd,
C
opy,
C
lone,
Debug,
Eq,
Hash)]
pub
enum
StabilityLevel
{
// Reason for the current stability level and the relevant rust-lang issue
Unstable
{
reason
:
Option
<
Symbol
>
,
issue
:
u32
},
...
...
@@ -151,7 +151,7 @@ pub fn is_stable(&self) -> bool {
}
}
#[derive(RustcEncodable,
RustcDecodable,
PartialEq,
PartialOrd,
Clone,
Debug,
Eq,
Hash)]
#[derive(RustcEncodable,
RustcDecodable,
PartialEq,
PartialOrd,
C
opy,
C
lone,
Debug,
Eq,
Hash)]
pub
struct
RustcDeprecation
{
pub
since
:
Symbol
,
pub
reason
:
Symbol
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录