Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
591b2802
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,发现更多精彩内容 >>
提交
591b2802
编写于
6月 13, 2012
作者:
M
Michael Sullivan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make trans only generate calls to the _dyn malloc upcalls, so we can get rid of the non dyn ones.
上级
4c0d41cf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
43 deletion
+26
-43
src/rt/rust_upcall.cpp
src/rt/rust_upcall.cpp
+2
-0
src/rustc/back/upcall.rs
src/rustc/back/upcall.rs
+0
-7
src/rustc/middle/trans/base.rs
src/rustc/middle/trans/base.rs
+22
-34
src/rustc/middle/trans/closure.rs
src/rustc/middle/trans/closure.rs
+2
-2
未找到文件。
src/rt/rust_upcall.cpp
浏览文件 @
591b2802
...
...
@@ -156,6 +156,7 @@ exchange_malloc(rust_task *task, type_desc *td, uintptr_t size) {
return
(
uintptr_t
)
header
;
}
// FIXME: remove after snapshot (6/13/12)
struct
s_exchange_malloc_args
{
uintptr_t
retval
;
type_desc
*
td
;
...
...
@@ -238,6 +239,7 @@ shared_malloc(rust_task *task, type_desc *td, uintptr_t size) {
return
(
uintptr_t
)
box
;
}
// FIXME: remove after snapshot (6/13/12)
struct
s_malloc_args
{
uintptr_t
retval
;
type_desc
*
td
;
...
...
src/rustc/back/upcall.rs
浏览文件 @
591b2802
...
...
@@ -10,10 +10,8 @@
type
upcalls
=
{
_
fail
:
ValueRef
,
trace
:
ValueRef
,
malloc
:
ValueRef
,
malloc_dyn
:
ValueRef
,
free
:
ValueRef
,
exchange_malloc
:
ValueRef
,
exchange_malloc_dyn
:
ValueRef
,
exchange_free
:
ValueRef
,
validate_box
:
ValueRef
,
...
...
@@ -57,17 +55,12 @@ fn nothrow(f: ValueRef) -> ValueRef {
trace
:
dv
(
"trace"
,
[
T_ptr
(
T_i8
()),
T_ptr
(
T_i8
()),
int_t
]),
malloc
:
nothrow
(
d
(
"malloc"
,
[
T_ptr
(
tydesc_type
)],
malloc_dyn
:
nothrow
(
d
(
"malloc_dyn"
,
[
T_ptr
(
tydesc_type
),
int_t
],
T_ptr
(
T_i8
()))),
free
:
nothrow
(
dv
(
"free"
,
[
T_ptr
(
T_i8
())])),
exchange_malloc
:
nothrow
(
d
(
"exchange_malloc"
,
[
T_ptr
(
tydesc_type
)],
T_ptr
(
T_i8
()))),
exchange_malloc_dyn
:
nothrow
(
d
(
"exchange_malloc_dyn"
,
[
T_ptr
(
tydesc_type
),
int_t
],
...
...
src/rustc/middle/trans/base.rs
浏览文件 @
591b2802
...
...
@@ -348,17 +348,17 @@ fn opaque_box_body(bcx: block,
PointerCast
(
bcx
,
bodyptr
,
T_ptr
(
type_of
(
ccx
,
body_t
)))
}
// malloc_raw
: expects an unboxed type and returns a pointer to
//
enough space for a box of that type. This includes a rust_opaque_box
// header.
fn
malloc_raw
(
bcx
:
block
,
t
:
ty
::
t
,
heap
:
heap
)
->
ValueRef
{
// malloc_raw
_dyn: allocates a box to contain a given type, but with a
//
potentially dynamic size.
fn
malloc_raw_dyn
(
bcx
:
block
,
t
:
ty
::
t
,
heap
:
heap
,
size
:
ValueRef
)
->
ValueRef
{
let
_
icx
=
bcx
.insn_ctxt
(
"malloc_raw"
);
let
ccx
=
bcx
.ccx
();
let
(
mk_fn
,
upcall
)
=
alt
heap
{
heap_shared
{
(
ty
::
mk_imm_box
,
ccx
.upcalls.malloc
)
}
heap_shared
{
(
ty
::
mk_imm_box
,
ccx
.upcalls.malloc
_dyn
)
}
heap_exchange
{
(
ty
::
mk_imm_uniq
,
ccx
.upcalls.exchange_malloc
)
(
ty
::
mk_imm_uniq
,
ccx
.upcalls.exchange_malloc
_dyn
)
}
};
...
...
@@ -372,52 +372,40 @@ fn malloc_raw(bcx: block, t: ty::t, heap: heap) -> ValueRef {
lazily_emit_all_tydesc_glue
(
ccx
,
copy
static_ti
);
// Allocate space:
let
rval
=
Call
(
bcx
,
upcall
,
[
lltydesc
]);
let
rval
=
Call
(
bcx
,
upcall
,
[
lltydesc
,
size
]);
ret
PointerCast
(
bcx
,
rval
,
llty
);
}
// malloc_general: usefully wraps malloc_raw; allocates a box,
// malloc_raw: expects an unboxed type and returns a pointer to
// enough space for a box of that type. This includes a rust_opaque_box
// header.
fn
malloc_raw
(
bcx
:
block
,
t
:
ty
::
t
,
heap
:
heap
)
->
ValueRef
{
malloc_raw_dyn
(
bcx
,
t
,
heap
,
llsize_of
(
bcx
.ccx
(),
type_of
(
bcx
.ccx
(),
t
)))
}
// malloc_general_dyn: usefully wraps malloc_raw_dyn; allocates a box,
// and pulls out the body
fn
malloc_general
(
bcx
:
block
,
t
:
ty
::
t
,
heap
:
heap
)
->
fn
malloc_general
_dyn
(
bcx
:
block
,
t
:
ty
::
t
,
heap
:
heap
,
size
:
ValueRef
)
->
{
box
:
ValueRef
,
body
:
ValueRef
}
{
let
_
icx
=
bcx
.insn_ctxt
(
"malloc_general"
);
let
box
=
malloc_raw
(
bcx
,
t
,
heap
);
let
box
=
malloc_raw
_dyn
(
bcx
,
t
,
heap
,
size
);
let
non_gc_box
=
non_gc_box_cast
(
bcx
,
box
);
let
body
=
GEPi
(
bcx
,
non_gc_box
,
[
0u
,
abi
::
box_field_body
]);
ret
{
box
:
box
,
body
:
body
};
}
fn
malloc_boxed
(
bcx
:
block
,
t
:
ty
::
t
)
->
{
box
:
ValueRef
,
body
:
ValueRef
}
{
malloc_general
(
bcx
,
t
,
heap_shared
)
malloc_general_dyn
(
bcx
,
t
,
heap_shared
,
llsize_of
(
bcx
.ccx
(),
type_of
(
bcx
.ccx
(),
t
)))
}
fn
malloc_unique
(
bcx
:
block
,
t
:
ty
::
t
)
->
{
box
:
ValueRef
,
body
:
ValueRef
}
{
malloc_general
(
bcx
,
t
,
heap_exchange
)
}
fn
malloc_unique_dyn_raw
(
bcx
:
block
,
t
:
ty
::
t
,
size
:
ValueRef
)
->
ValueRef
{
let
_
icx
=
bcx
.insn_ctxt
(
"malloc_unique_dyn_raw"
);
let
ccx
=
bcx
.ccx
();
// Grab the TypeRef type of box_ptr_ty.
let
box_ptr_ty
=
ty
::
mk_imm_uniq
(
ccx
.tcx
,
t
);
let
llty
=
type_of
(
ccx
,
box_ptr_ty
);
// Get the tydesc for the body:
let
mut
static_ti
=
none
;
let
lltydesc
=
get_tydesc
(
ccx
,
t
,
static_ti
);
lazily_emit_all_tydesc_glue
(
ccx
,
static_ti
);
// Allocate space:
let
rval
=
Call
(
bcx
,
ccx
.upcalls.exchange_malloc_dyn
,
[
lltydesc
,
size
]);
ret
PointerCast
(
bcx
,
rval
,
llty
);
malloc_general_dyn
(
bcx
,
t
,
heap_exchange
,
llsize_of
(
bcx
.ccx
(),
type_of
(
bcx
.ccx
(),
t
)))
}
fn
malloc_unique_dyn
(
bcx
:
block
,
t
:
ty
::
t
,
size
:
ValueRef
)
->
{
box
:
ValueRef
,
body
:
ValueRef
}
{
let
_
icx
=
bcx
.insn_ctxt
(
"malloc_unique_dyn"
);
let
box
=
malloc_unique_dyn_raw
(
bcx
,
t
,
size
);
let
body
=
GEPi
(
bcx
,
box
,
[
0u
,
abi
::
box_field_body
]);
ret
{
box
:
box
,
body
:
body
};
malloc_general_dyn
(
bcx
,
t
,
heap_exchange
,
size
)
}
// Type descriptor and type glue stuff
...
...
src/rustc/middle/trans/closure.rs
浏览文件 @
591b2802
...
...
@@ -553,8 +553,8 @@ fn make_opaque_cbox_take_glue(
let
sz
=
Add
(
bcx
,
sz
,
shape
::
llsize_of
(
ccx
,
T_box_header
(
ccx
)));
// Allocate memory, update original ptr, and copy existing data
let
malloc
=
ccx
.upcalls.exchange_malloc
;
let
cbox_out
=
Call
(
bcx
,
malloc
,
[
tydesc
]);
let
malloc
=
ccx
.upcalls.exchange_malloc
_dyn
;
let
cbox_out
=
Call
(
bcx
,
malloc
,
[
tydesc
,
sz
]);
let
cbox_out
=
PointerCast
(
bcx
,
cbox_out
,
llopaquecboxty
);
call_memmove
(
bcx
,
cbox_out
,
cbox_in
,
sz
);
Store
(
bcx
,
cbox_out
,
cboxptr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录