Skip to content

Commit

Permalink
Further cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Jul 8, 2024
1 parent 6e46d86 commit 559bbc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions lib/Echidna/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ execTxWithCov tx = do
(_, depths, results) | depth < 64 && not (depths `testBit` depth) -> do
VMut.write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop)
writeIORef covContextRef (True, Just (vec, pc))
_ -> do
modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc))
_ -> modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc))

-- | Get the VM's current execution location
currentCovLoc vm = (vm.state.pc, fromMaybe 0 $ vmOpIx vm, length vm.frames)
Expand Down
12 changes: 6 additions & 6 deletions lib/Echidna/Output/Source.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE ParallelListComp #-}

module Echidna.Output.Source where

Expand Down Expand Up @@ -39,18 +40,17 @@ zipSumStats :: IO [StatsInfo] -> IO [StatsInfo] -> IO [StatsInfo]
zipSumStats v1 v2 = do
vec1 <- v1
vec2 <- v2
return $ zipWith (\a b -> (fst a + fst b, snd a + snd b)) vec1 vec2
return [(exec1 + exec2, revert1 + revert2) | (exec1, revert1) <- vec1 | (exec2, revert2) <- vec2]

mvToList :: (VU.Unbox a) => VU.IOVector a -> IO [a]
mvToList = fmap U.toList . U.freeze

combineStats :: TLS (IORef StatsMap) -> IO StatsMapV
combineStats statsRef = do
threadStats' <- allTLS statsRef
threadStats <- sequence $ map readIORef threadStats' :: IO [StatsMap]
threadStats <- mapM readIORef threadStats' :: IO [StatsMap]
statsLists <- pure $ map (\(m :: StatsMap) -> Map.map (\(x :: VU.IOVector StatsInfo) -> mvToList x) m) threadStats :: IO [Map EVM.Types.W256 (IO [StatsInfo])]
stats <- traverse (\x -> x >>= U.thaw . U.fromList >>= U.freeze) $ ((Map.unionsWith) (\(x :: IO [StatsInfo]) (y :: IO [StatsInfo]) -> zipSumStats x y) statsLists)
return stats
traverse (\x -> x >>= U.thaw . U.fromList >>= U.freeze) $ Map.unionsWith zipSumStats statsLists

saveCoverages
:: Env
Expand Down Expand Up @@ -199,8 +199,8 @@ srcMapCov sc covMap statMap contracts = do
updateLine (Just (r, q)) = Just ((<> unpackTxResults txResults) r, max q execQty)
updateLine Nothing = Just (unpackTxResults txResults, execQty)
fileStats = Map.lookup c.runtimeCodehash statMap
idxStats | isJust fileStats = (fromJust fileStats) U.! opIx
| otherwise = (fromInteger 0, fromInteger 0)
idxStats | isJust fileStats = fromJust fileStats U.! opIx
| otherwise = (0, 0)
execQty = fst idxStats
Nothing -> acc
Nothing -> acc
Expand Down

0 comments on commit 559bbc1

Please sign in to comment.