diff options
author | simonmar <unknown> | 2003-05-14 09:14:02 +0000 |
---|---|---|
committer | simonmar <unknown> | 2003-05-14 09:14:02 +0000 |
commit | 7a236a564b90cd060612e1e979ce7d552da61fa1 (patch) | |
tree | c37aa39e2ffe18a8166e7c475e5b448d0fc93bb3 /ghc/compiler/codeGen/CgMonad.lhs | |
parent | efbac4137aea853ab5ac0b651cfd7c6b591904f6 (diff) | |
download | haskell-7a236a564b90cd060612e1e979ce7d552da61fa1.tar.gz |
[project @ 2003-05-14 09:13:52 by simonmar]
Change the way SRTs are represented:
Previously, the SRT associated with a function or thunk would be a
sub-list of the enclosing top-level function's SRT. But this approach
can lead to lots of duplication: if a CAF is referenced in several
different thunks, then it may appear several times in the SRT.
Let-no-escapes compound the problem, because the occurrence of a
let-no-escape-bound variable would expand to all the CAFs referred to
by the let-no-escape.
The new way is to describe the SRT associated with a function or thunk
as a (pointer+offset,bitmap) pair, where the pointer+offset points
into some SRT table (the enclosing function's SRT), and the bitmap
indicates which entries in this table are "live" for this closure.
The bitmap is stored in the 16 bits previously used for the length
field, but this rarely overflows. When it does overflow, we store the
bitmap externally in a new "SRT descriptor".
Now the enclosing SRT can be a set, hence eliminating the duplicates.
Also, we now have one SRT per top-level function in a recursive group,
where previously we used to have one SRT for the whole group. This
helps keep the size of SRTs down.
Bottom line: very little difference most of the time. GHC itself got
slightly smaller. One bad case of a module in GHC which had a huge
SRT has gone away.
While I was in the area:
- Several parts of the back-end require bitmaps. Functions for
creating bitmaps are now centralised in the Bitmap module.
- We were trying to be independent of word-size in a couple of
places in the back end, but we've now abandoned that strategy so I
simplified things a bit.
Diffstat (limited to 'ghc/compiler/codeGen/CgMonad.lhs')
-rw-r--r-- | ghc/compiler/codeGen/CgMonad.lhs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/ghc/compiler/codeGen/CgMonad.lhs b/ghc/compiler/codeGen/CgMonad.lhs index a14b77a562..99c776e34e 100644 --- a/ghc/compiler/codeGen/CgMonad.lhs +++ b/ghc/compiler/codeGen/CgMonad.lhs @@ -1,7 +1,7 @@ % % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -% $Id: CgMonad.lhs,v 1.37 2003/01/07 14:31:20 simonmar Exp $ +% $Id: CgMonad.lhs,v 1.38 2003/05/14 09:13:56 simonmar Exp $ % \section[CgMonad]{The code generation monad} @@ -60,8 +60,10 @@ import CmdLineOpts ( opt_SccProfilingOn, opt_DoTickyProfiling ) import Module ( Module ) import DataCon ( ConTag ) import Id ( Id ) +import Name ( Name ) import VarEnv import PrimRep ( PrimRep(..) ) +import SMRep ( StgHalfWord, hALF_WORD ) import FastString import Outputable @@ -605,16 +607,25 @@ bindings use sub-sections of this SRT. The label is passed down to the nested bindings via the monad. \begin{code} -getSRTInfo :: SRT -> FCode C_SRT -getSRTInfo NoSRT = return NoC_SRT -getSRTInfo (SRT off len) = do srt_lbl <- getSRTLabel - return (C_SRT srt_lbl off len) +getSRTInfo :: Name -> SRT -> FCode C_SRT +getSRTInfo id NoSRT = return NoC_SRT +getSRTInfo id (SRT off len bmp) + | len > hALF_WORD || bmp == [fromIntegral srt_escape] = do + srt_lbl <- getSRTLabel + let srt_desc_lbl = mkSRTDescLabel id + absC (CSRTDesc srt_desc_lbl srt_lbl off len bmp) + return (C_SRT srt_desc_lbl 0 srt_escape) + | otherwise = do + srt_lbl <- getSRTLabel + return (C_SRT srt_lbl off (fromIntegral (head bmp))) + +srt_escape = (-1) :: StgHalfWord getSRTLabel :: FCode CLabel -- Used only by cgPanic getSRTLabel = do MkCgInfoDown _ _ srt_lbl _ _ <- getInfoDown return srt_lbl -setSRTLabel :: CLabel -> Code -> Code +setSRTLabel :: CLabel -> FCode a -> FCode a setSRTLabel srt_lbl code = do MkCgInfoDown c_info statics _ ticky eob_info <- getInfoDown withInfoDown code (MkCgInfoDown c_info statics srt_lbl ticky eob_info) |