diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-12-14 17:37:25 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-12-14 17:37:39 +0000 |
commit | faa8ff40162da23a57b58fc128b0d672a8107a46 (patch) | |
tree | 7561f71178e8b7c6bca8313434943951d97d5983 /compiler/iface/BinIface.hs | |
parent | 566920c77bce252d807e9a7cc3da862e5817d340 (diff) | |
download | haskell-faa8ff40162da23a57b58fc128b0d672a8107a46.tar.gz |
Major refactoring of the way that UNPACK pragmas are handled
The situation was pretty dire. The way in which data constructors
were handled, notably the mapping between their *source* argument types
and their *representation* argument types (after seq'ing and unpacking)
was scattered in three different places, and hard to keep in sync.
Now it is all in one place:
* The dcRep field of a DataCon gives its representation,
specified by a DataConRep
* As well as having the wrapper, the DataConRep has a "boxer"
of type DataConBoxer (defined in MkId for loopy reasons).
The boxer used at a pattern match to reconstruct the source-level
arguments from the rep-level bindings in the pattern match.
* The unboxing in the wrapper and the boxing in the boxer are dual,
and are now constructed together, by MkId.mkDataConRep. This is
the key function of this change.
* All the computeBoxingStrategy code in TcTyClsDcls disappears.
Much nicer.
There is a little bit of refactoring left to do; the strange
deepSplitProductType functions are now called only in WwLib, so
I moved them there, and I think they could be tidied up further.
Diffstat (limited to 'compiler/iface/BinIface.hs')
-rw-r--r-- | compiler/iface/BinIface.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/iface/BinIface.hs b/compiler/iface/BinIface.hs index 5d667ced4f..8226b426c3 100644 --- a/compiler/iface/BinIface.hs +++ b/compiler/iface/BinIface.hs @@ -749,19 +749,20 @@ instance Binary InlineSpec where _ -> return NoInline instance Binary HsBang where - put_ bh HsNoBang = putByte bh 0 - put_ bh HsStrict = putByte bh 1 - put_ bh HsUnpack = putByte bh 2 - put_ bh HsUnpackFailed = putByte bh 3 - put_ bh HsNoUnpack = putByte bh 4 + put_ bh HsNoBang = putByte bh 0 + put_ bh (HsBang False) = putByte bh 1 + put_ bh (HsBang True) = putByte bh 2 + put_ bh HsUnpack = putByte bh 3 + put_ bh HsStrict = putByte bh 4 + get bh = do h <- getByte bh case h of 0 -> do return HsNoBang - 1 -> do return HsStrict - 2 -> do return HsUnpack - 3 -> do return HsUnpackFailed - _ -> do return HsNoUnpack + 1 -> do return (HsBang False) + 2 -> do return (HsBang True) + 3 -> do return HsUnpack + _ -> do return HsStrict instance Binary TupleSort where put_ bh BoxedTuple = putByte bh 0 |