From cf7573b8207bbb17c58612f3345e0b17d74cfb58 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 8 May 2015 15:28:40 +0100 Subject: More accurate allocation stats for :set +s The point of this commit is to make the memory allocation statistic from :set +s in GHCi a lot more accurate. Currently it uses the total allocation figure calculated by the RTS, which is only updated during GC, so can be wrong by an arbitrary amount. The fix is to the the per-thread allocation counter that was introduced for allocation limits. This required changes to the GHC API, because we now have to return the allocation value from each evaluation. Rather than just change the API, I introduced a new API and deprecated the old one. The new one is simpler and more extensible, so hopefully we won't need to make this transition in the future. See GHC.hs for details. --- testsuite/tests/ghc-api/T8628.hs | 8 ++++---- testsuite/tests/ghc-api/T8639_api.hs | 4 ++-- testsuite/tests/ghc-api/apirecomp001/myghc.hs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'testsuite/tests/ghc-api') diff --git a/testsuite/tests/ghc-api/T8628.hs b/testsuite/tests/ghc-api/T8628.hs index 203d3282ab..d3b05a9f86 100644 --- a/testsuite/tests/ghc-api/T8628.hs +++ b/testsuite/tests/ghc-api/T8628.hs @@ -24,10 +24,10 @@ main setContext [ IIDecl (simpleImportDecl pRELUDE_NAME) , IIDecl (simpleImportDecl (mkModuleNameFS (fsLit "System.IO")))] runDecls "data X = Y ()" - runStmt "print True" RunToCompletion - gtry $ runStmt "print (Y ())" RunToCompletion :: GhcMonad m => m (Either SomeException RunResult) + execStmt "print True" execOptions + gtry $ execStmt "print (Y ())" execOptions :: GhcMonad m => m (Either SomeException ExecResult) runDecls "data X = Y () deriving Show" _ <- dynCompileExpr "'x'" - runStmt "print (Y ())" RunToCompletion - runStmt "System.IO.hFlush System.IO.stdout" RunToCompletion + execStmt "print (Y ())" execOptions + execStmt "System.IO.hFlush System.IO.stdout" execOptions print "done" diff --git a/testsuite/tests/ghc-api/T8639_api.hs b/testsuite/tests/ghc-api/T8639_api.hs index 2ddfb4919e..36458b8eca 100644 --- a/testsuite/tests/ghc-api/T8639_api.hs +++ b/testsuite/tests/ghc-api/T8639_api.hs @@ -19,8 +19,8 @@ main -- With the next line, you get an "Not in scope" exception. -- If you comment out this runStmt, it runs without error and prints the type. - runStmt "putStrLn (show 3)" RunToCompletion - runStmt "hFlush stdout" RunToCompletion + execStmt "putStrLn (show 3)" execOptions + execStmt "hFlush stdout" execOptions ty <- exprType "T8639_api_a.it" liftIO (putStrLn (showPpr flags ty)) diff --git a/testsuite/tests/ghc-api/apirecomp001/myghc.hs b/testsuite/tests/ghc-api/apirecomp001/myghc.hs index 39545c937d..a21aa47fa6 100644 --- a/testsuite/tests/ghc-api/apirecomp001/myghc.hs +++ b/testsuite/tests/ghc-api/apirecomp001/myghc.hs @@ -44,11 +44,11 @@ main = do setContext [IIModule mod] liftIO $ hFlush stdout -- make sure things above are printed before -- interactive output - r <- runStmt "main" RunToCompletion + r <- execStmt "main" execOptions case r of - RunOk _ -> prn "ok" - RunException _ -> prn "exception" - RunBreak _ _ _ -> prn "breakpoint" + ExecComplete { execResult = Right _ } -> prn "ok" + ExecComplete { execResult = Left _ } -> prn "exception" + ExecBreak{} -> prn "breakpoint" liftIO $ hFlush stdout return () -- cgit v1.2.1