summaryrefslogtreecommitdiff
path: root/rts/sm/GCUtils.c
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2006-10-24 09:13:57 +0000
committerSimon Marlow <simonmar@microsoft.com>2006-10-24 09:13:57 +0000
commitab0e778ccfde61aed4c22679b24d175fc6cc9bf3 (patch)
treea0f6148a77644c5a7baa68b521bf3b1116dce50b /rts/sm/GCUtils.c
parent2246c514eade324d70058ba3135dc0c51ee9353b (diff)
downloadhaskell-ab0e778ccfde61aed4c22679b24d175fc6cc9bf3.tar.gz
Split GC.c, and move storage manager into sm/ directory
In preparation for parallel GC, split up the monolithic GC.c file into smaller parts. Also in this patch (and difficult to separate, unfortunatley): - Don't include Stable.h in Rts.h, instead just include it where necessary. - consistently use STATIC_INLINE in source files, and INLINE_HEADER in header files. STATIC_INLINE is now turned off when DEBUG is on, to make debugging easier. - The GC no longer takes the get_roots function as an argument. We weren't making use of this generalisation.
Diffstat (limited to 'rts/sm/GCUtils.c')
-rw-r--r--rts/sm/GCUtils.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/rts/sm/GCUtils.c b/rts/sm/GCUtils.c
new file mode 100644
index 0000000000..6e1fb302d8
--- /dev/null
+++ b/rts/sm/GCUtils.c
@@ -0,0 +1,79 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team 1998-2006
+ *
+ * Generational garbage collector: utilities
+ *
+ * ---------------------------------------------------------------------------*/
+
+#include "Rts.h"
+#include "Storage.h"
+#include "GC.h"
+#include "GCUtils.h"
+
+/* -----------------------------------------------------------------------------
+ Allocate a new to-space block in the given step.
+ -------------------------------------------------------------------------- */
+
+bdescr *
+gc_alloc_block(step *stp)
+{
+ bdescr *bd = allocBlock();
+ bd->gen_no = stp->gen_no;
+ bd->step = stp;
+ bd->link = NULL;
+
+ // blocks in to-space in generations up to and including N
+ // get the BF_EVACUATED flag.
+ if (stp->gen_no <= N) {
+ bd->flags = BF_EVACUATED;
+ } else {
+ bd->flags = 0;
+ }
+
+ // Start a new to-space block, chain it on after the previous one.
+ if (stp->hp_bd != NULL) {
+ stp->hp_bd->free = stp->hp;
+ stp->hp_bd->link = bd;
+ }
+
+ stp->hp_bd = bd;
+ stp->hp = bd->start;
+ stp->hpLim = stp->hp + BLOCK_SIZE_W;
+
+ stp->n_blocks++;
+ new_blocks++;
+
+ return bd;
+}
+
+bdescr *
+gc_alloc_scavd_block(step *stp)
+{
+ bdescr *bd = allocBlock();
+ bd->gen_no = stp->gen_no;
+ bd->step = stp;
+
+ // blocks in to-space in generations up to and including N
+ // get the BF_EVACUATED flag.
+ if (stp->gen_no <= N) {
+ bd->flags = BF_EVACUATED;
+ } else {
+ bd->flags = 0;
+ }
+
+ bd->link = stp->blocks;
+ stp->blocks = bd;
+
+ if (stp->scavd_hp != NULL) {
+ Bdescr(stp->scavd_hp)->free = stp->scavd_hp;
+ }
+ stp->scavd_hp = bd->start;
+ stp->scavd_hpLim = stp->scavd_hp + BLOCK_SIZE_W;
+
+ stp->n_blocks++;
+ new_scavd_blocks++;
+
+ return bd;
+}
+