|
1 |
| -use std::any::Any; |
2 | 1 | use std::collections::VecDeque;
|
3 | 2 | use std::collections::hash_map::Entry;
|
4 | 3 | use std::ops::Not;
|
@@ -129,9 +128,6 @@ struct Condvar {
|
129 | 128 | /// Contains the clock of the last thread to
|
130 | 129 | /// perform a condvar-signal.
|
131 | 130 | clock: VClock,
|
132 |
| - |
133 |
| - /// Additional data that can be set by shim implementations. |
134 |
| - data: Option<Box<dyn Any>>, |
135 | 131 | }
|
136 | 132 |
|
137 | 133 | /// The futex state.
|
@@ -220,32 +216,6 @@ pub(super) trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
220 | 216 | })
|
221 | 217 | }
|
222 | 218 |
|
223 |
| - /// Eagerly creates a Miri sync structure. |
224 |
| - /// |
225 |
| - /// `create_id` will store the index of the sync_structure in the memory pointed to by |
226 |
| - /// `lock_op`, so that future calls to `get_or_create_id` will see it as initialized. |
227 |
| - /// - `lock_op` must hold a pointer to the sync structure. |
228 |
| - /// - `lock_layout` must be the memory layout of the sync structure. |
229 |
| - /// - `offset` must be the offset inside the sync structure where its miri id will be stored. |
230 |
| - /// - `get_objs` is described in `get_or_create_id`. |
231 |
| - /// - `obj` must be the new sync object. |
232 |
| - fn create_id<Id: SyncId + Idx, T>( |
233 |
| - &mut self, |
234 |
| - lock: &MPlaceTy<'tcx>, |
235 |
| - offset: u64, |
236 |
| - get_objs: impl for<'a> Fn(&'a mut MiriInterpCx<'tcx>) -> &'a mut IndexVec<Id, T>, |
237 |
| - obj: T, |
238 |
| - ) -> InterpResult<'tcx, Id> { |
239 |
| - let this = self.eval_context_mut(); |
240 |
| - let offset = Size::from_bytes(offset); |
241 |
| - assert!(lock.layout.size >= offset + this.machine.layouts.u32.size); |
242 |
| - let id_place = lock.offset(offset, this.machine.layouts.u32, this)?; |
243 |
| - |
244 |
| - let new_index = get_objs(this).push(obj); |
245 |
| - this.write_scalar(Scalar::from_u32(new_index.to_u32()), &id_place)?; |
246 |
| - interp_ok(new_index) |
247 |
| - } |
248 |
| - |
249 | 219 | fn condvar_reacquire_mutex(
|
250 | 220 | &mut self,
|
251 | 221 | mutex: MutexId,
|
@@ -303,45 +273,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
303 | 273 | }
|
304 | 274 |
|
305 | 275 | /// Eagerly create and initialize a new condvar.
|
306 |
| - fn condvar_create( |
307 |
| - &mut self, |
308 |
| - condvar: &MPlaceTy<'tcx>, |
309 |
| - offset: u64, |
310 |
| - data: Option<Box<dyn Any>>, |
311 |
| - ) -> InterpResult<'tcx, CondvarId> { |
| 276 | + fn condvar_create(&mut self) -> CondvarId { |
312 | 277 | let this = self.eval_context_mut();
|
313 |
| - this.create_id(condvar, offset, |ecx| &mut ecx.machine.sync.condvars, Condvar { |
314 |
| - data, |
315 |
| - ..Default::default() |
316 |
| - }) |
317 |
| - } |
318 |
| - |
319 |
| - fn condvar_get_or_create_id( |
320 |
| - &mut self, |
321 |
| - lock: &MPlaceTy<'tcx>, |
322 |
| - offset: u64, |
323 |
| - initialize_data: impl for<'a> FnOnce( |
324 |
| - &'a mut MiriInterpCx<'tcx>, |
325 |
| - ) -> InterpResult<'tcx, Option<Box<dyn Any>>>, |
326 |
| - ) -> InterpResult<'tcx, CondvarId> { |
327 |
| - let this = self.eval_context_mut(); |
328 |
| - this.get_or_create_id( |
329 |
| - lock, |
330 |
| - offset, |
331 |
| - |ecx| &mut ecx.machine.sync.condvars, |
332 |
| - |ecx| initialize_data(ecx).map(|data| Condvar { data, ..Default::default() }), |
333 |
| - )? |
334 |
| - .ok_or_else(|| err_ub_format!("condvar has invalid ID")) |
335 |
| - .into() |
336 |
| - } |
337 |
| - |
338 |
| - /// Retrieve the additional data stored for a condvar. |
339 |
| - fn condvar_get_data<'a, T: 'static>(&'a mut self, id: CondvarId) -> Option<&'a T> |
340 |
| - where |
341 |
| - 'tcx: 'a, |
342 |
| - { |
343 |
| - let this = self.eval_context_ref(); |
344 |
| - this.machine.sync.condvars[id].data.as_deref().and_then(|p| p.downcast_ref::<T>()) |
| 278 | + this.machine.sync.condvars.push(Default::default()) |
345 | 279 | }
|
346 | 280 |
|
347 | 281 | #[inline]
|
|
0 commit comments