@@ -79,9 +79,6 @@ struct Mutex {
7979 queue : VecDeque < ThreadId > ,
8080 /// Mutex clock. This tracks the moment of the last unlock.
8181 clock : VClock ,
82-
83- /// Additional data that can be set by shim implementations.
84- data : Option < Box < dyn Any > > ,
8582}
8683
8784declare_id ! ( RwLockId ) ;
@@ -118,9 +115,6 @@ struct RwLock {
118115 /// locks.
119116 /// This is only relevant when there is an active reader.
120117 clock_current_readers : VClock ,
121-
122- /// Additional data that can be set by shim implementations.
123- data : Option < Box < dyn Any > > ,
124118}
125119
126120declare_id ! ( CondvarId ) ;
@@ -290,56 +284,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
290284 & mut self ,
291285 lock : & MPlaceTy < ' tcx > ,
292286 offset : u64 ,
293- initialize_data : impl for < ' a > FnOnce (
294- & ' a mut MiriInterpCx < ' tcx > ,
295- ) -> InterpResult < ' tcx , Option < Box < dyn Any > > > ,
296287 ) -> InterpResult < ' tcx , MutexId > {
297288 let this = self . eval_context_mut ( ) ;
298289 this. get_or_create_id (
299290 lock,
300291 offset,
301292 |ecx| & mut ecx. machine . sync . mutexes ,
302- |ecx| initialize_data ( ecx ) . map ( |data| Mutex { data , .. Default :: default ( ) } ) ,
293+ |_ecx| interp_ok ( Mutex :: default ( ) ) ,
303294 ) ?
304295 . ok_or_else ( || err_ub_format ! ( "mutex has invalid ID" ) )
305296 . into ( )
306297 }
307298
308- /// Retrieve the additional data stored for a mutex.
309- fn mutex_get_data < ' a , T : ' static > ( & ' a mut self , id : MutexId ) -> Option < & ' a T >
310- where
311- ' tcx : ' a ,
312- {
313- let this = self . eval_context_ref ( ) ;
314- this. machine . sync . mutexes [ id] . data . as_deref ( ) . and_then ( |p| p. downcast_ref :: < T > ( ) )
315- }
316-
317- fn rwlock_get_or_create_id (
318- & mut self ,
319- lock : & MPlaceTy < ' tcx > ,
320- offset : u64 ,
321- initialize_data : impl for < ' a > FnOnce (
322- & ' a mut MiriInterpCx < ' tcx > ,
323- ) -> InterpResult < ' tcx , Option < Box < dyn Any > > > ,
324- ) -> InterpResult < ' tcx , RwLockId > {
299+ /// Eagerly create and initialize a new rwlock.
300+ fn rwlock_create ( & mut self ) -> RwLockId {
325301 let this = self . eval_context_mut ( ) ;
326- this. get_or_create_id (
327- lock,
328- offset,
329- |ecx| & mut ecx. machine . sync . rwlocks ,
330- |ecx| initialize_data ( ecx) . map ( |data| RwLock { data, ..Default :: default ( ) } ) ,
331- ) ?
332- . ok_or_else ( || err_ub_format ! ( "rwlock has invalid ID" ) )
333- . into ( )
334- }
335-
336- /// Retrieve the additional data stored for a rwlock.
337- fn rwlock_get_data < ' a , T : ' static > ( & ' a mut self , id : RwLockId ) -> Option < & ' a T >
338- where
339- ' tcx : ' a ,
340- {
341- let this = self . eval_context_ref ( ) ;
342- this. machine . sync . rwlocks [ id] . data . as_deref ( ) . and_then ( |p| p. downcast_ref :: < T > ( ) )
302+ this. machine . sync . rwlocks . push ( Default :: default ( ) )
343303 }
344304
345305 /// Eagerly create and initialize a new condvar.
0 commit comments