@@ -3,6 +3,7 @@ use latch::{LatchProbe, SpinLatch};
3
3
use log:: Event :: * ;
4
4
use registry:: { self , WorkerThread } ;
5
5
use std:: any:: Any ;
6
+ use tlv;
6
7
use unwind;
7
8
8
9
use FnContext ;
@@ -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,7 +165,11 @@ 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) ;
172
+
167
173
return ( result_a, result_b) ;
168
174
} else {
169
175
log ! ( PoppedJob {
@@ -183,6 +189,9 @@ where
183
189
}
184
190
}
185
191
192
+ // Restore the TLV since we might have run some jobs overwriting it when waiting for job b.
193
+ tlv:: set ( tlv) ;
194
+
186
195
( result_a, job_b. into_result ( ) )
187
196
} )
188
197
}
@@ -195,7 +204,12 @@ unsafe fn join_recover_from_panic(
195
204
worker_thread : & WorkerThread ,
196
205
job_b_latch : & SpinLatch ,
197
206
err : Box < dyn Any + Send > ,
207
+ tlv : usize ,
198
208
) -> ! {
199
209
worker_thread. wait_until ( job_b_latch) ;
210
+
211
+ // Restore the TLV since we might have run some jobs overwriting it when waiting for job b.
212
+ tlv:: set ( tlv) ;
213
+
200
214
unwind:: resume_unwinding ( err)
201
215
}
0 commit comments