Skip to content

Commit c2290a5

Browse files
nikomatsakisbrson
authored andcommitted
---
yaml --- r: 5943 b: refs/heads/master c: 02d7a1e h: refs/heads/master i: 5941: ac23035 5939: e5a56d8 5935: f37f3ec v: v3
1 parent 730636b commit c2290a5

File tree

8 files changed

+97
-92
lines changed

8 files changed

+97
-92
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 0598635bdcb8316d072351d49d9c8ac04aa82992
2+
refs/heads/master: 02d7a1e7818f5ff3f272fe6cba21f82ea543dc39

trunk/src/lib/sys.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,36 @@ tag type_desc {
66
type_desc(@type_desc);
77
}
88

9-
native "rust" mod rustrt {
9+
native "c-stack-cdecl" mod rustrt {
1010
// Explicitly re-export native stuff we want to be made
1111
// available outside this crate. Otherwise it's
1212
// visible-in-crate, but not re-exported.
1313
fn last_os_error() -> str;
14-
fn size_of<T>() -> uint;
15-
fn align_of<T>() -> uint;
14+
fn size_of(td: *type_desc) -> uint;
15+
fn align_of(td: *type_desc) -> uint;
1616
fn refcount<T>(t: @T) -> uint;
1717
fn do_gc();
1818
fn unsupervise();
19+
}
20+
21+
native "rust-intrinsic" mod rusti {
1922
fn get_type_desc<T>() -> *type_desc;
2023
}
2124

2225
fn get_type_desc<T>() -> *type_desc {
23-
ret rustrt::get_type_desc::<T>();
26+
ret rusti::get_type_desc::<T>();
2427
}
2528

2629
fn last_os_error() -> str {
2730
ret rustrt::last_os_error();
2831
}
2932

3033
fn size_of<T>() -> uint {
31-
ret rustrt::size_of::<T>();
34+
ret rustrt::size_of(get_type_desc::<T>());
3235
}
3336

3437
fn align_of<T>() -> uint {
35-
ret rustrt::align_of::<T>();
38+
ret rustrt::align_of(get_type_desc::<T>());
3639
}
3740

3841
fn refcount<T>(t: @T) -> uint {

trunk/src/lib/task.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ native "rust" mod rustrt {
2626
fn task_sleep(time_in_us: uint);
2727
fn task_yield();
2828
fn task_join(t: task_id) -> int;
29-
fn unsupervise();
3029
fn pin_task();
3130
fn unpin_task();
3231
fn get_task_id() -> task_id;
@@ -85,7 +84,7 @@ fn join_id(t: task_id) -> task_result {
8584
alt rustrt::task_join(t) { 0 { tr_success } _ { tr_failure } }
8685
}
8786

88-
fn unsupervise() { ret rustrt::unsupervise(); }
87+
fn unsupervise() { ret sys::unsupervise(); }
8988

9089
fn pin() { rustrt::pin_task(); }
9190

trunk/src/rt/intrinsics/intrinsics.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@ rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty,
4848
port_recv((uintptr_t*)retptr, port);
4949
}
5050

51+
extern "C" void
52+
rust_intrinsic_get_type_desc(rust_task *task, void **retptr,
53+
type_desc* ty) {
54+
*(type_desc**)retptr = ty;
55+
}
56+
Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,108 @@
11
; ModuleID = 'intrinsics.cpp'
22
target triple = "@CFG_LLVM_TRIPLE@"
33

4-
%struct.rust_task = type { i32, %struct.stk_seg*, i32, i32, %struct.gc_alloc*, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, i32, %class.timer, i32*, %class.array_list, %class.context, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, i8, i8, %class.lock_and_signal }
5-
%struct.stk_seg = type { i32, i32, [0 x i8] }
6-
%struct.gc_alloc = type { %struct.gc_alloc*, %struct.gc_alloc*, i32, [0 x i8] }
7-
%struct.rust_scheduler = type { %class.rust_thread, %struct.rc_base, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, %class.hash_map, %class.hash_map.3, i32, %class.lock_and_signal, i32, %struct._opaque_pthread_attr_t, %struct.rust_env* }
8-
%class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* }
9-
%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] }
10-
%struct.__darwin_pthread_handler_rec = type { {}*, i8*, %struct.__darwin_pthread_handler_rec* }
11-
%struct.rc_base = type { i32 }
4+
%0 = type { i32, %"struct.memory_region::alloc_header"**, i32 }
5+
%1 = type { i32, %struct.rust_scheduler**, i32 }
6+
%2 = type { %"struct.hash_map<long, rust_task *>::map_entry"* }
7+
%3 = type { %struct.rust_task*, i32, i32, %class.rust_chan** }
8+
%class.array_list = type { i32, %struct.rust_task**, i32 }
9+
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
10+
%class.context = type { %struct.registers_t, %class.context* }
11+
%"class.debug::task_debug_info" = type { %"class.std::map" }
12+
%class.hash_map = type { %"struct.hash_map<long, rust_port *>::map_entry"* }
13+
%class.indexed_list = type { i32 (...)**, %class.array_list }
14+
%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8, i8 }
15+
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %0, i8, i8, %class.lock_and_signal }
16+
%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** }
17+
%class.rust_chan = type { i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i32, %class.circular_buffer }
18+
%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 }
19+
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %1, %struct.randctx, i32, %2, i32, i32, i32, %struct.rust_env* }
1220
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
21+
%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* }
22+
%class.rust_port = type { i32, i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_chan*, i32, %class.ptr_vec, %3, %class.lock_and_signal }
1323
%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region }
14-
%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* }
15-
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list.0, i8, i8, %class.lock_and_signal, i8 }
16-
%class.array_list.0 = type { i32, %"struct.memory_region::alloc_header"**, i32 }
17-
%"struct.memory_region::alloc_header" = type { i32, i32, i8*, [0 x i8] }
18-
%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8, i8 }
19-
%struct._opaque_pthread_cond_t = type { i32, [24 x i8] }
20-
%struct._opaque_pthread_mutex_t = type { i32, [40 x i8] }
24+
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
2125
%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* }
22-
%class.indexed_list = type { i32 (...)**, %class.array_list }
23-
%class.array_list = type { i32, %struct.rust_task**, i32 }
24-
%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 }
25-
%struct.type_desc = type { %struct.type_desc**, i32, i32, {}*, {}*, {}*, {}*, {}*, {}*, i32, {}*, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] }
26+
%class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* }
27+
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, const type_desc *>, std::_Select1st<std::pair<void *const, const type_desc *> >, std::less<void *>, std::allocator<std::pair<void *const, const type_desc *> > >::_Rb_tree_impl" }
28+
%"class.std::map" = type { %"class.std::_Rb_tree" }
29+
%class.timer = type { i32 (...)**, i64, i64 }
30+
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
2631
%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 }
2732
%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 }
28-
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
29-
%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 }
30-
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.4, %struct.randctx, i32, i32, i32, %struct.rust_env* }
31-
%class.array_list.4 = type { i32, %struct.rust_scheduler**, i32 }
32-
%class.hash_map = type { %"struct.hash_map<rust_task *, rust_task *>::map_entry"* }
33-
%"struct.hash_map<rust_task *, rust_task *>::map_entry" = type opaque
34-
%class.hash_map.3 = type { %"struct.hash_map<rust_port *, rust_port *>::map_entry"* }
35-
%"struct.hash_map<rust_port *, rust_port *>::map_entry" = type opaque
33+
%struct.__darwin_pthread_handler_rec = type { void (i8*)*, i8*, %struct.__darwin_pthread_handler_rec* }
3634
%struct._opaque_pthread_attr_t = type { i32, [36 x i8] }
37-
%struct.rust_cond = type { i8 }
38-
%class.timer = type { i32 (...)**, i64, i64 }
39-
%class.context = type { %struct.registers_t, %class.context* }
35+
%struct._opaque_pthread_cond_t = type { i32, [24 x i8] }
36+
%struct._opaque_pthread_mutex_t = type { i32, [40 x i8] }
37+
%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] }
38+
%struct.chan_handle = type { i32, i32 }
39+
%"struct.hash_map<long, rust_port *>::map_entry" = type opaque
40+
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
41+
%"struct.memory_region::alloc_header" = type { i32, i32, i8*, i32, [0 x i8] }
42+
%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 }
4043
%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 }
41-
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
42-
%struct.rc_base.5 = type { i32 }
43-
%struct.rust_vec = type { i32, i32, [ 0 x i8 ] }
44-
%class.rust_port = type { i32, %class.rust_kernel*, %struct.rust_task*, i32, %class.ptr_vec, %class.ptr_vec.7, %class.rust_chan*, %class.lock_and_signal }
45-
%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** }
44+
%struct.rust_cond = type { i8 }
45+
%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* }
46+
%struct.rust_obstack_chunk = type { %struct.rust_obstack_chunk*, i32, i32, i32, [0 x i8] }
47+
%struct.rust_scheduler = type { %class.rust_thread, i32, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, i32, %class.lock_and_signal, i32, %struct._opaque_pthread_attr_t, %struct.rust_env*, %class.context }
48+
%struct.rust_shape_tables = type { i8*, i8* }
49+
%struct.rust_task = type { %struct.rust_task_user, i32, %class.context, %struct.rust_vec*, i32, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, %class.timer, i32*, %class.array_list, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, i8, i8, i8, %class.lock_and_signal, %class.hash_map, %class.rust_obstack, %"class.std::map", i32, %"class.debug::task_debug_info" }
50+
%struct.rust_task_user = type { i32, i32, %struct.chan_handle, i32 }
4651
%struct.rust_token = type opaque
47-
%class.ptr_vec.7 = type { %struct.rust_task*, i32, i32, %class.rust_chan** }
48-
%class.rust_chan = type { i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i32, %class.circular_buffer }
49-
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
52+
%struct.rust_vec = type { i32, i32, [0 x i8] }
53+
%"struct.std::_Rb_tree<void *, std::pair<void *const, const type_desc *>, std::_Select1st<std::pair<void *const, const type_desc *> >, std::less<void *>, std::allocator<std::pair<void *const, const type_desc *> > >::_Rb_tree_impl" = type { %struct.rust_cond, %"struct.std::_Rb_tree_node_base", i32 }
54+
%"struct.std::_Rb_tree_node_base" = type { i32, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"* }
55+
%struct.type_desc = type { %struct.type_desc**, i32, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i8*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] }
5056

