@@ -2,6 +2,7 @@ use crate::job::StackJob;
2
2
use crate :: latch:: { LatchProbe , SpinLatch } ;
3
3
use crate :: log:: Event :: * ;
4
4
use crate :: registry:: { self , WorkerThread } ;
5
+ use crate :: tlv;
5
6
use crate :: unwind;
6
7
use std:: any:: Any ;
7
8
@@ -135,18 +136,19 @@ where
135
136
worker: worker_thread. index( )
136
137
} ) ;
137
138
139
+ let tlv = tlv:: get ( ) ;
138
140
// Create virtual wrapper for task b; this all has to be
139
141
// done here so that the stack frame can keep it all live
140
142
// long enough.
141
- let job_b = StackJob :: new ( call_b ( oper_b) , SpinLatch :: new ( ) ) ;
143
+ let job_b = StackJob :: new ( tlv , call_b ( oper_b) , SpinLatch :: new ( ) ) ;
142
144
let job_b_ref = job_b. as_job_ref ( ) ;
143
145
worker_thread. push ( job_b_ref) ;
144
146
145
147
// Execute task a; hopefully b gets stolen in the meantime.
146
148
let status_a = unwind:: halt_unwinding ( call_a ( oper_a, injected) ) ;
147
149
let result_a = match status_a {
148
150
Ok ( v) => v,
149
- Err ( err) => join_recover_from_panic ( worker_thread, & job_b. latch , err) ,
151
+ Err ( err) => join_recover_from_panic ( worker_thread, & job_b. latch , err, tlv ) ,
150
152
} ;
151
153
152
154
// Now that task A has finished, try to pop job B from the
@@ -163,6 +165,9 @@ where
163
165
log ! ( PoppedRhs {
164
166
worker: worker_thread. index( )
165
167
} ) ;
168
+ // Restore the TLV since we might have run some jobs overwriting it when waiting for job b.
169
+ tlv:: set ( tlv) ;
170
+
166
171
let result_b = job_b. run_inline ( injected) ;
167
172
return ( result_a, result_b) ;
168
173
} else {
@@ -183,6 +188,9 @@ where
183
188
}
184
189
}
185
190
191
+ // Restore the TLV since we might have run some jobs overwriting it when waiting for job b.
192
+ tlv:: set ( tlv) ;
193
+
186
194
( result_a, job_b. into_result ( ) )
187
195
} )
188
196
}
@@ -195,7 +203,12 @@ unsafe fn join_recover_from_panic(
195
203
worker_thread : & WorkerThread ,
196
204
job_b_latch : & SpinLatch ,
197
205
err : Box < dyn Any + Send > ,
206
+ tlv : usize ,
198
207
) -> ! {
199
208
worker_thread. wait_until ( job_b_latch) ;
209
+
210
+ // Restore the TLV since we might have run some jobs overwriting it when waiting for job b.
211
+ tlv:: set ( tlv) ;
212
+
200
213
unwind:: resume_unwinding ( err)
201
214
}
0 commit comments