projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2005-06-22 08:24:22 by simonmar]
[ghc-hetmet.git]
/
ghc
/
compiler
/
codeGen
/
CgHeapery.lhs
diff --git
a/ghc/compiler/codeGen/CgHeapery.lhs
b/ghc/compiler/codeGen/CgHeapery.lhs
index
b0bdf46
..
78a6f78
100644
(file)
--- a/
ghc/compiler/codeGen/CgHeapery.lhs
+++ b/
ghc/compiler/codeGen/CgHeapery.lhs
@@
-1,7
+1,7
@@
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CgHeapery.lhs,v 1.43 2005/02/10 13:01:53 simonmar Exp $
+% $Id: CgHeapery.lhs,v 1.47 2005/06/21 10:44:41 simonmar Exp $
%
\section[CgHeapery]{Heap management functions}
%
\section[CgHeapery]{Heap management functions}
@@
-40,7
+40,8
@@
import ClosureInfo ( closureSize, staticClosureNeedsLink,
nodeMustPointToIt, closureLFInfo,
ClosureInfo )
import SMRep ( CgRep(..), cgRepSizeW, separateByPtrFollowness,
nodeMustPointToIt, closureLFInfo,
ClosureInfo )
import SMRep ( CgRep(..), cgRepSizeW, separateByPtrFollowness,
- WordOff, fixedHdrSize, isVoidArg, primRepToCgRep )
+ WordOff, fixedHdrSize, thunkHdrSize,
+ isVoidArg, primRepToCgRep )
import Cmm ( CmmLit(..), CmmStmt(..), CmmExpr(..), GlobalReg(..),
CmmReg(..), hpReg, nodeReg, spReg )
import Cmm ( CmmLit(..), CmmStmt(..), CmmExpr(..), GlobalReg(..),
CmmReg(..), hpReg, nodeReg, spReg )
@@
-53,11
+54,9
@@
import TyCon ( tyConPrimRep )
import CostCentre ( CostCentreStack )
import Util ( mapAccumL, filterOut )
import Constants ( wORD_SIZE )
import CostCentre ( CostCentreStack )
import Util ( mapAccumL, filterOut )
import Constants ( wORD_SIZE )
-import CmdLineOpts ( DynFlags )
+import Packages ( HomeModules )
import Outputable
import Outputable
-import GLAEXTS
-
\end{code}
\end{code}
@@
-125,7
+124,7
@@
getHpRelOffset virtual_offset
\begin{code}
layOutDynConstr, layOutStaticConstr
\begin{code}
layOutDynConstr, layOutStaticConstr
- :: DynFlags
+ :: HomeModules
-> DataCon
-> [(CgRep,a)]
-> (ClosureInfo,
-> DataCon
-> [(CgRep,a)]
-> (ClosureInfo,
@@
-134,13
+133,13
@@
layOutDynConstr, layOutStaticConstr
layOutDynConstr = layOutConstr False
layOutStaticConstr = layOutConstr True
layOutDynConstr = layOutConstr False
layOutStaticConstr = layOutConstr True
-layOutConstr is_static dflags data_con args
- = (mkConInfo dflags is_static data_con tot_wds ptr_wds,
+layOutConstr is_static hmods data_con args
+ = (mkConInfo hmods is_static data_con tot_wds ptr_wds,
things_w_offsets)
where
things_w_offsets)
where
- (tot_wds, -- #ptr_wds + #nonptr_wds
- ptr_wds, -- #ptr_wds
- things_w_offsets) = mkVirtHeapOffsets args
+ (tot_wds, -- #ptr_wds + #nonptr_wds
+ ptr_wds, -- #ptr_wds
+ things_w_offsets) = mkVirtHeapOffsets False{-not a thunk-} args
\end{code}
@mkVirtHeapOffsets@ always returns boxed things with smaller offsets
\end{code}
@mkVirtHeapOffsets@ always returns boxed things with smaller offsets
@@
-149,8
+148,9
@@
list
\begin{code}
mkVirtHeapOffsets
\begin{code}
mkVirtHeapOffsets
- :: [(CgRep,a)] -- Things to make offsets for
- -> (WordOff, -- *Total* number of words allocated
+ :: Bool -- True <=> is a thunk
+ -> [(CgRep,a)] -- Things to make offsets for
+ -> (WordOff, -- _Total_ number of words allocated
WordOff, -- Number of words allocated for *pointers*
[(a, VirtualHpOffset)])
-- Things with their offsets from start of
WordOff, -- Number of words allocated for *pointers*
[(a, VirtualHpOffset)])
-- Things with their offsets from start of
@@
-158,7
+158,7
@@
mkVirtHeapOffsets
-- First in list gets lowest offset, which is initial offset + 1.
-- First in list gets lowest offset, which is initial offset + 1.
-mkVirtHeapOffsets things
+mkVirtHeapOffsets is_thunk things
= let non_void_things = filterOut (isVoidArg . fst) things
(ptrs, non_ptrs) = separateByPtrFollowness non_void_things
(wds_of_ptrs, ptrs_w_offsets) = mapAccumL computeOffset 0 ptrs
= let non_void_things = filterOut (isVoidArg . fst) things
(ptrs, non_ptrs) = separateByPtrFollowness non_void_things
(wds_of_ptrs, ptrs_w_offsets) = mapAccumL computeOffset 0 ptrs
@@
-166,8
+166,11
@@
mkVirtHeapOffsets things
in
(tot_wds, wds_of_ptrs, ptrs_w_offsets ++ non_ptrs_w_offsets)
where
in
(tot_wds, wds_of_ptrs, ptrs_w_offsets ++ non_ptrs_w_offsets)
where
+ hdr_size | is_thunk = thunkHdrSize
+ | otherwise = fixedHdrSize
+
computeOffset wds_so_far (rep, thing)
computeOffset wds_so_far (rep, thing)
- = (wds_so_far + cgRepSizeW rep, (thing, fixedHdrSize + wds_so_far))
+ = (wds_so_far + cgRepSizeW rep, (thing, hdr_size + wds_so_far))
\end{code}
\end{code}
@@
-227,6
+230,7
@@
mkStaticClosureFields cl_info ccs caf_refs payload
| caf_refs = mkIntCLit 0
| otherwise = mkIntCLit 1
| caf_refs = mkIntCLit 0
| otherwise = mkIntCLit 1
+
mkStaticClosure :: CLabel -> CostCentreStack -> [CmmLit]
-> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit]
mkStaticClosure info_lbl ccs payload padding_wds static_link_field saved_info_field
mkStaticClosure :: CLabel -> CostCentreStack -> [CmmLit]
-> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit]
mkStaticClosure info_lbl ccs payload padding_wds static_link_field saved_info_field