[Git][ghc/ghc][wip/gc/docs] Deleted 1 commit: NonMoving: Introduce nonmovingSegmentLogBlockSize acccessor

Ben Gamari gitlab at gitlab.haskell.org
Fri May 17 18:26:55 UTC 2019



Ben Gamari pushed to branch wip/gc/docs at Glasgow Haskell Compiler / GHC


WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.


Deleted commits:
789282db by Ben Gamari at 2019-05-17T17:22:45Z
NonMoving: Introduce nonmovingSegmentLogBlockSize acccessor

This will allow us to easily move the block size elsewhere.

- - - - -


3 changed files:

- rts/sm/NonMoving.c
- rts/sm/NonMoving.h
- rts/sm/NonMovingMark.c


Changes:

=====================================
rts/sm/NonMoving.c
=====================================
@@ -287,13 +287,13 @@ static void* nonmovingConcurrentMark(void *mark_queue);
 static void nonmovingClearBitmap(struct NonmovingSegment *seg);
 static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO **resurrected_threads);
 
-static void nonmovingInitSegment(struct NonmovingSegment *seg, uint8_t block_size)
+static void nonmovingInitSegment(struct NonmovingSegment *seg, uint8_t log_block_size)
 {
     seg->link = NULL;
     seg->todo_link = NULL;
     seg->next_free = 0;
     seg->next_free_snap = 0;
-    seg->block_size = block_size;
+    seg->log_block_size = log_block_size;
     nonmovingClearBitmap(seg);
     Bdescr((P_)seg)->u.scan = nonmovingSegmentGetBlock(seg, 0);
 }
