Skip to content

Commit cc0461d

Browse files
committed
---
yaml --- r: 2764 b: refs/heads/master c: ac836dd h: refs/heads/master v: v3
1 parent fe2aaa4 commit cc0461d

File tree

8 files changed

+53
-58
lines changed

8 files changed

+53
-58
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: b1292580b95ea4a2ab22682ff04a91004c44cd06
2+
refs/heads/master: ac836dd79c2d7c631ca601dc468de13cb5c785da

trunk/mk/rt.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUNTIME_CS := rt/sync/timer.cpp \
3333

3434
RUNTIME_LL := rt/new_exit.ll
3535

36-
RUNTIME_S := rt/activate_glue.s
36+
RUNTIME_S := rt/activate_glue.s rt/yield_glue.s
3737

3838
RUNTIME_HDR := rt/globals.h \
3939
rt/rust.h \

trunk/src/comp/back/x86.rs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -86,43 +86,6 @@ fn store_esp_to_runtime_sp_second_arg() -> vec[str] {
8686
ret ["movl %esp, " + wstr(abi::task_field_runtime_sp) + "(%edx)"];
8787
}
8888

89-
90-
/* More glue code, this time the 'bottom half' of yielding.
91-
*
92-
* We arrived here because an native call decided to deschedule the
93-
* running task. So the native call's return address got patched to the
94-
* first instruction of this glue code.
95-
*
96-
* When the native call does 'ret' it will come here, and its esp will be
97-
* pointing to the last argument pushed on the C stack before making
98-
* the native call: the 0th argument to the native call, which is always
99-
* the task ptr performing the native call. That's where we take over.
100-
*
101-
* Our goal is to complete the descheduling
102-
*
103-
* - Switch over to the task stack temporarily.
104-
*
105-
* - Save the task's callee-saves onto the task stack.
106-
* (the task is now 'descheduled', safe to set aside)
107-
*
108-
* - Switch *back* to the C stack.
109-
*
110-
* - Restore the C-stack callee-saves.
111-
*
112-
* - Return to the caller on the C stack that activated the task.
113-
*
114-
*/
115-
116-
fn rust_yield_glue() -> vec[str] {
117-
ret ["movl 0(%esp), %ecx # ecx = rust_task"]
118-
+ load_esp_from_rust_sp_first_arg()
119-
+ save_callee_saves()
120-
+ store_esp_to_rust_sp_first_arg()
121-
+ load_esp_from_runtime_sp_first_arg()
122-
+ restore_callee_saves()
123-
+ ["ret"];
124-
}
125-
12689
fn native_glue(int n_args, abi::native_glue_type ngt) -> vec[str] {
12790

12891
let bool pass_task;
@@ -218,11 +181,8 @@ fn get_module_asm() -> str {
218181

219182
auto prefix = get_symbol_prefix();
220183

221-
auto glues =
222-
[decl_glue(align, prefix,
223-
abi::yield_glue_name(),
224-
rust_yield_glue())]
225-
184+
let vec[str] glues =
185+
[]
226186
+ vec::init_fn[str](bind decl_native_glue(align, prefix,
227187
abi::ngt_rust, _), (abi::n_native_glues + 1) as uint)
228188
+ vec::init_fn[str](bind decl_native_glue(align, prefix,

trunk/src/comp/middle/trans.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7660,9 +7660,6 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
76607660

76617661
let ValueRef crate_addr = p2i(crate_ptr);
76627662

7663-
let ValueRef yield_glue_off =
7664-
llvm::LLVMConstSub(p2i(glues.yield_glue), crate_addr);
7665-
76667663
let ValueRef crate_val =
76677664
C_struct([C_null(T_int()), // ptrdiff_t image_base_off
76687665
p2i(crate_ptr), // uintptr_t self_addr
@@ -7671,10 +7668,10 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
76717668
C_null(T_int()), // ptrdiff_t debug_info_off
76727669
C_null(T_int()), // size_t debug_info_sz
76737670
C_null(T_int()), // size_t pad
7674-
yield_glue_off, // size_t yield_glue_off
76757671
C_null(T_int()), // size_t pad
7676-
C_null(T_int()), // size_t gc_glue_off
76777672
C_null(T_int()), // size_t pad2
7673+
C_null(T_int()), // size_t gc_glue_off
7674+
C_null(T_int()), // size_t pad3
76787675
C_null(T_int()), // int n_rust_syms
76797676
C_null(T_int()), // int n_c_syms
76807677
C_null(T_int()) // int n_libs

trunk/src/rt/rust_crate.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ rust_crate::get_gc_glue() const {
1616
return ((uintptr_t)this + gc_glue_off);
1717
}
1818

19-
uintptr_t
20-
rust_crate::get_yield_glue() const {
21-
return ((uintptr_t)this + yield_glue_off);
22-
}
23-
2419
rust_crate::mem_area::mem_area(rust_dom *dom, uintptr_t pos, size_t sz)
2520
: dom(dom),
2621
base(pos),

trunk/src/rt/rust_internal.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ class rust_crate {
232232
size_t debug_info_sz; // Size of .debug_info.
233233

234234
ptrdiff_t activate_glue_off;
235-
ptrdiff_t yield_glue_off;
236235
ptrdiff_t pad;
237-
ptrdiff_t gc_glue_off;
238236
ptrdiff_t pad2;
237+
ptrdiff_t gc_glue_off;
238+
ptrdiff_t pad3;
239239

240240
public:
241241

@@ -247,7 +247,6 @@ class rust_crate {
247247

248248
uintptr_t get_image_base() const;
249249
ptrdiff_t get_relocation_diff() const;
250-
uintptr_t get_yield_glue() const;
251250
uintptr_t get_gc_glue() const;
252251

253252
struct mem_area

trunk/src/rt/rust_task.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,14 @@ rust_task::yield(size_t nargs) {
317317
yield(nargs, 0);
318318
}
319319

320+
extern "C" void new_rust_yield_glue(void) asm("new_rust_yield_glue");
321+
320322
void
321323
rust_task::yield(size_t nargs, size_t time_in_us) {
322324
LOG(this, task, "task %s @0x%" PRIxPTR " yielding for %d us",
323325
name, this, time_in_us);
324326
yield_timer.reset(time_in_us);
325-
run_after_return(nargs, dom->root_crate->get_yield_glue());
327+
run_after_return(nargs, (uintptr_t) new_rust_yield_glue);
326328
}
327329

328330
static inline uintptr_t

trunk/src/rt/yield_glue.s

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* More glue code, this time the 'bottom half' of yielding.
2+
*
3+
* We arrived here because an native call decided to deschedule the
4+
* running task. So the native call's return address got patched to the
5+
* first instruction of this glue code.
6+
*
7+
* When the native call does 'ret' it will come here, and its esp will be
8+
* pointing to the last argument pushed on the C stack before making
9+
* the native call: the 0th argument to the native call, which is always
10+
* the task ptr performing the native call. That's where we take over.
11+
*
12+
* Our goal is to complete the descheduling
13+
*
14+
* - Switch over to the task stack temporarily.
15+
*
16+
* - Save the task's callee-saves onto the task stack.
17+
* (the task is now 'descheduled', safe to set aside)
18+
*
19+
* - Switch *back* to the C stack.
20+
*
21+
* - Restore the C-stack callee-saves.
22+
*
23+
* - Return to the caller on the C stack that activated the task.
24+
*
25+
*/
26+
27+
.globl new_rust_yield_glue
28+
.balign 4
29+
new_rust_yield_glue:
30+
movl 0(%esp), %ecx # ecx = rust_task
31+
movl 16(%ecx), %esp
32+
pushl %ebp
33+
pushl %edi
34+
pushl %esi
35+
pushl %ebx
36+
movl %esp, 16(%ecx)
37+
movl 12(%ecx), %esp
38+
popl %ebx
39+
popl %esi
40+
popl %edi
41+
popl %ebp
42+
ret

0 commit comments

Comments
 (0)