[commit: ghc] master: Comments only (182fe6f)
Simon Peyton Jones
simonpj at microsoft.com
Wed Jan 30 15:34:34 CET 2013
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/182fe6f0a7ed5db5d4097727fdac4a3d2489bd7e
>---------------------------------------------------------------
commit 182fe6f0a7ed5db5d4097727fdac4a3d2489bd7e
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu Jan 24 15:45:35 2013 +0000
Comments only
>---------------------------------------------------------------
compiler/stranal/WwLib.lhs | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/compiler/stranal/WwLib.lhs b/compiler/stranal/WwLib.lhs
index ea23655..98c0b9e 100644
--- a/compiler/stranal/WwLib.lhs
+++ b/compiler/stranal/WwLib.lhs
@@ -371,17 +371,29 @@ mkWWstr dflags (arg : args) = do
Note [Unpacking arguments with product and polymorphic demands]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The argument is unpacked in a case if it has a product type and has a
-strict and used demand put on it. I.e., arguments, with demands such
+strict *and* used demand put on it. I.e., arguments, with demands such
as the following ones:
-<S,U(U, L)>
-<S(L,S),U>
+ <S,U(U, L)>
+ <S(L,S),U>
-will be unpacked. Moreover, for arguments whose demand is <S,U> or
-<S,H>, we take an advantage of the polymorphic nature of S and U and
-replicate the enclosed demand correspondingly (see definition of
-replicateDmd).
+will be unpacked, but
+ <S,U> or <B,U>
+
+will not, because the pieces aren't used. This is quite important otherwise
+we end up unpacking massive tuples passed to the bottoming function. Example:
+
+ f :: ((Int,Int) -> String) -> (Int,Int) -> a
+ f g pr = error (g pr)
+
+ main = print (f fst (1, error "no"))
+
+Does 'main' print "error 1" or "error no"? We don't really want 'f'
+to unbox its second argument. This actually happened in GHC's onwn
+source code, in Packages.applyPackageFlag, which ended up un-boxing
+the enormous DynFlags tuple, and being strict in the
+as-yet-un-filled-in pkgState fiels.
\begin{code}
----------------------
@@ -421,10 +433,9 @@ mkWWstr_one dflags arg
-- But the Evald flag is pretty weird, and I worry that it might disappear
-- during simplification, so for now I've just nuked this whole case
- -- Unpack case,
- -- see note [Unpacking arguments with product and polymorphic demands]
| isStrictDmd dmd
, Just cs <- splitProdDmd_maybe dmd
+ -- See Note [Unpacking arguments with product and polymorphic demands]
, Just (data_con, inst_tys, inst_con_arg_tys, co)
<- deepSplitProductType_maybe (idType arg)
= do { (uniq1:uniqs) <- getUniquesM
More information about the ghc-commits
mailing list