@@ -198,6 +198,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
198
198
void call_on_rust_stack (void *args, void *fn_ptr);
199
199
};
200
200
201
+ // This stuff is on the stack-switching fast path
202
+
201
203
// Get a rough approximation of the current stack pointer
202
204
extern " C" uintptr_t get_sp ();
203
205
@@ -226,7 +228,8 @@ sanitize_next_sp(uintptr_t next_sp) {
226
228
227
229
inline void
228
230
rust_task::call_on_c_stack (void *args, void *fn_ptr) {
229
- I (thread, on_rust_stack ());
231
+ // Too expensive to check
232
+ // I(thread, on_rust_stack());
230
233
231
234
next_rust_sp = get_sp ();
232
235
@@ -252,7 +255,8 @@ rust_task::call_on_c_stack(void *args, void *fn_ptr) {
252
255
253
256
inline void
254
257
rust_task::call_on_rust_stack (void *args, void *fn_ptr) {
255
- I (thread, !on_rust_stack ());
258
+ // Too expensive to check
259
+ // I(thread, !on_rust_stack());
256
260
I (thread, next_rust_sp);
257
261
258
262
next_c_sp = get_sp ();
@@ -264,43 +268,14 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
264
268
265
269
inline void
266
270
rust_task::return_c_stack () {
267
- I (thread, on_rust_stack ());
271
+ // Too expensive to check
272
+ // I(thread, on_rust_stack());
268
273
I (thread, c_stack != NULL );
269
274
thread->return_c_stack (c_stack);
270
275
c_stack = NULL ;
271
276
next_c_sp = 0 ;
272
277
}
273
278
274
- inline bool
275
- sp_in_stk_seg (uintptr_t sp, stk_seg *stk) {
276
- // Not positive these bounds for sp are correct. I think that the first
277
- // possible value for esp on a new stack is stk->end, which points to the
278
- // address before the first value to be pushed onto a new stack. The last
279
- // possible address we can push data to is stk->data. Regardless, there's
280
- // so much slop at either end that we should never hit one of these
281
- // boundaries.
282
- return (uintptr_t )stk->data <= sp && sp <= stk->end ;
283
- }
284
-
285
- /*
286
- Returns true if we're currently running on the Rust stack
287
- */
288
- inline bool
289
- rust_task::on_rust_stack () {
290
- uintptr_t sp = get_sp ();
291
- bool in_first_segment = sp_in_stk_seg (sp, stk);
292
- if (in_first_segment) {
293
- return true ;
294
- } else if (stk->next != NULL ) {
295
- // This happens only when calling the upcall to delete
296
- // a stack segment
297
- bool in_second_segment = sp_in_stk_seg (sp, stk->next );
298
- return in_second_segment;
299
- } else {
300
- return false ;
301
- }
302
- }
303
-
304
279
//
305
280
// Local Variables:
306
281
// mode: C++
0 commit comments