Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7fd23e4f
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,发现更多精彩内容 >>
提交
7fd23e4f
编写于
7月 22, 2013
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert uses of transmute which don't need it
上级
467d381d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
16 addition
and
18 deletion
+16
-18
src/libstd/cleanup.rs
src/libstd/cleanup.rs
+8
-10
src/libstd/gc.rs
src/libstd/gc.rs
+8
-8
未找到文件。
src/libstd/cleanup.rs
浏览文件 @
7fd23e4f
...
...
@@ -13,7 +13,6 @@
use
libc
::
c_void
;
use
ptr
::{
mut_null
};
use
repr
::
BoxRepr
;
use
cast
::
transmute
;
use
unstable
::
intrinsics
::
TyDesc
;
type
DropGlue
<
'self
>
=
&
'self
fn
(
**
TyDesc
,
*
c_void
);
...
...
@@ -40,18 +39,17 @@ unsafe fn each_live_alloc(read_next_before: bool,
let
box
=
local_heap
::
live_allocs
();
let
mut
box
:
*
mut
BoxRepr
=
transmute
(
box
);
while
box
!=
mut_null
()
{
let
next_before
=
transmute
((
*
box
)
.header.next
);
let
uniq
=
(
*
box
)
.header.ref_count
==
managed
::
raw
::
RC_MANAGED_UNIQUE
;
let
next_before
=
(
*
box
)
.next
;
let
uniq
=
(
*
box
)
.ref_count
==
managed
::
RC_MANAGED_UNIQUE
;
if
!
f
(
box
,
uniq
)
{
if
!
f
(
box
as
*
mut
raw
::
Box
<
()
>
,
uniq
)
{
return
false
;
}
if
read_next_before
{
box
=
next_before
;
}
else
{
box
=
transmute
((
*
box
)
.header.next
)
;
box
=
(
*
box
)
.next
;
}
}
return
true
;
...
...
@@ -113,9 +111,9 @@ pub unsafe fn annihilate() {
// callback, as the original value may have been freed.
for
each_live_alloc
(
false
)
|
box
,
uniq
|
{
if
!
uniq
{
let
tydesc
:
*
TyDesc
=
transmute
((
*
box
)
.header.type_desc
)
;
let
data
=
transmute
(
&
(
*
box
)
.data
);
((
*
tydesc
)
.drop_glue
)(
data
);
let
tydesc
=
(
*
box
)
.type_desc
;
let
data
=
&
(
*
box
)
.data
as
*
(
);
((
*
tydesc
)
.drop_glue
)(
data
as
*
i8
);
}
}
...
...
@@ -130,7 +128,7 @@ pub unsafe fn annihilate() {
stats
.n_bytes_freed
+=
(
*
((
*
box
)
.header.type_desc
))
.size
+
sys
::
size_of
::
<
BoxRepr
>
();
local_free
(
transmute
(
box
)
);
local_free
(
box
as
*
u8
);
}
}
...
...
src/libstd/gc.rs
浏览文件 @
7fd23e4f
...
...
@@ -74,14 +74,14 @@ pub mod rustrt {
}
unsafe
fn
bump
<
T
,
U
>
(
ptr
:
*
T
,
count
:
uint
)
->
*
U
{
return
cast
::
transmute
(
ptr
::
offset
(
ptr
,
count
))
;
return
ptr
::
offset
(
ptr
,
count
)
as
*
U
;
}
unsafe
fn
align_to_pointer
<
T
>
(
ptr
:
*
T
)
->
*
T
{
let
align
=
sys
::
min_align_of
::
<*
T
>
();
let
ptr
:
uint
=
cast
::
transmute
(
ptr
)
;
let
ptr
=
ptr
as
uint
;
let
ptr
=
(
ptr
+
(
align
-
1
))
&
-
align
;
return
cast
::
transmute
(
ptr
)
;
return
ptr
as
*
T
;
}
unsafe
fn
get_safe_point_count
()
->
uint
{
...
...
@@ -126,8 +126,8 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
// Walks the list of roots for the given safe point, and calls visitor
// on each root.
unsafe
fn
_
walk_safe_point
(
fp
:
*
Word
,
sp
:
SafePoint
,
visitor
:
Visitor
)
->
bool
{
let
fp_bytes
:
*
u8
=
cast
::
transmute
(
fp
)
;
let
sp_meta
:
*
u32
=
cast
::
transmute
(
sp
.sp_meta
)
;
let
fp_bytes
=
fp
as
*
u8
;
let
sp_meta
=
sp
.sp_meta
as
*
u32
;
let
num_stack_roots
=
*
sp_meta
as
uint
;
let
num_reg_roots
=
*
ptr
::
offset
(
sp_meta
,
1
)
as
uint
;
...
...
@@ -173,9 +173,9 @@ unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
// Is fp contained in segment?
unsafe
fn
is_frame_in_segment
(
fp
:
*
Word
,
segment
:
*
StackSegment
)
->
bool
{
let
begin
:
Word
=
cast
::
transmute
(
segment
)
;
let
end
:
Word
=
cast
::
transmute
((
*
segment
)
.end
)
;
let
frame
:
Word
=
cast
::
transmute
(
fp
)
;
let
begin
=
segment
as
Word
;
let
end
=
(
*
segment
)
.end
as
Word
;
let
frame
=
fp
as
Word
;
return
begin
<=
frame
&&
frame
<=
end
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录