Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
645841ea
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,发现更多精彩内容 >>
提交
645841ea
编写于
7月 25, 2017
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
async-llvm(8): Clean up resource management and drop LLVM modules ASAP.
上级
4282dd87
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
256 addition
and
151 deletion
+256
-151
src/librustc_driver/driver.rs
src/librustc_driver/driver.rs
+0
-2
src/librustc_trans/back/write.rs
src/librustc_trans/back/write.rs
+180
-135
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+19
-8
src/librustc_trans/lib.rs
src/librustc_trans/lib.rs
+57
-6
未找到文件。
src/librustc_driver/driver.rs
浏览文件 @
645841ea
...
...
@@ -237,8 +237,6 @@ pub fn compile_input(sess: &Session,
phase5_result
);
phase5_result
?
;
write
::
cleanup_llvm
(
&
trans
);
phase_6_link_output
(
sess
,
&
trans
,
&
outputs
);
// Now that we won't touch anything in the incremental compilation directory
...
...
src/librustc_trans/back/write.rs
浏览文件 @
645841ea
此差异已折叠。
点击以展开。
src/librustc_trans/base.rs
浏览文件 @
645841ea
...
...
@@ -27,6 +27,7 @@
use
super
::
ModuleLlvm
;
use
super
::
ModuleSource
;
use
super
::
ModuleTranslation
;
use
super
::
ModuleKind
;
use
assert_module_sources
;
use
back
::
link
;
...
...
@@ -952,6 +953,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
llcx
:
metadata_llcx
,
llmod
:
metadata_llmod
,
}),
kind
:
ModuleKind
::
Metadata
,
};
let
no_builtins
=
attr
::
contains_name
(
&
krate
.attrs
,
"no_builtins"
);
...
...
@@ -961,7 +963,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
!
tcx
.sess.opts.output_types
.should_trans
()
{
let
empty_exported_symbols
=
ExportedSymbols
::
empty
();
let
linker_info
=
LinkerInfo
::
new
(
&
shared_ccx
,
&
empty_exported_symbols
);
return
OngoingCrateTranslation
{
let
crate_translation
=
OngoingCrateTranslation
{
crate_name
:
tcx
.crate_name
(
LOCAL_CRATE
),
link
:
link_meta
,
metadata
:
metadata
,
...
...
@@ -970,12 +972,18 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
linker_info
:
linker_info
,
windows_subsystem
:
None
,
no_integrated_as
:
false
,
result
:
::
std
::
cell
::
RefCell
::
new
(
Some
(::
back
::
write
::
RunLLVMPassesResult
{
modules
:
vec!
[],
metadata_module
:
metadata_module
,
allocator_module
:
None
,
})),
result
:
::
std
::
cell
::
RefCell
::
new
(
None
),
};
::
back
::
write
::
run_passes
(
tcx
.sess
,
&
crate_translation
,
vec!
[],
metadata_module
,
None
,
&
output_filenames
.outputs
,
output_filenames
);
return
crate_translation
;
}
let
exported_symbols
=
Arc
::
new
(
ExportedSymbols
::
compute
(
tcx
,
...
...
@@ -1047,7 +1055,8 @@ fn module_translation<'a, 'tcx>(
let
module
=
ModuleTranslation
{
name
:
cgu_name
,
symbol_name_hash
,
source
:
ModuleSource
::
Preexisting
(
buf
.clone
())
source
:
ModuleSource
::
Preexisting
(
buf
.clone
()),
kind
:
ModuleKind
::
Regular
,
};
return
(
Stats
::
default
(),
module
);
}
...
...
@@ -1108,7 +1117,8 @@ fn module_translation<'a, 'tcx>(
source
:
ModuleSource
::
Translated
(
ModuleLlvm
{
llcx
:
ccx
.llcx
(),
llmod
:
ccx
.llmod
(),
})
}),
kind
:
ModuleKind
::
Regular
,
}
};
...
...
@@ -1196,6 +1206,7 @@ fn module_translation<'a, 'tcx>(
name
:
link
::
ALLOCATOR_MODULE_NAME
.to_string
(),
symbol_name_hash
:
0
,
// we always rebuild allocator shims
source
:
ModuleSource
::
Translated
(
modules
),
kind
:
ModuleKind
::
Allocator
,
})
}
});
...
...
src/librustc_trans/lib.rs
浏览文件 @
645841ea
...
...
@@ -135,7 +135,6 @@ pub mod back {
mod
type_of
;
mod
value
;
#[derive(Clone)]
pub
struct
ModuleTranslation
{
/// The name of the module. When the crate may be saved between
/// compilations, incremental compilation requires that name be
...
...
@@ -145,6 +144,58 @@ pub struct ModuleTranslation {
pub
name
:
String
,
pub
symbol_name_hash
:
u64
,
pub
source
:
ModuleSource
,
pub
kind
:
ModuleKind
,
}
#[derive(Copy,
Clone,
Debug)]
pub
enum
ModuleKind
{
Regular
,
Metadata
,
Allocator
,
}
impl
ModuleTranslation
{
pub
fn
into_compiled_module
(
self
,
emit_obj
:
bool
,
emit_bc
:
bool
)
->
CompiledModule
{
let
pre_existing
=
match
self
.source
{
ModuleSource
::
Preexisting
(
_
)
=>
true
,
ModuleSource
::
Translated
(
_
)
=>
false
,
};
CompiledModule
{
name
:
self
.name
.clone
(),
kind
:
self
.kind
,
symbol_name_hash
:
self
.symbol_name_hash
,
pre_existing
,
emit_obj
,
emit_bc
,
}
}
}
impl
Drop
for
ModuleTranslation
{
fn
drop
(
&
mut
self
)
{
match
self
.source
{
ModuleSource
::
Preexisting
(
_
)
=>
{
// Nothing to dispose.
},
ModuleSource
::
Translated
(
llvm
)
=>
{
unsafe
{
llvm
::
LLVMDisposeModule
(
llvm
.llmod
);
llvm
::
LLVMContextDispose
(
llvm
.llcx
);
}
},
}
}
}
#[derive(Debug)]
pub
struct
CompiledModule
{
pub
name
:
String
,
pub
kind
:
ModuleKind
,
pub
symbol_name_hash
:
u64
,
pub
pre_existing
:
bool
,
pub
emit_obj
:
bool
,
pub
emit_bc
:
bool
,
}
#[derive(Clone)]
...
...
@@ -156,7 +207,7 @@ pub enum ModuleSource {
Translated
(
ModuleLlvm
),
}
#[derive(Copy,
Clone)]
#[derive(Copy,
Clone
,
Debug
)]
pub
struct
ModuleLlvm
{
pub
llcx
:
llvm
::
ContextRef
,
pub
llmod
:
llvm
::
ModuleRef
,
...
...
@@ -167,9 +218,9 @@ unsafe impl Sync for ModuleTranslation { }
pub
struct
CrateTranslation
{
pub
crate_name
:
Symbol
,
pub
modules
:
Vec
<
ModuleTranslation
>
,
pub
metadata_module
:
ModuleTranslation
,
pub
allocator_module
:
Option
<
ModuleTranslation
>
,
pub
modules
:
Vec
<
CompiledModule
>
,
pub
metadata_module
:
CompiledModule
,
pub
allocator_module
:
Option
<
CompiledModule
>
,
pub
link
:
rustc
::
middle
::
cstore
::
LinkMeta
,
pub
metadata
:
rustc
::
middle
::
cstore
::
EncodedMetadata
,
pub
exported_symbols
:
Arc
<
back
::
symbol_export
::
ExportedSymbols
>
,
...
...
@@ -189,7 +240,7 @@ pub struct OngoingCrateTranslation {
pub
no_integrated_as
:
bool
,
// This will be replaced by a Future.
pub
result
:
::
std
::
cell
::
RefCell
<
Option
<
back
::
write
::
RunLLVMPassesResult
>>
,
pub
result
:
::
std
::
cell
::
RefCell
<
Option
<
back
::
write
::
CompiledModules
>>
,
}
impl
OngoingCrateTranslation
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录