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