Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
976c0b3d
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,发现更多精彩内容 >>
提交
976c0b3d
编写于
6月 21, 2013
作者:
P
Philipp Brüschweiler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove rust_call_tydesc_glue
Towards #4812. Also includes some minor cleanups.
上级
273f9056
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
17 addition
and
82 deletion
+17
-82
src/libextra/arena.rs
src/libextra/arena.rs
+8
-24
src/libstd/cleanup.rs
src/libstd/cleanup.rs
+3
-15
src/libstd/gc.rs
src/libstd/gc.rs
+5
-10
src/libstd/sys.rs
src/libstd/sys.rs
+0
-23
src/rt/rust_builtin.cpp
src/rt/rust_builtin.cpp
+0
-8
src/rt/rustrt.def.in
src/rt/rustrt.def.in
+1
-2
未找到文件。
src/libextra/arena.rs
浏览文件 @
976c0b3d
...
...
@@ -41,36 +41,20 @@
use
core
::
at_vec
;
use
core
::
cast
::{
transmute
,
transmute_mut_region
};
use
core
::
cast
;
use
core
::
libc
::
size_t
;
use
core
::
ptr
;
use
core
::
sys
;
use
core
::
uint
;
use
core
::
vec
;
use
core
::
unstable
::
intrinsics
;
use
core
::
unstable
::
intrinsics
::{
TyDesc
};
#[cfg(stage0)]
use
intrinsic
::{
get_tydesc
,
TyDesc
};
#[cfg(not(stage0))]
use
core
::
unstable
::
intrinsics
::{
get_tydesc
,
TyDesc
};
pub
mod
rustrt
{
use
core
::
libc
::
size_t
;
#[cfg(stage0)]
use
intrinsic
::{
TyDesc
};
#[cfg(not(stage0))]
use
core
::
unstable
::
intrinsics
::{
TyDesc
};
pub
extern
{
#[rust_stack]
unsafe
fn
rust_call_tydesc_glue
(
root
:
*
u8
,
tydesc
:
*
TyDesc
,
field
:
size_t
);
}
}
use
core
::
unstable
::
intrinsics
::{
get_tydesc
};
// This probably belongs somewhere else. Needs to be kept in sync with
// changes to glue...
static
tydesc_drop_glue_index
:
size_t
=
3
as
size_t
;
#[cfg(stage0)]
unsafe
fn
get_tydesc
<
T
>
()
->
*
TyDesc
{
intrinsics
::
get_tydesc
::
<
T
>
()
as
*
TyDesc
}
// The way arena uses arrays is really deeply awful. The arrays are
// allocated, and have capacities reserved, but the fill for the array
...
...
@@ -150,8 +134,8 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
//debug!("freeing object: idx = %u, size = %u, align = %u, done = %b",
// start, size, align, is_done);
if
is_done
{
rustrt
::
rust_call_tydesc_glue
(
ptr
::
offset
(
buf
,
start
),
tydesc
,
tydesc_drop_glue_index
);
((
*
tydesc
)
.drop_glue
)(
&
tydesc
as
**
TyDesc
,
ptr
::
offset
(
buf
,
start
)
as
*
i8
);
}
// Find where the next tydesc lives
...
...
src/libstd/cleanup.rs
浏览文件 @
976c0b3d
...
...
@@ -158,20 +158,6 @@ fn debug_mem() -> bool {
false
}
#[cfg(stage0)]
unsafe
fn
call_drop_glue
(
tydesc
:
*
::
std
::
unstable
::
intrinsics
::
TyDesc
,
data
:
*
i8
)
{
use
sys
::
TypeDesc
;
let
tydesc
:
*
TypeDesc
=
transmute
(
tydesc
);
let
drop_glue
:
extern
"Rust"
fn
(
**
TypeDesc
,
*
i8
)
=
transmute
((
*
tydesc
)
.drop_glue
);
drop_glue
(
to_unsafe_ptr
(
&
tydesc
),
data
);
}
#[cfg(not(stage0))]
unsafe
fn
call_drop_glue
(
tydesc
:
*
::
std
::
unstable
::
intrinsics
::
TyDesc
,
data
:
*
i8
)
{
((
*
tydesc
)
.drop_glue
)(
to_unsafe_ptr
(
&
tydesc
),
data
);
}
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
#[cfg(not(test))]
#[lang=
"annihilate"
]
...
...
@@ -213,7 +199,9 @@ pub unsafe fn annihilate() {
// callback, as the original value may have been freed.
for
each_live_alloc
(
false
)
|
box
,
uniq
|
{
if
!
uniq
{
call_drop_glue
((
*
box
)
.header.type_desc
,
transmute
(
&
(
*
box
)
.data
));
let
tydesc
=
(
*
box
)
.header.type_desc
;
let
data
=
transmute
(
&
(
*
box
)
.data
);
((
*
tydesc
)
.drop_glue
)(
to_unsafe_ptr
(
&
tydesc
),
data
);
}
}
...
...
src/libstd/gc.rs
浏览文件 @
976c0b3d
...
...
@@ -40,12 +40,13 @@
use
cast
;
use
container
::{
Map
,
Set
};
use
io
;
use
libc
::{
size_t
,
uintptr_t
};
use
libc
::{
uintptr_t
};
use
option
::{
None
,
Option
,
Some
};
use
ptr
;
use
hashmap
::
HashSet
;
use
stackwalk
::
walk_stack
;
use
sys
;
use
unstable
::
intrinsics
::{
TyDesc
};
pub
use
stackwalk
::
Word
;
...
...
@@ -58,17 +59,11 @@ pub struct StackSegment {
}
pub
mod
rustrt
{
use
libc
::
size_t
;
use
stackwalk
::
Word
;
use
super
::
StackSegment
;
#[link_name
=
"rustrt"
]
pub
extern
{
#[rust_stack]
pub
unsafe
fn
rust_call_tydesc_glue
(
root
:
*
Word
,
tydesc
:
*
Word
,
field
:
size_t
);
#[rust_stack]
pub
unsafe
fn
rust_gc_metadata
()
->
*
Word
;
...
...
@@ -125,7 +120,7 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
return
None
;
}
type
Visitor
<
'self
>
=
&
'self
fn
(
root
:
**
Word
,
tydesc
:
*
Word
)
->
bool
;
type
Visitor
<
'self
>
=
&
'self
fn
(
root
:
**
Word
,
tydesc
:
*
TyDesc
)
->
bool
;
// Walks the list of roots for the given safe point, and calls visitor
// on each root.
...
...
@@ -139,7 +134,7 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
let
stack_roots
:
*
u32
=
bump
(
sp_meta
,
2
);
let
reg_roots
:
*
u8
=
bump
(
stack_roots
,
num_stack_roots
);
let
addrspaces
:
*
Word
=
align_to_pointer
(
bump
(
reg_roots
,
num_reg_roots
));
let
tydescs
:
***
Word
=
bump
(
addrspaces
,
num_stack_roots
);
let
tydescs
:
***
TyDesc
=
bump
(
addrspaces
,
num_stack_roots
);
// Stack roots
let
mut
sri
=
0
;
...
...
@@ -364,7 +359,7 @@ pub fn cleanup_stack_for_failure() {
// FIXME #4420: Destroy this box
// FIXME #4330: Destroy this box
}
else
{
rustrt
::
rust_call_tydesc_glue
(
*
root
,
tydesc
,
3
as
size_t
);
((
*
tydesc
)
.drop_glue
)(
&
tydesc
as
**
TyDesc
,
*
root
as
*
i8
);
}
}
}
...
...
src/libstd/sys.rs
浏览文件 @
976c0b3d
...
...
@@ -22,17 +22,6 @@
use
str
;
use
unstable
::
intrinsics
;
// Corresponds to runtime type_desc type
#[cfg(stage0)]
pub
struct
TypeDesc
{
size
:
uint
,
align
:
uint
,
take_glue
:
uint
,
drop_glue
:
uint
,
free_glue
:
uint
// Remaining fields not listed
}
/// The representation of a Rust closure
pub
struct
Closure
{
code
:
*
(),
...
...
@@ -50,18 +39,6 @@ unsafe fn rust_upcall_fail(expr: *c_char,
}
}
/**
* Returns a pointer to a type descriptor.
*
* Useful for calling certain function in the Rust runtime or otherwise
* performing dark magick.
*/
#[inline]
#[cfg(stage0)]
pub
fn
get_type_desc
<
T
>
()
->
*
TypeDesc
{
unsafe
{
intrinsics
::
get_tydesc
::
<
T
>
()
as
*
TypeDesc
}
}
/// Returns the size of a type
#[inline]
pub
fn
size_of
<
T
>
()
->
uint
{
...
...
src/rt/rust_builtin.cpp
浏览文件 @
976c0b3d
...
...
@@ -729,14 +729,6 @@ rust_task_deref(rust_task *task) {
task
->
deref
();
}
// Must call on rust stack.
extern
"C"
CDECL
void
rust_call_tydesc_glue
(
void
*
root
,
size_t
*
tydesc
,
size_t
glue_index
)
{
glue_fn
*
fn
=
(
glue_fn
*
)
tydesc
[
glue_index
];
if
(
fn
)
fn
(
0
,
0
,
root
);
}
// Don't run on the Rust stack!
extern
"C"
void
rust_log_str
(
uint32_t
level
,
const
char
*
str
,
size_t
size
)
{
...
...
src/rt/rustrt.def.in
浏览文件 @
976c0b3d
...
...
@@ -174,7 +174,6 @@ rust_set_task_local_data
rust_task_local_data_atexit
rust_task_ref
rust_task_deref
rust_call_tydesc_glue
tdefl_compress_mem_to_heap
tinfl_decompress_mem_to_heap
rust_gc_metadata
...
...
@@ -239,4 +238,4 @@ rust_valgrind_stack_deregister
rust_take_env_lock
rust_drop_env_lock
rust_update_log_settings
rust_running_on_valgrind
\ No newline at end of file
rust_running_on_valgrind
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录