Skip to content

Commit 107d7fe

Browse files
committed
---
yaml --- r: 2792 b: refs/heads/master c: 8e945dc h: refs/heads/master v: v3
1 parent eb0dbb3 commit 107d7fe

File tree

5 files changed

+11
-262
lines changed

5 files changed

+11
-262
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: 89e5f6c8830b2842165e86112b0ab9b53c15d621
2+
refs/heads/master: 8e945dcd817a07d2d952acf431a6bc12a4246061

trunk/src/comp/back/abi.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ const int closure_elt_ty_params = 3;
6969

7070
const int worst_case_glue_call_args = 7;
7171

72-
const int n_native_glues = 8;
73-
74-
tag native_glue_type {
75-
ngt_rust;
76-
ngt_pure_rust;
77-
ngt_cdecl;
78-
}
79-
8072
fn memcpy_glue_name() -> str {
8173
ret "rust_memcpy_glue";
8274
}
@@ -89,16 +81,6 @@ fn vec_append_glue_name() -> str {
8981
ret "rust_vec_append_glue";
9082
}
9183

92-
fn native_glue_name(int n, native_glue_type ngt) -> str {
93-
auto prefix;
94-
alt (ngt) {
95-
case (ngt_rust) { prefix = "rust_native_rust_"; }
96-
case (ngt_pure_rust) { prefix = "rust_native_pure_rust_"; }
97-
case (ngt_cdecl) { prefix = "rust_native_cdecl_"; }
98-
}
99-
ret prefix + util::common::istr(n);
100-
}
101-
10284
fn yield_glue_name() -> str {
10385
ret "rust_yield_glue";
10486
}

trunk/src/comp/back/x86.rs

Lines changed: 1 addition & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -5,193 +5,8 @@ import std::vec;
55
import std::os::target_os;
66
import util::common::istr;
77

