Skip to content

Commit 2736c97

Browse files
committed
io-sim-por: removed ST effect
ST computations can not be shared by multiple threads, they are always thread local; which means they never can race with anything else. This means we don't need to track ST effects, and consider them when checking if two steps race or not.
1 parent 0594c39 commit 2736c97

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

io-sim/src/Control/Monad/IOSimPOR/Internal.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ schedule thread@Thread{
378378

379379
LiftST st k -> do
380380
x <- strictToLazyST st
381-
let thread' = thread { threadControl = ThreadControl (k x) ctl,
382-
threadEffect = effect <> liftSTEffect }
381+
let thread' = thread { threadControl = ThreadControl (k x) ctl }
383382
schedule thread' simstate
384383

385384
GetMonoTime k -> do

io-sim/src/Control/Monad/IOSimPOR/Types.hs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@ data Effect = Effect {
1717
effectReads :: !(Set TVarId),
1818
effectWrites :: !(Set TVarId),
1919
effectForks :: !(Set ThreadId),
20-
effectLiftST :: !Bool,
2120
effectThrows :: ![ThreadId],
2221
effectWakeup :: ![ThreadId]
2322
}
2423
deriving (Eq, Show)
2524

2625
instance Semigroup Effect where
27-
Effect r w s b ts wu <> Effect r' w' s' b' ts' wu' =
28-
Effect (r<>r') (w<>w') (s<>s') (b||b') (ts++ts') (wu++wu')
26+
Effect r w s ts wu <> Effect r' w' s' ts' wu' =
27+
Effect (r<>r') (w<>w') (s<>s') (ts++ts') (wu++wu')
2928

3029
instance Monoid Effect where
31-
mempty = Effect Set.empty Set.empty Set.empty False [] []
30+
mempty = Effect Set.empty Set.empty Set.empty [] []
3231

3332
-- readEffect :: SomeTVar s -> Effect
3433
-- readEffect r = mempty{effectReads = Set.singleton $ someTvarId r }
@@ -45,9 +44,6 @@ writeEffects rs = mempty{effectWrites = Set.fromList (map someTvarId rs)}
4544
forkEffect :: ThreadId -> Effect
4645
forkEffect tid = mempty{effectForks = Set.singleton $ tid}
4746

48-
liftSTEffect :: Effect
49-
liftSTEffect = mempty{ effectLiftST = True }
50-
5147
throwToEffect :: ThreadId -> Effect
5248
throwToEffect tid = mempty{ effectThrows = [tid] }
5349

@@ -62,9 +58,7 @@ onlyReadEffect e = e { effectReads = effectReads mempty } == mempty
6258

6359
racingEffects :: Effect -> Effect -> Bool
6460
racingEffects e e' =
65-
(effectLiftST e && racesWithLiftST e')
66-
|| (effectLiftST e' && racesWithLiftST e )
67-
|| effectThrows e `intersectsL` effectThrows e'
61+
effectThrows e `intersectsL` effectThrows e'
6862
|| effectReads e `intersects` effectWrites e'
6963
|| effectWrites e `intersects` effectReads e'
7064
|| effectWrites e `intersects` effectWrites e'
@@ -74,8 +68,3 @@ racingEffects e e' =
7468

7569
intersectsL :: Eq a => [a] -> [a] -> Bool
7670
intersectsL a b = not $ null $ a `List.intersect` b
77-
78-
racesWithLiftST eff =
79-
effectLiftST eff
80-
|| not (Set.null (effectReads eff) && Set.null (effectWrites eff))
81-

0 commit comments

Comments
 (0)