51-
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
52-
@.str1 = private unnamed_addr constant [15 x i8] c"intrinsics.cpp\00", align 1
57+
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00"
58+
@.str1 = private unnamed_addr constant [15 x i8] c"intrinsics.cpp\00"
5359

54-
define linkonce_odr void @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %v) nounwind {
55-
entry:
56-
%ptr1 = load %struct.rust_vec** %v, align 4, !tbaa !0
57-
%fill1 = getelementptr inbounds %struct.rust_vec* %ptr1, i32 0, i32 0
58-
%tmp2 = load i32* %fill1, align 4, !tbaa !0
59-
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
60-
%tmp20 = load i32* %size, align 4, !tbaa !0
61-
%div = udiv i32 %tmp2, %tmp20
62-
store i32 %div, i32* %retptr, align 4, !tbaa !0
60+
define void @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
61+
%1 = load %struct.rust_vec** %vp, align 4
62+
%2 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 0
63+
%3 = load i32* %2, align 4
64+
%4 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
65+
%5 = load i32* %4, align 4
66+
%6 = udiv i32 %3, %5
67+
store i32 %6, i32* %retptr, align 4
6368
ret void
6469
}
6570

66-
define linkonce_odr void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind {
67-
entry:
68-
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
69-
%tmp1 = load i32* %size, align 4, !tbaa !0
70-
%mul = mul i32 %tmp1, %count
71-
%arrayidx = getelementptr inbounds i8* %ptr, i32 %mul
72-
store i8* %arrayidx, i8** %retptr, align 4, !tbaa !3
71+
define void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind {
72+
%1 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
73+
%2 = load i32* %1, align 4
74+
%3 = mul i32 %2, %count
75+
%4 = getelementptr inbounds i8* %ptr, i32 %3
76+
store i8* %4, i8** %retptr, align 4
7377
ret void
7478
}
7579

76-
define linkonce_odr void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
77-
entry:
78-
%size = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
79-
%tmp1 = load i32* %size, align 4, !tbaa !0
80-
%size3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
81-
%tmp4 = load i32* %size3, align 4, !tbaa !0
82-
%cmp = icmp eq i32 %tmp1, %tmp4
83-
br i1 %cmp, label %if.end, label %if.then
80+
define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
81+
%1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
82+
%2 = load i32* %1, align 4
83+
%3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
84+
%4 = load i32* %3, align 4
85+
%5 = icmp eq i32 %2, %4
86+
br i1 %5, label %7, label %6
8487

8588
if.then: ; preds = %entry
8689
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8]* @.str1, i32 0, i32 0), i32 45)
8790
br label %return
8891