8-
const int wordsz = 4;
9-
10-
fn wstr(int i) -> str {
11-
ret istr(i * wordsz);
12-
}
13-
14-
fn start() -> vec[str] {
15-
ret [".cfi_startproc"];
16-
}
17-
18-
fn end() -> vec[str] {
19-
ret [".cfi_endproc"];
20-
}
21-
22-
fn save_callee_saves() -> vec[str] {
23-
ret ["pushl %ebp",
24-
"pushl %edi",
25-
"pushl %esi",
26-
"pushl %ebx"];
27-
}
28-
29-
fn save_callee_saves_with_cfi() -> vec[str] {
30-
auto offset = 8;
31-
auto t;
32-
t = ["pushl %ebp"];
33-
t += [".cfi_def_cfa_offset " + istr(offset)];
34-
t += [".cfi_offset %ebp, -" + istr(offset)];
35-
36-
t += ["pushl %edi"];
37-
offset += 4;
38-
t += [".cfi_def_cfa_offset " + istr(offset)];
39-
40-
t += ["pushl %esi"];
41-
offset += 4;
42-
t += [".cfi_def_cfa_offset " + istr(offset)];
43-
44-
t += ["pushl %ebx"];
45-
offset += 4;
46-
t += [".cfi_def_cfa_offset " + istr(offset)];
47-
ret t;
48-
}
49-
50-
fn restore_callee_saves() -> vec[str] {
51-
ret ["popl %ebx",
52-
"popl %esi",
53-
"popl %edi",
54-
"popl %ebp"];
55-
}
56-
57-
fn load_esp_from_rust_sp_first_arg() -> vec[str] {
58-
ret ["movl " + wstr(abi::task_field_rust_sp) + "(%ecx), %esp"];
59-
}
60-
61-
fn load_esp_from_runtime_sp_first_arg() -> vec[str] {
62-
ret ["movl " + wstr(abi::task_field_runtime_sp) + "(%ecx), %esp"];
63-
}
64-
65-
fn store_esp_to_rust_sp_first_arg() -> vec[str] {
66-
ret ["movl %esp, " + wstr(abi::task_field_rust_sp) + "(%ecx)"];
67-
}
68-
69-
fn store_esp_to_runtime_sp_first_arg() -> vec[str] {
70-
ret ["movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%ecx)"];
71-
}
72-
73-
fn load_esp_from_rust_sp_second_arg() -> vec[str] {
74-
ret ["movl " + wstr(abi::task_field_rust_sp) + "(%edx), %esp"];
75-
}
76-
77-
fn load_esp_from_runtime_sp_second_arg() -> vec[str] {
78-
ret ["movl " + wstr(abi::task_field_runtime_sp) + "(%edx), %esp"];
79-
}
80-
81-
fn store_esp_to_rust_sp_second_arg() -> vec[str] {
82-
ret ["movl %esp, " + wstr(abi::task_field_rust_sp) + "(%edx)"];
83-
}
84-
85-
fn store_esp_to_runtime_sp_second_arg() -> vec[str] {
86-
ret ["movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%edx)"];
87-
}
88-
89-
fn native_glue(int n_args, abi::native_glue_type ngt) -> vec[str] {
90-
91-
let bool pass_task;
92-
alt (ngt) {
93-
case (abi::ngt_rust) { pass_task = true; }
94-
case (abi::ngt_pure_rust) { pass_task = true; }
95-
case (abi::ngt_cdecl) { pass_task = false; }
96-
}
97-
98-
/*
99-
* 0, 4, 8, 12 are callee-saves
100-
* 16 is retpc
101-
* 20 .. (5+i) * 4 are args
102-
*
103-
* ecx is taskptr
104-
* edx is callee
105-
*
106-
*/
107-
108-
fn copy_arg(bool pass_task, uint i) -> str {
109-
if (i == 0u && pass_task) {
110-
ret "movl %edx, (%esp)";
111-
}
112-
auto dst_off = wstr(0 + (i as int));
113-
auto src_off;
114-
if (pass_task) {
115-
src_off = wstr(4 + (i as int));
116-
} else {
117-
src_off = wstr(5 + (i as int));
118-
}
119-
auto m = ["movl " + src_off + "(%ebp),%eax",
120-
"movl %eax," + dst_off + "(%esp)"];
121-
ret str::connect(m, "\n\t");
122-
}
123-
124-
auto carg = bind copy_arg(pass_task, _);
125-
126-
ret
127-
start()
128-
+ save_callee_saves_with_cfi()
129-
130-
+ ["movl %esp, %ebp # ebp = rust_sp"]
131-
+ [".cfi_def_cfa_register %ebp"]
132-
133-
+ store_esp_to_rust_sp_second_arg()
134-
+ load_esp_from_runtime_sp_second_arg()
135-
136-
+ ["subl $" + wstr(n_args) + ", %esp # esp -= args",
137-
"andl $~0xf, %esp # align esp down"]
138-
139-
+ vec::init_fn[str](carg, (n_args) as uint)
140-
141-
+ ["movl %edx, %edi # save task from edx to edi",
142-
"call *%ecx # call *%ecx",
143-
"movl %edi, %edx # restore edi-saved task to edx"]
144-
145-
+ load_esp_from_rust_sp_second_arg()
146-
+ restore_callee_saves()
147-
+ ["ret"]
148-
+ end();
149-
150-
}
151-
152-
153-
fn decl_glue(int align, str prefix, str name, vec[str] insns) -> str {
154-
auto sym = prefix + name;
155-
ret "\t.globl " + sym + "\n" +
156-
"\t.balign " + istr(align) + "\n" +
157-
sym + ":\n" +
158-
"\t" + str::connect(insns, "\n\t");
159-
}
160-
161-
162-
fn decl_native_glue(int align, str prefix, abi::native_glue_type ngt, uint n)
163-
-> str {
164-
let int i = n as int;
165-
ret decl_glue(align, prefix,
166-
abi::native_glue_name(i, ngt),
167-
native_glue(i, ngt));
168-
}
169-
170-
fn get_symbol_prefix() -> str {
171-
if (str::eq(target_os(), "macos") ||
172-
str::eq(target_os(), "win32")) {
173-
ret "_";
174-
} else {
175-
ret "";
176-
}
177-
}
178-
1798
fn get_module_asm() -> str {
180-
auto align = 4;
181-
182-
auto prefix = get_symbol_prefix();
183-
184-
let vec[str] glues =
185-
[]
186-
+ vec::init_fn[str](bind decl_native_glue(align, prefix,
187-
abi::ngt_rust, _), (abi::n_native_glues + 1) as uint)
188-
+ vec::init_fn[str](bind decl_native_glue(align, prefix,
189-
abi::ngt_pure_rust, _), (abi::n_native_glues + 1) as uint)
190-
+ vec::init_fn[str](bind decl_native_glue(align, prefix,
191-
abi::ngt_cdecl, _), (abi::n_native_glues + 1) as uint);
192-
193-
194-
ret str::connect(glues, "\n\n");
9+
ret "";
19510
}
19611

