summaryrefslogtreecommitdiff
path: root/compiler/codeGen/CgHeapery.lhs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/codeGen/CgHeapery.lhs')
-rw-r--r--compiler/codeGen/CgHeapery.lhs67
1 files changed, 35 insertions, 32 deletions
diff --git a/compiler/codeGen/CgHeapery.lhs b/compiler/codeGen/CgHeapery.lhs
index daca30c25a..e37783cf11 100644
--- a/compiler/codeGen/CgHeapery.lhs
+++ b/compiler/codeGen/CgHeapery.lhs
@@ -208,22 +208,22 @@ mkStaticClosureFields dflags cl_info ccs caf_refs payload
padding_wds
| not is_caf = []
- | otherwise = ASSERT(null payload) [mkIntCLit 0]
+ | otherwise = ASSERT(null payload) [mkIntCLit dflags 0]
static_link_field
| is_caf || staticClosureNeedsLink cl_info = [static_link_value]
| otherwise = []
saved_info_field
- | is_caf = [mkIntCLit 0]
+ | is_caf = [mkIntCLit dflags 0]
| otherwise = []
-- for a static constructor which has NoCafRefs, we set the
-- static link field to a non-zero value so the garbage
-- collector will ignore it.
static_link_value
- | caf_refs = mkIntCLit 0
- | otherwise = mkIntCLit 1
+ | caf_refs = mkIntCLit dflags 0
+ | otherwise = mkIntCLit dflags 1
mkStaticClosure :: DynFlags -> CLabel -> CostCentreStack -> [CmmLit]
-> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit]
@@ -412,18 +412,18 @@ unbxTupleHeapCheck regs ptrs nptrs fail_code code
| ptrs > 255 || nptrs > 255 = panic "altHeapCheck"
| otherwise
= initHeapUsage $ \ hpHw -> do
- { codeOnly $ do { do_checks 0 {- no stack check -} hpHw
+ { dflags <- getDynFlags
+ ; let full_fail_code = fail_code `plusStmts` oneStmt assign_liveness
+ assign_liveness = CmmAssign (CmmGlobal (VanillaReg 9 VNonGcPtr)) -- Ho ho ho!
+ (CmmLit (mkWordCLit dflags liveness))
+ liveness = mkRegLiveness regs ptrs nptrs
+ live = Just $ map snd regs
+ rts_label = CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "stg_gc_ut")))
+ ; codeOnly $ do { do_checks 0 {- no stack check -} hpHw
full_fail_code rts_label live
; tickyAllocHeap hpHw }
; setRealHp hpHw
; code }
- where
- full_fail_code = fail_code `plusStmts` oneStmt assign_liveness
- assign_liveness = CmmAssign (CmmGlobal (VanillaReg 9 VNonGcPtr)) -- Ho ho ho!
- (CmmLit (mkWordCLit liveness))
- liveness = mkRegLiveness regs ptrs nptrs
- live = Just $ map snd regs
- rts_label = CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "stg_gc_ut")))
\end{code}
@@ -462,15 +462,27 @@ do_checks _ hp _ _ _
"structures in the code."])
do_checks stk hp reg_save_code rts_lbl live
- = do_checks' (mkIntExpr (stk*wORD_SIZE))
- (mkIntExpr (hp*wORD_SIZE))
- (stk /= 0) (hp /= 0) reg_save_code rts_lbl live
+ = do dflags <- getDynFlags
+ do_checks' (mkIntExpr dflags (stk*wORD_SIZE))
+ (mkIntExpr dflags (hp*wORD_SIZE))
+ (stk /= 0) (hp /= 0) reg_save_code rts_lbl live
-- The offsets are now in *bytes*
do_checks' :: CmmExpr -> CmmExpr -> Bool -> Bool -> CmmStmts -> CmmExpr
-> Maybe [GlobalReg] -> Code
do_checks' stk_expr hp_expr stk_nonzero hp_nonzero reg_save_code rts_lbl live
= do { dflags <- getDynFlags
+
+ -- Stk overflow if (Sp - stk_bytes < SpLim)
+ ; let stk_oflo = CmmMachOp (mo_wordULt dflags)
+ [CmmMachOp (mo_wordSub dflags) [CmmReg spReg, stk_expr],
+ CmmReg (CmmGlobal SpLim)]
+
+ -- Hp overflow if (Hp > HpLim)
+ -- (Hp has been incremented by now)
+ -- HpLim points to the LAST WORD of valid allocation space.
+ hp_oflo = CmmMachOp (mo_wordUGt dflags)
+ [CmmReg hpReg, CmmReg (CmmGlobal HpLim)]
; doGranAllocate hp_expr
@@ -506,17 +518,6 @@ do_checks' stk_expr hp_expr stk_nonzero hp_nonzero reg_save_code rts_lbl live
-- with slop at the end of the current block, which can
-- confuse the LDV profiler.
}
- where
- -- Stk overflow if (Sp - stk_bytes < SpLim)
- stk_oflo = CmmMachOp mo_wordULt
- [CmmMachOp mo_wordSub [CmmReg spReg, stk_expr],
- CmmReg (CmmGlobal SpLim)]
-
- -- Hp overflow if (Hp > HpLim)
- -- (Hp has been incremented by now)
- -- HpLim points to the LAST WORD of valid allocation space.
- hp_oflo = CmmMachOp mo_wordUGt
- [CmmReg hpReg, CmmReg (CmmGlobal HpLim)]
\end{code}
%************************************************************************
@@ -532,15 +533,16 @@ hpChkGen bytes liveness reentry
let platform = targetPlatform dflags
assigns = mkStmts [ mk_vanilla_assignment dflags 9 liveness,
mk_vanilla_assignment dflags 10 reentry ]
- do_checks' zeroExpr bytes False True assigns
+ do_checks' (zeroExpr dflags) bytes False True assigns
stg_gc_gen (Just (activeStgRegs platform))
-- a heap check where R1 points to the closure to enter on return, and
-- we want to assign to Sp[0] on failure (used in AutoApply.cmm:BUILD_PAP).
hpChkNodePointsAssignSp0 :: CmmExpr -> CmmExpr -> Code
hpChkNodePointsAssignSp0 bytes sp0
- = do_checks' zeroExpr bytes False True assign
- stg_gc_enter1 (Just [node])
+ = do dflags <- getDynFlags
+ do_checks' (zeroExpr dflags) bytes False True assign
+ stg_gc_enter1 (Just [node])
where assign = oneStmt (CmmStore (CmmReg spReg) sp0)
stkChkGen :: CmmExpr -> CmmExpr -> CmmExpr -> Code
@@ -549,7 +551,7 @@ stkChkGen bytes liveness reentry
let platform = targetPlatform dflags
assigns = mkStmts [ mk_vanilla_assignment dflags 9 liveness,
mk_vanilla_assignment dflags 10 reentry ]
- do_checks' bytes zeroExpr True False assigns
+ do_checks' bytes (zeroExpr dflags) True False assigns
stg_gc_gen (Just (activeStgRegs platform))
mk_vanilla_assignment :: DynFlags -> Int -> CmmExpr -> CmmStmt
@@ -558,8 +560,9 @@ mk_vanilla_assignment dflags n e
stkChkNodePoints :: CmmExpr -> Code
stkChkNodePoints bytes
- = do_checks' bytes zeroExpr True False noStmts
- stg_gc_enter1 (Just [node])
+ = do dflags <- getDynFlags
+ do_checks' bytes (zeroExpr dflags) True False noStmts
+ stg_gc_enter1 (Just [node])
stg_gc_gen :: CmmExpr
stg_gc_gen = CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "stg_gc_gen")))