@@ -25,22 +25,39 @@ fn restore_callee_saves() -> vec[str] {
25
25
"popl %ebp" ) ;
26
26
}
27
27
28
- fn load_esp_from_rust_sp ( ) -> vec[ str ] {
28
+ fn load_esp_from_rust_sp_first_arg ( ) -> vec[ str ] {
29
29
ret vec ( "movl " + wstr ( abi. task_field_rust_sp ) + "(%ecx), %esp" ) ;
30
30
}
31
31
32
- fn load_esp_from_runtime_sp ( ) -> vec[ str ] {
32
+ fn load_esp_from_runtime_sp_first_arg ( ) -> vec[ str ] {
33
33
ret vec ( "movl " + wstr ( abi. task_field_runtime_sp ) + "(%ecx), %esp" ) ;
34
34
}
35
35
36
- fn store_esp_to_rust_sp ( ) -> vec[ str ] {
36
+ fn store_esp_to_rust_sp_first_arg ( ) -> vec[ str ] {
37
37
ret vec ( "movl %esp, " + wstr ( abi. task_field_rust_sp ) + "(%ecx)" ) ;
38
38
}
39
39
40
- fn store_esp_to_runtime_sp ( ) -> vec[ str ] {
40
+ fn store_esp_to_runtime_sp_first_arg ( ) -> vec[ str ] {
41
41
ret vec ( "movl %esp, " + wstr ( abi. task_field_runtime_sp ) + "(%ecx)" ) ;
42
42
}
43
43
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
+
44
61
/*
45
62
* This is a bit of glue-code. It should be emitted once per
46
63
* compilation unit.
@@ -61,8 +78,8 @@ fn store_esp_to_runtime_sp() -> vec[str] {
61
78
fn rust_activate_glue ( ) -> vec[ str ] {
62
79
ret vec ( "movl 4(%esp), %ecx # ecx = rust_task" )
63
80
+ 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 ( )
66
83
67
84
/*
68
85
* There are two paths we can arrive at this code from:
@@ -154,10 +171,10 @@ fn rust_activate_glue() -> vec[str] {
154
171
155
172
fn rust_yield_glue ( ) -> vec[ str ] {
156
173
ret vec ( "movl 0(%esp), %ecx # ecx = rust_task" )
157
- + load_esp_from_rust_sp ( )
174
+ + load_esp_from_rust_sp_first_arg ( )
158
175
+ 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 ( )
161
178
+ restore_callee_saves ( )
162
179
+ vec ( "ret" ) ;
163
180
}
@@ -192,19 +209,19 @@ fn upcall_glue(int n_args) -> vec[str] {
192
209
193
210
+ vec ( "movl %esp, %ebp # ebp = rust_sp" )
194
211
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 ( )
197
214
198
215
+ vec ( "subl $" + wstr ( n_args + 1 ) + ", %esp # esp -= args" ,
199
216
"andl $~0xf, %esp # align esp down" )
200
217
201
218
+ _vec. init_fn [ str] ( carg, ( n_args + 1 ) as uint )
202
219
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 " )
206
223
207
- + load_esp_from_rust_sp ( )
224
+ + load_esp_from_rust_sp_second_arg ( )
208
225
+ restore_callee_saves ( )
209
226
+ vec ( "ret" ) ;
210
227
0 commit comments