@@ -113,8 +113,8 @@ pub enum BlockReason {
113
113
}
114
114
115
115
/// The state of a thread.
116
- // TODO GENMC : is this ok to be pub ?
117
- pub enum ThreadState < ' tcx > {
116
+ // FIXME(genmc,question) : is this ok to be public ?
117
+ pub ( crate ) enum ThreadState < ' tcx > {
118
118
/// The thread is enabled and can be executed.
119
119
Enabled ,
120
120
/// The thread is blocked on something.
@@ -136,16 +136,16 @@ impl<'tcx> std::fmt::Debug for ThreadState<'tcx> {
136
136
}
137
137
138
138
impl < ' tcx > ThreadState < ' tcx > {
139
- // TODO GENMC : is it ok if these are pub ?
140
- pub fn is_enabled ( & self ) -> bool {
139
+ // FIXME(genmc,question) : is it ok for these to be public ?
140
+ pub ( crate ) fn is_enabled ( & self ) -> bool {
141
141
matches ! ( self , ThreadState :: Enabled )
142
142
}
143
143
144
- pub fn is_terminated ( & self ) -> bool {
144
+ pub ( crate ) fn is_terminated ( & self ) -> bool {
145
145
matches ! ( self , ThreadState :: Terminated )
146
146
}
147
147
148
- pub fn is_blocked_on ( & self , reason : BlockReason ) -> bool {
148
+ pub ( crate ) fn is_blocked_on ( & self , reason : BlockReason ) -> bool {
149
149
matches ! ( * self , ThreadState :: Blocked { reason: actual_reason, .. } if actual_reason == reason)
150
150
}
151
151
}
@@ -211,8 +211,8 @@ impl<'tcx> Thread<'tcx> {
211
211
self . thread_name . as_deref ( )
212
212
}
213
213
214
- pub fn get_state ( & self ) -> & ThreadState < ' tcx > {
215
- // TODO GENMC: should this implementation detail be exposed?
214
+ // FIXME(genmc,question): is this ok to be public? (it exposes implementation details)
215
+ pub ( crate ) fn get_state ( & self ) -> & ThreadState < ' tcx > {
216
216
& self . state
217
217
}
218
218
@@ -349,10 +349,10 @@ impl VisitProvenance for Frame<'_, Provenance, FrameExtra<'_>> {
349
349
}
350
350
}
351
351
352
+ // FIXME(genmc,question): is this ok to be public?
352
353
/// The moment in time when a blocked thread should be woken up.
353
- // TODO GENMC: is this ok to be pub?
354
354
#[ derive( Debug ) ]
355
- pub enum Timeout {
355
+ pub ( crate ) enum Timeout {
356
356
Monotonic ( Instant ) ,
357
357
RealTime ( SystemTime ) ,
358
358
}
@@ -499,8 +499,11 @@ impl<'tcx> ThreadManager<'tcx> {
499
499
& mut self . threads [ self . active_thread ] . stack
500
500
}
501
501
502
- /// TODO GENMC: this function can probably be removed once the GenmcCtx code is finished:
503
- pub fn get_thread_stack ( & self , id : ThreadId ) -> & [ Frame < ' tcx , Provenance , FrameExtra < ' tcx > > ] {
502
+ // FIXME(genmc,question): is this ok to exist?
503
+ pub ( crate ) fn get_thread_stack (
504
+ & self ,
505
+ id : ThreadId ,
506
+ ) -> & [ Frame < ' tcx , Provenance , FrameExtra < ' tcx > > ] {
504
507
& self . threads [ id] . stack
505
508
}
506
509
@@ -538,11 +541,6 @@ impl<'tcx> ThreadManager<'tcx> {
538
541
self . threads . len ( )
539
542
}
540
543
541
- /// Get the total of threads that are currently enabled, i.e., could continue executing.
542
- pub fn get_enabled_thread_count ( & self ) -> usize {
543
- self . threads . iter ( ) . filter ( |t| t. state . is_enabled ( ) ) . count ( )
544
- }
545
-
546
544
/// Get the total of threads that are currently live, i.e., not yet terminated.
547
545
/// (They might be blocked.)
548
546
pub fn get_live_thread_count ( & self ) -> usize {
@@ -934,10 +932,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
934
932
assert ! ( thread. stack. is_empty( ) , "only threads with an empty stack can be terminated" ) ;
935
933
thread. state = ThreadState :: Terminated ;
936
934
937
- // TODO GENMC (QUESTION): Can we move this down to where the GenmcCtx is?
938
- if let Some ( data_race) = this. machine . data_race . as_vclocks_mut ( ) {
939
- data_race. thread_terminated ( & this. machine . threads ) ;
940
- }
941
935
// Deallocate TLS.
942
936
let gone_thread = this. active_thread ( ) ;
943
937
{
@@ -969,10 +963,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
969
963
}
970
964
}
971
965
972
- // Inform GenMC that the thread finished.
973
- // This needs to happen once all accesses to the thread are done, including freeing any TLS statics.
974
- if let Some ( genmc_ctx) = this. machine . data_race . as_genmc_ref ( ) {
975
- genmc_ctx. handle_thread_finish ( & this. machine . threads ) ;
966
+ // FIXME(genmc,question): Is it correct to move this code here?
967
+ match & mut this. machine . data_race {
968
+ GlobalDataRaceHandler :: None => { }
969
+ GlobalDataRaceHandler :: Vclocks ( data_race) =>
970
+ data_race. thread_terminated ( & this. machine . threads ) ,
971
+ GlobalDataRaceHandler :: Genmc ( genmc_ctx) => {
972
+ // Inform GenMC that the thread finished.
973
+ // This needs to happen once all accesses to the thread are done, including freeing any TLS statics.
974
+ genmc_ctx. handle_thread_finish ( & this. machine . threads )
975
+ }
976
976
}
977
977
978
978
// Unblock joining threads.
@@ -1264,7 +1264,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1264
1264
SchedulingAction :: ExecuteTimeoutCallback => {
1265
1265
this. run_timeout_callback ( ) ?;
1266
1266
}
1267
- // TODO GENMC: do we need to sleep in GenMC Mode?
1267
+ // FIXME(genmc): properly handle sleep in GenMC mode.
1268
1268
SchedulingAction :: Sleep ( duration) => {
1269
1269
this. machine . monotonic_clock . sleep ( duration) ;
1270
1270
}
0 commit comments