@@ -215,15 +215,6 @@ void MiriGenMCShim::handleThreadFinish(ThreadId thread_id, uint64_t ret_val)
215
215
GenMCDriver::handleThreadFinish (std::move (eLab));
216
216
}
217
217
218
- /* *** Blocking instructions ****/
219
-
220
- void MiriGenMCShim::handleUserBlock (ThreadId thread_id)
221
- {
222
- auto pos = incPos (thread_id);
223
- auto bLab = UserBlockLabel::create (pos);
224
- GenMCDriver::handleBlock (std::move (bLab));
225
- }
226
-
227
218
/* *** Memory access handling ****/
228
219
229
220
[[nodiscard]] auto MiriGenMCShim::handleLoad (ThreadId thread_id, uint64_t address, uint64_t size,
@@ -356,9 +347,6 @@ void MiriGenMCShim::handleUserBlock(ThreadId thread_id)
356
347
case StoreEventType::CompareExchange:
357
348
wLab = std::make_unique<CasWriteLabel>(pos, ord, loc, aSize, type, val);
358
349
break ;
359
- case StoreEventType::MutexUnlockWrite:
360
- wLab = UnlockWriteLabel::create (pos, ord, loc, aSize, AType::Signed, val);
361
- break ;
362
350
default :
363
351
ERROR (" Unsupported Store Event Type" );
364
352
}
@@ -412,94 +400,3 @@ void MiriGenMCShim::handleFree(ThreadId thread_id, uint64_t address, uint64_t si
412
400
auto dLab = std::make_unique<FreeLabel>(pos, addr, size);
413
401
GenMCDriver::handleFree (std::move (dLab));
414
402
}
415
-
416
- /* *** Mutex handling ****/
417
-
418
- auto MiriGenMCShim::handleMutexLock (ThreadId thread_id, uint64_t address, uint64_t size)
419
- -> MutexLockResult
420
- {
421
- // TODO GENMC: this needs to be identical even in multithreading
422
- ModuleID::ID annot_id;
423
- if (annotation_id.contains (address)) {
424
- annot_id = annotation_id.at (address);
425
- } else {
426
- annot_id = annotation_id_counter++;
427
- annotation_id.insert (std::make_pair (address, annot_id));
428
- }
429
- const auto aSize = ASize (size);
430
- auto annot = std::move (Annotation (
431
- AssumeType::Spinloop,
432
- Annotation::ExprVP (NeExpr<AnnotID>::create (
433
- RegisterExpr<AnnotID>::create (aSize.getBits (), annot_id),
434
- ConcreteExpr<AnnotID>::create (aSize.getBits (), SVal (1 )))
435
- .release ())));
436
-
437
- auto &currPos = globalInstructions[thread_id].event ;
438
- // auto rLab = LockCasReadLabel::create(++currPos, address, size);
439
- auto rLab = LockCasReadLabel::create (++currPos, address, size, annot);
440
-
441
- // Mutex starts out unlocked, so we always say the previous value is "unlocked".
442
- auto oldValSetter = [this ](SAddr loc) { this ->handleOldVal (loc, SVal (0 )); };
443
- LoadResult loadResult = GenMCDriver::handleLoad (std::move (rLab), oldValSetter);
444
- if (loadResult.is_error ()) {
445
- --currPos;
446
- return MutexLockResult::fromError (*loadResult.error );
447
- } else if (loadResult.is_read_opt ) {
448
- --currPos;
449
- // TODO GENMC: is_read_opt == Mutex is acquired
450
- // None --> Someone else has lock, this thread will be rescheduled later (currently
451
- // block) 0 --> Got the lock 1 --> Someone else has lock, this thread will
452
- // not be rescheduled later (block on Miri side)
453
- return MutexLockResult (false );
454
- }
455
- // TODO GENMC(QUESTION): is the `isBlocked` even needed?
456
- // if (!loadResult.has_value() || getCurThr().isBlocked())
457
- // return;
458
-
459
- const bool is_lock_acquired = loadResult.value () == SVal (0 );
460
- if (is_lock_acquired) {
461
- auto wLab = LockCasWriteLabel::create (++currPos, address, size);
462
- StoreResult storeResult = GenMCDriver::handleStore (std::move (wLab), oldValSetter);
463
- if (storeResult.is_error ())
464
- return MutexLockResult::fromError (*storeResult.error );
465
-
466
- } else {
467
- auto bLab = LockNotAcqBlockLabel::create (++currPos);
468
- GenMCDriver::handleBlock (std::move (bLab));
469
- }
470
-
471
- return MutexLockResult (is_lock_acquired);
472
- }
473
-
474
- auto MiriGenMCShim::handleMutexTryLock (ThreadId thread_id, uint64_t address, uint64_t size)
475
- -> MutexLockResult
476
- {
477
- auto &currPos = globalInstructions[thread_id].event ;
478
- auto rLab = TrylockCasReadLabel::create (++currPos, address, size);
479
- // Mutex starts out unlocked, so we always say the previous value is "unlocked".
480
- auto oldValSetter = [this ](SAddr loc) { this ->handleOldVal (loc, SVal (0 )); };
481
- LoadResult loadResult = GenMCDriver::handleLoad (std::move (rLab), oldValSetter);
482
- if (!loadResult.has_value ()) {
483
- --currPos;
484
- // TODO GENMC: maybe use std move and make it take a unique_ptr<string> ?
485
- return MutexLockResult::fromError (*loadResult.error );
486
- }
487
-
488
- const bool is_lock_acquired = loadResult.value () == SVal (0 );
489
- if (!is_lock_acquired)
490
- return MutexLockResult (false ); /* Lock already held. */
491
-
492
- auto wLab = TrylockCasWriteLabel::create (++currPos, address, size);
493
- StoreResult storeResult = GenMCDriver::handleStore (std::move (wLab), oldValSetter);
494
- if (storeResult.is_error ())
495
- return MutexLockResult::fromError (*storeResult.error );
496
-
497
- return MutexLockResult (true );
498
- }
499
-
500
- auto MiriGenMCShim::handleMutexUnlock (ThreadId thread_id, uint64_t address, uint64_t size)
501
- -> StoreResult
502
- {
503
- return handleStore (thread_id, address, size, SVal (0 ), SVal (0xDEADBEEF ),
504
- MemOrdering::Release, StoreEventType::MutexUnlockWrite);
505
- }
0 commit comments