summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Barton <rwbarton@gmail.com>2016-02-29 17:35:43 -0500
committerReid Barton <rwbarton@gmail.com>2016-02-29 17:35:43 -0500
commit0fd5db798e31912f335e4553e939e1e783284495 (patch)
tree43f1d3c8466b7e4276dfb3bb25e2a1839d7265f8
parent49c55e68aae9841c166430ae566b0d9bdc03c99d (diff)
downloadhaskell-wip/rwbarton-tiny-tables.tar.gz
Experiment with one-byte info tableswip/rwbarton-tiny-tables
-rw-r--r--compiler/cmm/CmmInfo.hs12
-rw-r--r--compiler/nativeGen/X86/Ppr.hs5
-rw-r--r--includes/rts/storage/ClosureMacros.h15
-rw-r--r--rts/ThreadPaused.c8
-rw-r--r--rts/sm/Scav.c20
5 files changed, 59 insertions, 1 deletions
diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs
index b9981f247b..299f7bb271 100644
--- a/compiler/cmm/CmmInfo.hs
+++ b/compiler/cmm/CmmInfo.hs
@@ -194,7 +194,11 @@ mkInfoTableContents dflags
| null liveness_data = rET_SMALL -- Fits in extra_bits
| otherwise = rET_BIG -- Does not; extra_bits is
-- a label
- ; return (prof_data ++ liveness_data, (std_info, srt_label)) }
+ mb_tiny_liveness = mkTinyLivenessBits frame
+ ; case (prof_data, liveness_data, srt_label, rts_tag == rET_SMALL,
+ srt_bitmap == toStgHalfWord dflags 0, mb_tiny_liveness) of
+ ([], [], [], True, True, Just b) -> return ([], ([b], []))
+ _ -> return (prof_data ++ liveness_data, (std_info, srt_label)) }
| HeapRep _ ptrs nonptrs closure_type <- smrep
= do { let layout = packIntsCLit dflags ptrs nonptrs
@@ -317,6 +321,12 @@ makeRelativeRefTo _ _ lit = lit
-- The head of the stack layout is the top of the stack and
-- the least-significant bit.
+mkTinyLivenessBits :: Liveness -> Maybe CmmLit
+mkTinyLivenessBits liveness
+ | length liveness > 7 = Nothing
+ | otherwise = Just (CmmInt b W8)
+ where b = foldr (.|.) 0 [ 1 `shiftL` n | (True,n) <- zip (liveness ++ [True]) [0..] ]
+
mkLivenessBits :: DynFlags -> Liveness -> UniqSM (CmmLit, [RawCmmDecl])
-- ^ Returns:
-- 1. The bitmap (literal value or label)
diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs
index 7809ae1df9..b5111a1a99 100644
--- a/compiler/nativeGen/X86/Ppr.hs
+++ b/compiler/nativeGen/X86/Ppr.hs
@@ -108,6 +108,11 @@ pprBasicBlock info_env (BasicBlock blockid instrs)
asmLbl = mkAsmTempLabel (getUnique blockid)
maybe_infotable = case mapLookup blockid info_env of
Nothing -> empty
+ Just (Statics info_lbl [b8@(CmmStaticLit (CmmInt _ W8))]) ->
+ text ".align 2" $$ -- XXX Needs to be adjusted for darwin
+ infoTableLoc $$
+ pprData b8 $$
+ pprLabel info_lbl
Just (Statics info_lbl info) ->
pprAlignForSection Text $$
infoTableLoc $$
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h
index d53487326f..a5966ab0cc 100644
--- a/includes/rts/storage/ClosureMacros.h
+++ b/includes/rts/storage/ClosureMacros.h
@@ -415,11 +415,26 @@ EXTERN_INLINE nat closure_sizeW (StgClosure *p)
Sizes of stack frames
-------------------------------------------------------------------------- */
+INLINE_HEADER StgWord tiny_bitmap_size(uint8_t liveness)
+{
+ StgWord bitmap_size = 0;
+ // XXX use a table or instruction?
+ while (liveness > 1) {
+ bitmap_size++;
+ liveness = liveness >> 1;
+ }
+ return bitmap_size;
+}
+
EXTERN_INLINE StgWord stack_frame_sizeW( StgClosure *frame );
EXTERN_INLINE StgWord stack_frame_sizeW( StgClosure *frame )
{
StgRetInfoTable *info;
+ if (*(P_)frame & 1) {
+ return 1 + tiny_bitmap_size(*(*(uint8_t **)frame - 1));
+ }
+
info = get_ret_itbl(frame);
switch (info->i.type) {
diff --git a/rts/ThreadPaused.c b/rts/ThreadPaused.c
index 1f1d0afe58..e0e616aec4 100644
--- a/rts/ThreadPaused.c
+++ b/rts/ThreadPaused.c
@@ -219,6 +219,14 @@ threadPaused(Capability *cap, StgTSO *tso)
frame = (StgClosure *)tso->stackobj->sp;
while ((P_)frame < stack_end) {
+ if (*(P_)frame & 1) {
+ nat frame_size = stack_frame_sizeW(frame);
+ weight_pending += frame_size;
+ frame = (StgClosure *)((StgPtr)frame + frame_size);
+ prev_was_update_frame = rtsFalse;
+ continue;
+ }
+
info = get_ret_itbl(frame);
switch (info->i.type) {
diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c
index 953f055d57..b6783749c5 100644
--- a/rts/sm/Scav.c
+++ b/rts/sm/Scav.c
@@ -174,6 +174,19 @@ static StgPtr scavenge_mut_arr_ptrs_marked (StgMutArrPtrs *a)
}
STATIC_INLINE StgPtr
+scavenge_tiny_bitmap (StgPtr p, uint8_t layout)
+{
+ while (layout > 1) {
+ if ((layout & 1) == 0) {
+ evacuate((StgClosure **)p);
+ }
+ p++;
+ layout = layout >> 1;
+ }
+ return p;
+}
+
+STATIC_INLINE StgPtr
scavenge_small_bitmap (StgPtr p, StgWord size, StgWord bitmap)
{
while (size > 0) {
@@ -1807,6 +1820,13 @@ scavenge_stack(StgPtr p, StgPtr stack_end)
*/
while (p < stack_end) {
+ if (*p & 1) {
+ // Tiny liveness layout: no SRT
+ uint8_t liveness = *((uint8_t *)(*p) - 1);
+ p = scavenge_tiny_bitmap(p+1, liveness);
+ continue;
+ }
+
info = get_ret_itbl((StgClosure *)p);
switch (info->i.type) {