19712
fn get_meta_sect_name() -> str {

trunk/src/comp/middle/trans.rs

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ state obj namegen(mutable int i) {
5656
type derived_tydesc_info = rec(ValueRef lltydesc, bool escapes);
5757

5858
type glue_fns = rec(ValueRef yield_glue,
59-
vec[ValueRef] native_glues_rust,
60-
vec[ValueRef] native_glues_pure_rust,
61-
vec[ValueRef] native_glues_cdecl,
6259
ValueRef no_op_type_glue,
6360
ValueRef vec_append_glue);
6461

@@ -80,10 +77,7 @@ type tydesc_info = rec(ty::t ty,
8077
* please make sure you link it in at runtime". This could be a reference to
8178
* C code found in a C library, or rust code found in a rust crate.
8279
*
83-
* A "native" is a combination of an extern that references C code, plus a
84-
* glue-code stub that "looks like" a rust function, emitted here, plus a
85-
* generic N-ary bit of asm glue (found over in back/x86::rs) that performs a
86-
* control transfer into C from rust. Natives may be normal C library code.
80+
* A "native" is an extern that references C code. Called with cdecl.
8781
*
8882
* An upcall is a native call generated by the compiler (not corresponding to
8983
* any user-written call in the code) into librustrt, to perform some helper
@@ -1048,32 +1042,6 @@ fn decl_glue(ModuleRef llmod, type_names tn, &str s) -> ValueRef {
10481042
ret decl_cdecl_fn(llmod, s, T_fn([T_taskptr(tn)], T_void()));
10491043
}
10501044

1051-
fn decl_native_glue(ModuleRef llmod, &type_names tn,
1052-
abi::native_glue_type ngt, uint _n) -> ValueRef {
1053-
let bool pass_task;
1054-
alt (ngt) {
1055-
case (abi::ngt_rust) { pass_task = true; }
1056-
case (abi::ngt_pure_rust) { pass_task = true; }
1057-
case (abi::ngt_cdecl) { pass_task = false; }
1058-
}
1059-
1060-
// It doesn't actually matter what type we come up with here, at the
1061-
// moment, as we cast the native function pointers to int before passing
1062-
// them to the indirect native-invocation glue. But eventually we'd like
1063-
// to call them directly, once we have a calling convention worked out.
1064-
let int n = _n as int;
1065-
let str s = abi::native_glue_name(n, ngt);
1066-
let vec[TypeRef] args = [T_int()]; // callee
1067-
1068-
if (!pass_task) {
1069-
args += [T_int()]; // taskptr, will not be passed
1070-
}
1071-
1072-
args += vec::init_elt[TypeRef](T_int(), n as uint);
1073-
1074-
ret decl_fastcall_fn(llmod, s, T_fn(args, T_int()));
1075-
}
1076-
10771045
fn get_extern_fn(&hashmap[str, ValueRef] externs,
10781046
ModuleRef llmod, &str name,
10791047
uint cc, TypeRef ty) -> ValueRef {
@@ -1108,27 +1076,16 @@ fn trans_native_call(&builder b, @glue_fns glues, ValueRef lltaskptr,
11081076
&hashmap[str, ValueRef] externs,
11091077
&type_names tn, ModuleRef llmod, &str name,
11101078
bool pass_task, &vec[ValueRef] args) -> ValueRef {
1079+
11111080
let int n = (vec::len[ValueRef](args) as int);
11121081
let ValueRef llnative = get_simple_extern_fn(externs, llmod, name, n);
1113-
llnative = llvm::LLVMConstPointerCast(llnative, T_int());
1114-
1115-
let ValueRef llglue;
1116-
if (pass_task) {
1117-
llglue = glues.native_glues_rust.(n);
1118-
} else {
1119-
llglue = glues.native_glues_cdecl.(n);
1120-
}
1121-
let vec[ValueRef] call_args = [llnative];
1122-
1123-
if (!pass_task) {
1124-
call_args += [lltaskptr];
1125-
}
11261082

1083+
let vec[ValueRef] call_args = [];
11271084
for (ValueRef a in args) {
11281085
call_args += [b.ZExtOrBitCast(a, T_int())];
11291086
}
11301087

1131-
ret b.FastCall(llglue, call_args);
1088+
ret b.Call(llnative, call_args);
11321089
}
11331090

11341091
fn trans_non_gc_free(&@block_ctxt cx, ValueRef v) -> result {
@@ -8030,16 +7987,6 @@ fn trans_vec_append_glue(@local_ctxt cx, &ast::span sp) {
80307987

80317988
fn make_glues(ModuleRef llmod, &type_names tn) -> @glue_fns {
80327989
ret @rec(yield_glue = decl_glue(llmod, tn, abi::yield_glue_name()),
8033-
8034-
native_glues_rust =
8035-
vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
8036-
abi::ngt_rust, _), abi::n_native_glues + 1 as uint),
8037-
native_glues_pure_rust =
8038-
vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
8039-
abi::ngt_pure_rust, _), abi::n_native_glues + 1 as uint),
8040-
native_glues_cdecl =
8041-
vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
8042-
abi::ngt_cdecl, _), abi::n_native_glues + 1 as uint),
80437990
no_op_type_glue = decl_no_op_type_glue(llmod, tn),
80447991
vec_append_glue = make_vec_append_glue(llmod, tn));
80457992
}

trunk/src/test/run-pass/lib-task.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// xfail-stage0
2+
// xfail-stage1
3+
// xfail-stage2
4+
// xfail-stage3
5+
16
use std;
27
import std::_task;
38

0 commit comments

Comments
 (0)