rts: Update some comments, minor refactoring
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Wed, 27 Jun 2018 07:31:29 +0000 (10:31 +0300)
committerÖmer Sinan Ağacan <omeragacan@gmail.com>
Wed, 27 Jun 2018 07:31:29 +0000 (10:31 +0300)
includes/rts/storage/GC.h
rts/Capability.h
rts/sm/Storage.c

index d4182dd..1571975 100644 (file)
@@ -109,7 +109,12 @@ typedef struct generation_ {
     memcount       n_compact_blocks_in_import; // no. of blocks used by compacts
                                                // being imported
 
-    memcount       max_blocks;          // max blocks
+    // Max blocks to allocate in this generation before collecting it. Collect
+    // this generation when
+    //
+    //     n_blocks + n_large_blocks + n_compact_blocks > max_blocks
+    //
+    memcount       max_blocks;
 
     StgTSO *       threads;             // threads in this gen
                                         // linked via global_link
index e4df0b8..250ec22 100644 (file)
@@ -109,7 +109,7 @@ struct Capability_ {
     int interrupt;
 
     // Total words allocated by this cap since rts start
-    // See [Note allocation accounting] in Storage.c
+    // See Note [allocation accounting] in Storage.c
     W_ total_allocated;
 
 #if defined(THREADED_RTS)
index cea7635..dcc5b3a 100644 (file)
@@ -1158,7 +1158,7 @@ dirty_MVAR(StgRegTable *reg, StgClosure *p)
  * -------------------------------------------------------------------------- */
 
 /* -----------------------------------------------------------------------------
- * [Note allocation accounting]
+ * Note [allocation accounting]
  *
  *   - When cap->r.rCurrentNusery moves to a new block in the nursery,
  *     we add the size of the used portion of the previous block to
@@ -1271,9 +1271,8 @@ W_ gcThreadLiveBlocks (uint32_t i, uint32_t g)
 extern W_
 calcNeeded (bool force_major, memcount *blocks_needed)
 {
-    W_ needed = 0, blocks;
-    uint32_t g, N;
-    generation *gen;
+    W_ needed = 0;
+    uint32_t N;
 
     if (force_major) {
         N = RtsFlags.GcFlags.generations - 1;
@@ -1281,12 +1280,12 @@ calcNeeded (bool force_major, memcount *blocks_needed)
         N = 0;
     }
 
-    for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
-        gen = &generations[g];
+    for (uint32_t g = 0; g < RtsFlags.GcFlags.generations; g++) {
+        generation *gen = &generations[g];
 
-        blocks = gen->n_blocks // or: gen->n_words / BLOCK_SIZE_W (?)
-               + gen->n_large_blocks
-               + gen->n_compact_blocks;
+        W_ blocks = gen->n_blocks // or: gen->n_words / BLOCK_SIZE_W (?)
+                  + gen->n_large_blocks
+                  + gen->n_compact_blocks;
 
         // we need at least this much space
         needed += blocks;