Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5aedabf1
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,发现更多精彩内容 >>
提交
5aedabf1
编写于
9月 03, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Run all intrinsics through the monomorphiser
Intrinsics always want to be inlined.
上级
bb348cca
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
39 deletion
+22
-39
src/rustc/middle/trans/base.rs
src/rustc/middle/trans/base.rs
+16
-17
src/rustc/middle/trans/foreign.rs
src/rustc/middle/trans/foreign.rs
+2
-20
src/rustc/middle/trans/type_use.rs
src/rustc/middle/trans/type_use.rs
+4
-2
未找到文件。
src/rustc/middle/trans/base.rs
浏览文件 @
5aedabf1
...
...
@@ -2504,7 +2504,6 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id,
// Check whether this fn has an inlined copy and, if so, redirect fn_id to
// the local id of the inlined copy.
let
original_crate
=
fn_id
.crate
;
let
fn_id
=
if
fn_id
.crate
!=
ast
::
local_crate
{
maybe_instantiate_inline
(
ccx
,
fn_id
)
}
else
{
fn_id
};
...
...
@@ -2513,27 +2512,27 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id,
let
local_with_type_params
=
fn_id
.crate
==
ast
::
local_crate
&&
tys
.len
()
>
0u
;
// Rust intrinsic functions should always be monomorphised
let
inlined_rust_intrinsic
=
{
if
fn_id
.crate
==
ast
::
local_crate
&&
original_crate
!=
ast
::
local_crate
{
// Intrinsic functions should always be monomorphised. In particular,
// if we see an intrinsic that is inlined from a different crate, we
// want to reemit the intrinsic instead of trying to call it in the
// other crate.
let
rust_intrinsic
=
if
fn_id
.crate
==
ast
::
local_crate
{
let
map_node
=
session
::
expect
(
ccx
.sess
,
ccx
.tcx.items
.find
(
fn_id
.node
),
||
fmt!
(
"inlined
item should be in ast map"
));
let
map_node
=
session
::
expect
(
ccx
.sess
,
ccx
.tcx.items
.find
(
fn_id
.node
),
||
fmt!
(
"local
item should be in ast map"
));
match
map_node
{
ast_map
::
node_foreign_item
(
_
,
ast
::
foreign_abi_rust_intrinsic
,
_
)
=>
true
,
_
=>
false
}
}
else
{
false
match
map_node
{
ast_map
::
node_foreign_item
(
_
,
ast
::
foreign_abi_rust_intrinsic
,
_
)
=>
true
,
_
=>
false
}
}
else
{
false
};
local_with_type_params
||
inlined_
rust_intrinsic
local_with_type_params
||
rust_intrinsic
};
if
must_monomorphise
{
...
...
src/rustc/middle/trans/foreign.rs
浏览文件 @
5aedabf1
...
...
@@ -759,7 +759,7 @@ fn build_ret(bcx: block, _tys: @c_stack_tys,
for
vec
::
each
(
foreign_mod
.items
)
|
foreign_item
|
{
match
foreign_item
.node
{
ast
::
foreign_item_fn
(
_
,
_
,
typarams
)
=>
{
ast
::
foreign_item_fn
(
*
)
=>
{
let
id
=
foreign_item
.id
;
if
abi
!=
ast
::
foreign_abi_rust_intrinsic
{
let
llwrapfn
=
get_item_val
(
ccx
,
id
);
...
...
@@ -772,25 +772,7 @@ fn build_ret(bcx: block, _tys: @c_stack_tys,
build_wrap_fn
(
ccx
,
tys
,
llshimfn
,
llwrapfn
);
}
}
else
{
// Intrinsics with type parameters are emitted by
// monomorphic_fn, but ones without are emitted here
if
typarams
.is_empty
()
{
let
llwrapfn
=
get_item_val
(
ccx
,
id
);
let
path
=
match
ccx
.tcx.items
.find
(
id
)
{
Some
(
ast_map
::
node_foreign_item
(
_
,
_
,
pt
))
=>
pt
,
_
=>
{
ccx
.sess
.span_bug
(
foreign_item
.span
,
~
"can't find intrinsic path"
)
}
};
let
psubsts
=
{
tys
:
~
[],
vtables
:
None
,
bounds
:
@~
[]
};
trans_intrinsic
(
ccx
,
llwrapfn
,
foreign_item
,
*
path
,
psubsts
,
None
);
}
// Intrinsics are emitted by monomorphic fn
}
}
ast
::
foreign_item_const
(
*
)
=>
{
...
...
src/rustc/middle/trans/type_use.rs
浏览文件 @
5aedabf1
...
...
@@ -94,11 +94,13 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
~
"atomic_xchg_acq"
|
~
"atomic_xadd_acq"
|
~
"atomic_xsub_acq"
|
~
"atomic_xchg_rel"
|
~
"atomic_xadd_rel"
|
~
"atomic_xsub_rel"
=>
{
0u
}
~
"visit_tydesc"
|
~
"forget"
|
~
"addr_of"
=>
{
~
"visit_tydesc"
|
~
"forget"
|
~
"addr_of"
|
~
"frame_address"
|
~
"morestack_addr"
=>
{
0u
}
// would be cool to make these an enum instead of strings!
_
=>
fail
~
"unknown intrinsic in type_use"
_
=>
fail
fmt!
(
"unknown intrinsic in type_use %?"
,
cx
.ccx.sess
.str_of
(
i
.ident
))
};
for
uint
::
range
(
0u
,
n_tps
)
|
n
|
{
cx
.uses
[
n
]
|
=
flags
;}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录