Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dacf9ba0
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,发现更多精彩内容 >>
提交
dacf9ba0
编写于
4月 01, 2018
作者:
J
John Kåre Alsaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make Session.injected_allocator and Session.allocator_kind thread-safe
上级
66488a50
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
5 deletion
+13
-5
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+4
-4
src/librustc_metadata/creader.rs
src/librustc_metadata/creader.rs
+8
-0
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+1
-1
未找到文件。
src/librustc/session/mod.rs
浏览文件 @
dacf9ba0
...
...
@@ -118,8 +118,8 @@ pub struct Session {
/// The metadata::creader module may inject an allocator/panic_runtime
/// dependency if it didn't already find one, and this tracks what was
/// injected.
pub
injected_allocator
:
Cell
<
Option
<
CrateNum
>>
,
pub
allocator_kind
:
Cell
<
Option
<
AllocatorKind
>>
,
pub
injected_allocator
:
Once
<
Option
<
CrateNum
>>
,
pub
allocator_kind
:
Once
<
Option
<
AllocatorKind
>>
,
pub
injected_panic_runtime
:
Cell
<
Option
<
CrateNum
>>
,
/// Map from imported macro spans (which consist of
...
...
@@ -1105,8 +1105,8 @@ pub fn build_session_(
const_eval_stack_frame_limit
:
100
,
const_eval_step_limit
:
1_000_000
,
next_node_id
:
OneThread
::
new
(
Cell
::
new
(
NodeId
::
new
(
1
))),
injected_allocator
:
Cell
::
new
(
None
),
allocator_kind
:
Cell
::
new
(
None
),
injected_allocator
:
Once
::
new
(
),
allocator_kind
:
Once
::
new
(
),
injected_panic_runtime
:
Cell
::
new
(
None
),
imported_macro_spans
:
OneThread
::
new
(
RefCell
::
new
(
HashMap
::
new
())),
incr_comp_session
:
OneThread
::
new
(
RefCell
::
new
(
IncrCompSession
::
NotInitialized
)),
...
...
src/librustc_metadata/creader.rs
浏览文件 @
dacf9ba0
...
...
@@ -823,6 +823,8 @@ fn inject_allocator_crate(&mut self, krate: &ast::Crate) {
needs_allocator
=
needs_allocator
||
data
.needs_allocator
(
self
.sess
);
});
if
!
needs_allocator
{
self
.sess.injected_allocator
.set
(
None
);
self
.sess.allocator_kind
.set
(
None
);
return
}
...
...
@@ -842,6 +844,8 @@ fn inject_allocator_crate(&mut self, krate: &ast::Crate) {
}
}
if
!
need_lib_alloc
&&
!
need_exe_alloc
{
self
.sess.injected_allocator
.set
(
None
);
self
.sess.allocator_kind
.set
(
None
);
return
}
...
...
@@ -879,6 +883,7 @@ fn inject_allocator_crate(&mut self, krate: &ast::Crate) {
});
if
global_allocator
.is_some
()
{
self
.sess.allocator_kind
.set
(
Some
(
AllocatorKind
::
Global
));
self
.sess.injected_allocator
.set
(
None
);
return
}
...
...
@@ -922,6 +927,9 @@ fn inject_allocator_crate(&mut self, krate: &ast::Crate) {
};
let
allocation_crate_data
=
exe_allocation_crate_data
.or_else
(||
{
// No allocator was injected
self
.sess.injected_allocator
.set
(
None
);
if
attr
::
contains_name
(
&
krate
.attrs
,
"default_lib_allocator"
)
{
// Prefer self as the allocator if there's a collision
return
None
;
...
...
src/librustc_trans/base.rs
浏览文件 @
dacf9ba0
...
...
@@ -795,7 +795,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
codegen_units
.len
());
// Translate an allocator shim, if any
let
allocator_module
=
if
let
Some
(
kind
)
=
tcx
.sess.allocator_kind
.get
()
{
let
allocator_module
=
if
let
Some
(
kind
)
=
*
tcx
.sess.allocator_kind
.get
()
{
unsafe
{
let
llmod_id
=
"allocator"
;
let
(
llcx
,
llmod
)
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录