[commit: testsuite] master: Test that runST is not inlined prematurely (e17a62c)

git at git.haskell.org git at git.haskell.org
Wed Jan 8 18:24:26 UTC 2014


Repository : ssh://git@git.haskell.org/testsuite

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e17a62c14b6a1fce681b06ebd0cc11223841f92f/testsuite

>---------------------------------------------------------------

commit e17a62c14b6a1fce681b06ebd0cc11223841f92f
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Wed Jan 8 18:23:56 2014 +0000

    Test that runST is not inlined prematurely
    
    This resulted form a discussion about #5916.


>---------------------------------------------------------------

e17a62c14b6a1fce681b06ebd0cc11223841f92f
 tests/simplCore/should_run/all.T                          |    2 ++
 tests/simplCore/should_run/runST.hs                       |   13 +++++++++++++
 .../T3279.stdout => simplCore/should_run/runST.stdout}    |    0
 3 files changed, 15 insertions(+)

diff --git a/tests/simplCore/should_run/all.T b/tests/simplCore/should_run/all.T
index c9be7a4..430d61f 100644
--- a/tests/simplCore/should_run/all.T
+++ b/tests/simplCore/should_run/all.T
@@ -31,6 +31,8 @@ test('T3437', extra_run_opts('+RTS -M10m'), compile_and_run, [''])
 
 test('SeqRule', only_ways(['optasm']), compile_and_run, [''])
 
+test('runST', normal, compile_and_run, [''])
+
 test('T3403', normal, compile_and_run, ['-package containers'])
 test('T3591', normal, compile_and_run, [''])
 test('T4814', normal, compile_and_run, [''])
diff --git a/tests/simplCore/should_run/runST.hs b/tests/simplCore/should_run/runST.hs
new file mode 100644
index 0000000..dc06c24
--- /dev/null
+++ b/tests/simplCore/should_run/runST.hs
@@ -0,0 +1,13 @@
+import Control.Monad.ST
+import Data.STRef
+
+-- Make sure that the realWord# token used by runST (actually by runSTRep) is
+-- not inlined, which would share the call to `newMutVar#`, and suddenly there
+-- would be only one MutVar
+
+main =
+    let f () = runST $ do
+        ref <- newSTRef 0
+        modifySTRef ref (+1)
+        readSTRef ref
+    in print (f () + f ())
diff --git a/tests/concurrent/should_run/T3279.stdout b/tests/simplCore/should_run/runST.stdout
similarity index 100%
copy from tests/concurrent/should_run/T3279.stdout
copy to tests/simplCore/should_run/runST.stdout



More information about the ghc-commits mailing list