%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: AbsCSyn.lhs,v 1.54 2003/07/18 14:39:06 simonmar Exp $
+% $Id: AbsCSyn.lhs,v 1.55 2003/07/28 16:05:30 simonmar Exp $
%
\section[AbstractC]{Abstract C: the last stop before machine code}
-- dataToTag# primop -- *only* used in unregisterised builds.
-- (see AbsCUtils.dsCOpStmt)
| DATA_TO_TAGZH
- | AWAKEN_BQ_CLOSURE -- possibly awaken a blocking quuee
- -- (used for in-place updates)
| REGISTER_FOREIGN_EXPORT -- register a foreign exported fun
| REGISTER_IMPORT -- register an imported module
= ENTRY_CODE
| ARG_TAG -- stack argument tagging
| GET_TAG -- get current constructor tag
- | UPD_FRAME_UPDATEE
| CCS_HDR
| BYTE_ARR_CTS -- used when passing a ByteArray# to a ccall
| PTRS_ARR_CTS -- similarly for an Array#
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: Costs.lhs,v 1.32 2002/12/11 15:36:22 simonmar Exp $
+% $Id: Costs.lhs,v 1.33 2003/07/28 16:05:30 simonmar Exp $
%
% Only needed in a GranSim setup -- HWL
% ---------------------------------------------------------------------------
ENTRY_CODE -> nullCosts -- nothing
ARG_TAG -> nullCosts -- nothing
GET_TAG -> Cost (0, 0, 1, 0, 0) -- indirect load
- UPD_FRAME_UPDATEE -> Cost (0, 0, 1, 0, 0) -- indirect load
-- ---------------------------------------------------------------------------
cExprMacroText ENTRY_CODE = SLIT("ENTRY_CODE")
cExprMacroText ARG_TAG = SLIT("ARG_TAG")
cExprMacroText GET_TAG = SLIT("GET_TAG")
-cExprMacroText UPD_FRAME_UPDATEE = SLIT("UPD_FRAME_UPDATEE")
cExprMacroText CCS_HDR = SLIT("CCS_HDR")
cExprMacroText BYTE_ARR_CTS = SLIT("BYTE_ARR_CTS")
cExprMacroText PTRS_ARR_CTS = SLIT("PTRS_ARR_CTS")
cStmtMacroText PUSH_UPD_FRAME = SLIT("PUSH_UPD_FRAME")
cStmtMacroText SET_TAG = SLIT("SET_TAG")
cStmtMacroText DATA_TO_TAGZH = SLIT("dataToTagzh")
-cStmtMacroText AWAKEN_BQ_CLOSURE = SLIT("AWAKEN_BQ_CLOSURE")
cStmtMacroText REGISTER_FOREIGN_EXPORT = SLIT("REGISTER_FOREIGN_EXPORT")
cStmtMacroText REGISTER_IMPORT = SLIT("REGISTER_IMPORT")
cStmtMacroText REGISTER_DIMPORT = SLIT("REGISTER_DIMPORT")
import CgRetConv ( assignRegs )
import Constants ( mAX_INTLIKE, mIN_INTLIKE, mAX_CHARLIKE, mIN_CHARLIKE,
mIN_UPD_SIZE )
-import CgHeapery ( allocDynClosure, inPlaceAllocDynClosure )
+import CgHeapery ( allocDynClosure )
import CgTailCall ( performReturn, mkStaticAlgReturnCode,
returnUnboxedTuple )
import CLabel ( mkClosureLabel )
jump_to_join_point sequel = absC (CJump (CLbl deflt_lbl CodePtrRep))
-- Ignore the sequel: we've already looked at it above
- -- If the sequel is an update frame, we might be able to
- -- do update in place...
- UpdateCode
- | not (isNullaryDataCon con) -- no nullary constructors, please
- && not (any isFollowableRep (map getAmodeRep amodes))
- -- no ptrs please (generational gc...)
- && closureSize closure_info <= mIN_UPD_SIZE
- -- don't know the real size of the
- -- thunk, so assume mIN_UPD_SIZE
-
- -> -- get a new temporary and make it point to the updatee
- let
- uniq = getUnique con
- temp = CTemp uniq PtrRep
- in
-
- profCtrC FSLIT("TICK_UPD_CON_IN_PLACE")
- [mkIntCLit (length amodes)] `thenC`
-
- getSpRelOffset args_sp `thenFC` \ sp_rel ->
- absC (CAssign temp
- (CMacroExpr PtrRep UPD_FRAME_UPDATEE [CAddr sp_rel]))
- `thenC`
-
- -- stomp all over it with the new constructor
- inPlaceAllocDynClosure closure_info temp (CReg CurCostCentre) stuff
- `thenC`
-
- -- set Node to point to the closure being returned
- -- (can't be done earlier: node might conflict with amodes)
- absC (CAssign (CReg node) temp) `thenC`
-
- -- pop the update frame off the stack, and do the proper
- -- return.
- let new_sp = args_sp - updateFrameSize in
- setEndOfBlockInfo (EndOfBlockInfo new_sp (OnStack new_sp)) $
- performReturn (AbsCNop) (mkStaticAlgReturnCode con)
-
- where
- (closure_info, stuff) = layOutDynConstr con getAmodeRep amodes
-
other_sequel -- The usual case
| isUnboxedTupleCon con -> returnUnboxedTuple amodes
| otherwise -> build_it_then (mkStaticAlgReturnCode con)
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CgHeapery.lhs,v 1.38 2003/07/18 14:39:06 simonmar Exp $
+% $Id: CgHeapery.lhs,v 1.39 2003/07/28 16:05:35 simonmar Exp $
%
\section[CgHeapery]{Heap management functions}
\begin{code}
module CgHeapery (
funEntryChecks, altHeapCheck, unbxTupleHeapCheck, thunkChecks,
- allocDynClosure, inPlaceAllocDynClosure
+ allocDynClosure,
-- new functions, basically inserting macro calls into Code -- HWL
,fetchAndReschedule, yield
closure_size = closureSize closure_info
slop_size = slopSize closure_info
\end{code}
-
-Occasionally we can update a closure in place instead of allocating
-new space for it. This is the function that does the business, assuming:
-
- - the new closure doesn't contain any pointers if we're
- using a generational collector.
-
-\begin{code}
-inPlaceAllocDynClosure
- :: ClosureInfo
- -> CAddrMode -- Pointer to beginning of closure
- -> CAddrMode -- Cost Centre to stick in the object
-
- -> [(CAddrMode, VirtualHeapOffset)] -- Offsets from start of the object
- -- ie Info ptr has offset zero.
- -> Code
-
-inPlaceAllocDynClosure closure_info head use_cc amodes_with_offsets
- = let -- do_move IS THE ASSIGNMENT FUNCTION
- do_move (amode, offset_from_start)
- = CAssign (CVal (CIndex head (mkIntCLit offset_from_start) WordRep)
- (getAmodeRep amode))
- amode
- in
- -- GENERATE THE CODE
- absC ( mkAbstractCs (
- [
- -- don't forget to AWAKEN_BQ_CLOSURE: even though we're
- -- doing update-in-place, the thunk might still have been
- -- blackholed and another thread might be waiting on it.
- CMacroStmt AWAKEN_BQ_CLOSURE [head],
- CInitHdr closure_info head use_cc 0{-no alloc-}
- ]
- ++ (map do_move amodes_with_offsets)))
-\end{code}
-----------------------------------------------------------------------------
\begin{code}
-macroCode AWAKEN_BQ_CLOSURE [arg]
- = getUniqLabelNCG `thenUs` \ label ->
- let
- info = StInd AddrRep arg
- cond = StMachOp MO_Nat_Ne [info, bq_info ]
- jump = StCondJump label cond
- blocking_queue = StInd PtrRep
- (StIndex PtrRep arg (StInt (toInteger fixedHdrSize)))
- call = StVoidable (StCall (Left FSLIT("awakenBlockedQueue"))
- CCallConv VoidRep [blocking_queue])
- in
- returnUs ( \xs -> jump : call : StLabel label : xs )
-\end{code}
-
------------------------------------------------------------------------------
-
-\begin{code}
macroCode REGISTER_IMPORT [arg]
= returnUs (
\xs -> StAssignMem WordRep (StReg stgSp) arg
(StInt (toInteger (-1)))),
StInt 16]
#endif
- UPD_FRAME_UPDATEE
- -> StInd PtrRep (StIndex PtrRep arg_amode
- (StInt (toInteger uF_UPDATEE)))
-
BYTE_ARR_CTS -> StIndex IntRep arg_amode arrWordsHS
PTRS_ARR_CTS -> StIndex PtrRep arg_amode arrPtrsHS
ForeignObj_CLOSURE_DATA -> StInd PtrRep (StIndex PtrRep arg_amode fixedHS)
/* -----------------------------------------------------------------------------
- * $Id: StgMacros.h,v 1.53 2003/04/28 10:02:15 simonmar Exp $
+ * $Id: StgMacros.h,v 1.54 2003/07/28 16:05:36 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
# define UPD_BH_SINGLE_ENTRY(thunk) /* nothing */
#endif /* EAGER_BLACKHOLING */
-#define UPD_FRAME_UPDATEE(p) ((P_)(((StgUpdateFrame *)(p))->updatee))
-
/* -----------------------------------------------------------------------------
Moving Floats and Doubles
/* -----------------------------------------------------------------------------
- * $Id: Updates.h,v 1.32 2003/07/18 14:39:05 simonmar Exp $
+ * $Id: Updates.h,v 1.33 2003/07/28 16:05:38 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
Awaken any threads waiting on this computation
-------------------------------------------------------------------------- */
-#define AWAKEN_BQ_CLOSURE(closure) \
- { \
- const StgInfoTable *info; \
- info = ((StgClosure *)closure)->header.info; \
- AWAKEN_BQ(info,closure); \
- }
-
#if defined(PAR)
/*
ProjectName = The Glorious Glasgow Haskell Compilation System
ProjectNameShort = ghc
-ProjectVersion = 6.1
+ProjectVersion = 6.1.20030727
ProjectVersionInt = 601
ProjectPatchLevel = 0