89-
if.end: ; preds = %entry
90-
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %tmp1, i32 1, i1 false)
91-
br label %return
92+
; <label>:7 ; preds = %0
93+
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %2, i32 1, i1 false)
94+
br label %8
9295

93-
return: ; preds = %if.end, %if.then
96+
; <label>:8 ; preds = %7, %6
9497
ret void
9598
}
9699

97100
declare void @upcall_fail(i8*, i8*, i32)
98101

99102
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
100103

101-
define linkonce_odr void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
102-
entry:
103-
store i8* %valptr, i8** %retptr, align 4, !tbaa !3
104+
define void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
105+
store i8* %valptr, i8** %retptr, align 4
104106
ret void
105107
}
106108

@@ -113,7 +115,8 @@ entry:
113115

114116
declare void @port_recv(i32*, %class.rust_port*)
115117

116-
!0 = metadata !{metadata !"long", metadata !1}
117-
!1 = metadata !{metadata !"omnipotent char", metadata !2}
118-
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
119-
!3 = metadata !{metadata !"any pointer", metadata !1}
118+
define void @rust_intrinsic_get_type_desc(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
119+
%ty.c = bitcast %struct.type_desc* %ty to i8*
120+
store i8* %ty.c, i8** %retptr, align 4
121+
ret void
122+
}

trunk/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ leak(void *thing) {
9292
}
9393

9494
extern "C" CDECL intptr_t
95-
refcount(type_desc *t, intptr_t *v) {
95+
refcount(intptr_t *v) {
9696
// Passed-in value has refcount 1 too high
9797
// because it was ref'ed while making the call.
9898
return (*v) - 1;
@@ -109,11 +109,6 @@ unsupervise() {
109109
task->unsupervise();
110110
}
111111

112-
extern "C" CDECL type_desc*
113-
get_type_desc(void *unused_task, type_desc* t) {
114-
return t;
115-
}
116-
117112
extern "C" CDECL void
118113
vec_reserve_shared(type_desc* ty, rust_vec** vp,
119114
size_t n_elts) {

trunk/src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ vec_from_buf_shared
6262
task_sleep
6363
task_yield
6464
task_join
65-
get_type_desc
6665
unsupervise
6766
upcall_alloc_c_stack
6867
upcall_call_c_stack

trunk/src/test/run-pass/unique-copy-box.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std;
2-
import std::sys::rustrt::refcount;
2+
import std::sys::refcount;
33

44
fn main() unsafe {
55
let i = ~@1;

0 commit comments

Comments
 (0)