Skip to content

Commit e37d7f8

Browse files
committed
---
yaml --- r: 1570 b: refs/heads/master c: 10d8b4e h: refs/heads/master v: v3
1 parent 3c31696 commit e37d7f8

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: aeca13894438af8876f88e26a4947b4e7627111d
2+
refs/heads/master: 10d8b4e861faedb734636a80dc4963392f1f82c5

trunk/src/comp/back/x86.rs

+32-15
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,39 @@ fn restore_callee_saves() -> vec[str] {
2525
"popl %ebp");
2626
}
2727

28-
fn load_esp_from_rust_sp() -> vec[str] {
28+
fn load_esp_from_rust_sp_first_arg() -> vec[str] {
2929
ret vec("movl " + wstr(abi.task_field_rust_sp) + "(%ecx), %esp");
3030
}
3131

32-
fn load_esp_from_runtime_sp() -> vec[str] {
32+
fn load_esp_from_runtime_sp_first_arg() -> vec[str] {
3333
ret vec("movl " + wstr(abi.task_field_runtime_sp) + "(%ecx), %esp");
3434
}
3535

36-
fn store_esp_to_rust_sp() -> vec[str] {
36+
fn store_esp_to_rust_sp_first_arg() -> vec[str] {
3737
ret vec("movl %esp, " + wstr(abi.task_field_rust_sp) + "(%ecx)");
3838
}
3939

40-
fn store_esp_to_runtime_sp() -> vec[str] {
40+
fn store_esp_to_runtime_sp_first_arg() -> vec[str] {
4141
ret vec("movl %esp, " + wstr(abi.task_field_runtime_sp) + "(%ecx)");
4242
}
4343

44+
fn load_esp_from_rust_sp_second_arg() -> vec[str] {
45+
ret vec("movl " + wstr(abi.task_field_rust_sp) + "(%edx), %esp");
46+
}
47+
48+
fn load_esp_from_runtime_sp_second_arg() -> vec[str] {
49+
ret vec("movl " + wstr(abi.task_field_runtime_sp) + "(%edx), %esp");
50+
}
51+
52+
fn store_esp_to_rust_sp_second_arg() -> vec[str] {
53+
ret vec("movl %esp, " + wstr(abi.task_field_rust_sp) + "(%edx)");
54+
}
55+
56+
fn store_esp_to_runtime_sp_second_arg() -> vec[str] {
57+
ret vec("movl %esp, " + wstr(abi.task_field_runtime_sp) + "(%edx)");
58+
}
59+
60+
4461
/*
4562
* This is a bit of glue-code. It should be emitted once per
4663
* compilation unit.
@@ -61,8 +78,8 @@ fn store_esp_to_runtime_sp() -> vec[str] {
6178
fn rust_activate_glue() -> vec[str] {
6279
ret vec("movl 4(%esp), %ecx # ecx = rust_task")
6380
+ save_callee_saves()
64-
+ store_esp_to_runtime_sp()
65-
+ load_esp_from_rust_sp()
81+
+ store_esp_to_runtime_sp_first_arg()
82+
+ load_esp_from_rust_sp_first_arg()
6683

6784
/*
6885
* There are two paths we can arrive at this code from:
@@ -154,10 +171,10 @@ fn rust_activate_glue() -> vec[str] {
154171

155172
fn rust_yield_glue() -> vec[str] {
156173
ret vec("movl 0(%esp), %ecx # ecx = rust_task")
157-
+ load_esp_from_rust_sp()
174+
+ load_esp_from_rust_sp_first_arg()
158175
+ save_callee_saves()
159-
+ store_esp_to_rust_sp()
160-
+ load_esp_from_runtime_sp()
176+
+ store_esp_to_rust_sp_first_arg()
177+
+ load_esp_from_runtime_sp_first_arg()
161178
+ restore_callee_saves()
162179
+ vec("ret");
163180
}
@@ -192,19 +209,19 @@ fn upcall_glue(int n_args) -> vec[str] {
192209

193210
+ vec("movl %esp, %ebp # ebp = rust_sp")
194211

195-
+ store_esp_to_rust_sp()
196-
+ load_esp_from_runtime_sp()
212+
+ store_esp_to_rust_sp_second_arg()
213+
+ load_esp_from_runtime_sp_second_arg()
197214

198215
+ vec("subl $" + wstr(n_args + 1) + ", %esp # esp -= args",
199216
"andl $~0xf, %esp # align esp down")
200217

201218
+ _vec.init_fn[str](carg, (n_args + 1) as uint)
202219

203-
+ vec("movl %edx, %edi # save task from ecx to edi",
204-
"call *%ecx # call *%edx",
205-
"movl %edi, %edx # restore edi-saved task to ecx")
220+
+ vec("movl %edx, %edi # save task from edx to edi",
221+
"call *%ecx # call *%ecx",
222+
"movl %edi, %edx # restore edi-saved task to edx")
206223

207-
+ load_esp_from_rust_sp()
224+
+ load_esp_from_rust_sp_second_arg()
208225
+ restore_callee_saves()
209226
+ vec("ret");
210227

0 commit comments

Comments
 (0)