@@ -881,21 +881,9 @@ execAtomically !time !tid !tlbl !nextVid0 action0 k0 =
881
881
(mapMaybe traceString $ ds ++ ds')
882
882
nextVid
883
883
884
- OrElseLeftFrame _b k writtenOuter writtenOuterSeq createdOuterSeq ctl' -> do
885
- -- Commit the TVars written in this sub-transaction that are also
886
- -- in the written set of the outer transaction
887
- ! _ <- traverse_ (\ (SomeTVar tvar) -> commitTVar tvar)
888
- (Map. intersection written writtenOuter)
889
- -- Merge the written set of the inner with the outer
890
- let written' = Map. union written writtenOuter
891
- writtenSeq' = filter (\ (SomeTVar tvar) ->
892
- tvarId tvar `Map.notMember` writtenOuter)
893
- writtenSeq
894
- ++ writtenOuterSeq
895
- -- Skip the orElse right hand and continue with the k continuation
896
- go ctl' read written' writtenSeq' createdOuterSeq nextVid (k x)
897
-
898
- OrElseRightFrame k writtenOuter writtenOuterSeq createdOuterSeq ctl' -> do
884
+ BranchFrame _b k writtenOuter writtenOuterSeq createdOuterSeq ctl' -> do
885
+ -- The branch has successfully completed the transaction. Hence,
886
+ -- the alternative branch can be ignored.
899
887
-- Commit the TVars written in this sub-transaction that are also
900
888
-- in the written set of the outer transaction
901
889
! _ <- traverse_ (\ (SomeTVar tvar) -> commitTVar tvar)
@@ -907,7 +895,7 @@ execAtomically !time !tid !tlbl !nextVid0 action0 k0 =
907
895
writtenSeq
908
896
++ writtenOuterSeq
909
897
createdSeq' = createdSeq ++ createdOuterSeq
910
- -- Continue with the k continuation
898
+ -- Skip the right hand alternative and continue with the k continuation
911
899
go ctl' read written' writtenSeq' createdSeq' nextVid (k x)
912
900
913
901
ThrowStm e ->
@@ -925,17 +913,19 @@ execAtomically !time !tid !tlbl !nextVid0 action0 k0 =
925
913
-- Return vars read, so the thread can block on them
926
914
k0 $! StmTxBlocked $! (Map. elems read )
927
915
928
- OrElseLeftFrame b k writtenOuter writtenOuterSeq createdOuterSeq ctl' ->
929
- {-# SCC "execAtomically.go.OrElseLeftFrame " #-} do
930
- -- Revert all the TVar writes within this orElse
916
+ BranchFrame ( OrElseStmA b) k writtenOuter writtenOuterSeq createdOuterSeq ctl' ->
917
+ {-# SCC "execAtomically.go.BranchFrame " #-} do
918
+ -- Revert all the TVar writes within this orElse branch
931
919
! _ <- traverse_ (\ (SomeTVar tvar) -> revertTVar tvar) written
932
920
-- Execute the orElse right hand with an empty written set
933
- let ctl'' = OrElseRightFrame k writtenOuter writtenOuterSeq createdOuterSeq ctl'
921
+ let ctl'' = BranchFrame NoOpStmA k writtenOuter writtenOuterSeq createdOuterSeq ctl'
934
922
go ctl'' read Map. empty [] [] nextVid b
935
923
936
- OrElseRightFrame _k writtenOuter writtenOuterSeq createdOuterSeq ctl' ->
937
- {-# SCC "execAtomically.go.OrElseRightFrame" #-} do
938
- -- Revert all the TVar writes within this orElse branch
924
+ BranchFrame _ _k writtenOuter writtenOuterSeq createdOuterSeq ctl' ->
925
+ {-# SCC "execAtomically.go.BranchFrame" #-} do
926
+ -- Retry makes sense only within a OrElse context. If it is a branch other than
927
+ -- OrElse left side, then bubble up the `retry` to the frame above.
928
+ -- Revert all the TVar writes within this branch
939
929
! _ <- traverse_ (\ (SomeTVar tvar) -> revertTVar tvar) written
940
930
-- Skip the continuation and propagate the retry into the outer frame
941
931
-- using the written set for the outer frame
@@ -944,7 +934,7 @@ execAtomically !time !tid !tlbl !nextVid0 action0 k0 =
944
934
OrElse a b k ->
945
935
{-# SCC "execAtomically.go.OrElse" #-} do
946
936
-- Execute the left side in a new frame with an empty written set
947
- let ctl' = OrElseLeftFrame b k written writtenSeq createdSeq ctl
937
+ let ctl' = BranchFrame ( OrElseStmA b) k written writtenSeq createdSeq ctl
948
938
go ctl' read Map. empty [] [] nextVid a
949
939
950
940
NewTVar ! mbLabel x k ->
0 commit comments