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