@@ -1043,12 +1043,13 @@ void assert_in_nonmoving_heap(StgPtr p)
 void nonmovingPrintSegment(struct NonmovingSegment *seg)
 {
     int num_blocks = nonmovingSegmentBlockCount(seg);
+    uint8_t log_block_size = nonmovingSegmentLogBlockSize(seg);
 
     debugBelch("Segment with %d blocks of size 2^%d (%d bytes, %lu words, scan: %p)\n",
                num_blocks,
-               seg->block_size,
-               1 << seg->block_size,
-               ROUNDUP_BYTES_TO_WDS(1 << seg->block_size),
+               log_block_size,
+               1 << log_block_size,
+               ROUNDUP_BYTES_TO_WDS(1 << log_block_size),
                (void*)Bdescr((P_)seg)->u.scan);
 
     for (nonmoving_block_idx p_idx = 0; p_idx < seg->next_free; ++p_idx) {


=====================================
rts/sm/NonMoving.h
=====================================
@@ -39,7 +39,7 @@ struct NonmovingSegment {
     struct NonmovingSegment *todo_link; // NULL when not in todo list
     nonmoving_block_idx next_free;      // index of the next unallocated block
     nonmoving_block_idx next_free_snap; // snapshot of next_free
-    uint8_t block_size;                 // log2 of block size in bytes
+    uint8_t log_block_size;             // log2 of block size in bytes
     uint8_t bitmap[];                   // liveness bitmap
     // After the liveness bitmap comes the data blocks. Note that we need to
     // ensure that the size of this struct (including the bitmap) is a multiple
@@ -118,11 +118,15 @@ void *nonmovingAllocate(Capability *cap, StgWord sz);
 void nonmovingAddCapabilities(uint32_t new_n_caps);
 void nonmovingPushFreeSegment(struct NonmovingSegment *seg);
 
+INLINE_HEADER void nonmovingSegmentLogBlockSize(struct NonmovingSegment *seg) {
+    return seg->log_block_size;
+}
+
 // Add a segment to the appropriate active list.
 INLINE_HEADER void nonmovingPushActiveSegment(struct NonmovingSegment *seg)
 {
     struct NonmovingAllocator *alloc =
-        nonmovingHeap.allocators[seg->block_size - NONMOVING_ALLOCA0];
+        nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0];
     while (true) {
         struct NonmovingSegment *current_active = (struct NonmovingSegment*)VOLATILE_LOAD(&alloc->active);
         seg->link = current_active;
@@ -136,7 +140,7 @@ INLINE_HEADER void nonmovingPushActiveSegment(struct NonmovingSegment *seg)
 INLINE_HEADER void nonmovingPushFilledSegment(struct NonmovingSegment *seg)
 {
     struct NonmovingAllocator *alloc =
-        nonmovingHeap.allocators[seg->block_size - NONMOVING_ALLOCA0];
+        nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0];
     while (true) {
         struct NonmovingSegment *current_filled = (struct NonmovingSegment*)VOLATILE_LOAD(&alloc->filled);
         seg->link = current_filled;
@@ -157,7 +161,7 @@ void assert_in_nonmoving_heap(StgPtr p);
 // The block size of a given segment in bytes.
 INLINE_HEADER unsigned int nonmovingSegmentBlockSize(struct NonmovingSegment *seg)
 {
-    return 1 << seg->block_size;
+    return 1 << nonmovingSegmentLogBlockSize(seg);
 }
 
 // How many blocks does a segment with the given block size have?
@@ -175,7 +179,7 @@ unsigned int nonmovingBlockCountFromSize(uint8_t log_block_size);
 // How many blocks does the given segment contain? Also the size of the bitmap.
 INLINE_HEADER unsigned int nonmovingSegmentBlockCount(struct NonmovingSegment *seg)
 {
-  return nonmovingBlockCountFromSize(seg->block_size);
+  return nonmovingBlockCountFromSize(nonmovingSegmentLogBlockSize(seg));
 }
 
 // Get a pointer to the given block index assuming that the block size is as
@@ -183,7 +187,7 @@ INLINE_HEADER unsigned int nonmovingSegmentBlockCount(struct NonmovingSegment *s
 // available). The log_block_size argument must be equal to seg->block_size.
 INLINE_HEADER void *nonmovingSegmentGetBlock_(struct NonmovingSegment *seg, uint8_t log_block_size, nonmoving_block_idx i)
 {
-  ASSERT(log_block_size == seg->block_size);
+  ASSERT(log_block_size == nonmovingSegmentLogBlockSize(seg));
   // Block size in bytes
   unsigned int blk_size = 1 << log_block_size;
   // Bitmap size in bytes
@@ -199,7 +203,7 @@ INLINE_HEADER void *nonmovingSegmentGetBlock_(struct NonmovingSegment *seg, uint
 // Get a pointer to the given block index.
 INLINE_HEADER void *nonmovingSegmentGetBlock(struct NonmovingSegment *seg, nonmoving_block_idx i)
 {
-  return nonmovingSegmentGetBlock_(seg, seg->block_size, i);
+  return nonmovingSegmentGetBlock_(seg, nonmovingSegmentLogBlockSize(seg), i);
 }
 
 // Get the segment which a closure resides in. Assumes that pointer points into
@@ -222,7 +226,7 @@ INLINE_HEADER nonmoving_block_idx nonmovingGetBlockIdx(StgPtr p)
     struct NonmovingSegment *seg = nonmovingGetSegment(p);
     ptrdiff_t blk0 = (ptrdiff_t)nonmovingSegmentGetBlock(seg, 0);
     ptrdiff_t offset = (ptrdiff_t)p - blk0;
-    return (nonmoving_block_idx) (offset >> seg->block_size);
+    return (nonmoving_block_idx) (offset >> nonmovingSegmentLogBlockSize(seg));
 }
 
 // TODO: Eliminate this


=====================================
rts/sm/NonMovingMark.c
=====================================
@@ -764,7 +764,7 @@ static MarkQueueEnt markQueuePop (MarkQueue *q)
         // MarkQueueEnt encoding always places the pointer to the object to be
         // marked first.
         __builtin_prefetch(&new.mark_closure.p->header.info, 0, 0);
-        __builtin_prefetch(&nonmovingGetSegment_unchecked((StgPtr) new.mark_closure.p)->block_size, 0, 0);
+        __builtin_prefetch(&nonmovingGetSegment_unchecked((StgPtr) new.mark_closure.p)->log_block_size, 0, 0);
         q->prefetch_queue[i] = new;
         i = (i + 1) % MARK_PREFETCH_QUEUE_DEPTH;
     }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/789282dbed0a4942792ce78cd5b768aa643e49d6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/789282dbed0a4942792ce78cd5b768aa643e49d6
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190517/2a26d916/attachment-0001.html>


More information about the ghc-commits mailing list