summaryrefslogtreecommitdiff
path: root/ghc/rts/GCCompact.h
diff options
context:
space:
mode:
authorsimonmar <unknown>2001-07-23 17:23:20 +0000
committersimonmar <unknown>2001-07-23 17:23:20 +0000
commitdfd7d6d02a597949b08161ae3d49dc6dfc9e812d (patch)
tree4afa5a75fa30ebbe08247543c3863a49ed54a792 /ghc/rts/GCCompact.h
parent9528fa3e6229f36e424c5e327255694066017e10 (diff)
downloadhaskell-dfd7d6d02a597949b08161ae3d49dc6dfc9e812d.tar.gz
[project @ 2001-07-23 17:23:19 by simonmar]
Add a compacting garbage collector. It isn't enabled by default, as there are still a couple of problems: there's a fallback case I haven't implemented yet which means it will occasionally bomb out, and speed-wise it's quite a bit slower than the copying collector (about 1.8x slower). Until I can make it go faster, it'll only be useful when you're actually running low on real memory. '+RTS -c' to enable it. Oh, and I cleaned up a few things in the RTS while I was there, and fixed one or two possibly real bugs in the existing GC.
Diffstat (limited to 'ghc/rts/GCCompact.h')
-rw-r--r--ghc/rts/GCCompact.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/ghc/rts/GCCompact.h b/ghc/rts/GCCompact.h
new file mode 100644
index 0000000000..8244e87c45
--- /dev/null
+++ b/ghc/rts/GCCompact.h
@@ -0,0 +1,30 @@
+/* -----------------------------------------------------------------------------
+ * $Id: GCCompact.h,v 1.1 2001/07/23 17:23:19 simonmar Exp $
+ *
+ * (c) The GHC Team 1998-1999
+ *
+ * Compacting garbage collector
+ *
+ * ---------------------------------------------------------------------------*/
+
+static inline void
+mark(StgPtr p, bdescr *bd)
+{
+ nat offset_within_block = p - bd->start; // in words
+ StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
+ (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
+ nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
+ *bitmap_word |= bit_mask;
+}
+
+static inline int
+is_marked(StgPtr p, bdescr *bd)
+{
+ nat offset_within_block = p - bd->start; // in words
+ StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
+ (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
+ nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
+ return (*bitmap_word & bit_mask);
+}
+
+void compact( void (*get_roots)(evac_fn) );