src/hotspot/share/gc/parallel/psCardTable.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54110 f4f0dce5d0bb
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  *
    22  *
    23  */
    23  */
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "gc/parallel/gcTaskManager.hpp"
       
    27 #include "gc/parallel/objectStartArray.inline.hpp"
    26 #include "gc/parallel/objectStartArray.inline.hpp"
    28 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
    27 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
    29 #include "gc/parallel/psCardTable.hpp"
    28 #include "gc/parallel/psCardTable.hpp"
    30 #include "gc/parallel/psPromotionManager.inline.hpp"
    29 #include "gc/parallel/psPromotionManager.inline.hpp"
    31 #include "gc/parallel/psScavenge.inline.hpp"
    30 #include "gc/parallel/psScavenge.inline.hpp"
    32 #include "gc/parallel/psTasks.hpp"
       
    33 #include "gc/parallel/psYoungGen.hpp"
    31 #include "gc/parallel/psYoungGen.hpp"
    34 #include "memory/iterator.inline.hpp"
    32 #include "memory/iterator.inline.hpp"
    35 #include "oops/access.inline.hpp"
    33 #include "oops/access.inline.hpp"
    36 #include "oops/oop.inline.hpp"
    34 #include "oops/oop.inline.hpp"
    37 #include "runtime/prefetch.inline.hpp"
    35 #include "runtime/prefetch.inline.hpp"
   125 // Do not call this method if the space is empty.
   123 // Do not call this method if the space is empty.
   126 // It is a waste to start tasks and get here only to
   124 // It is a waste to start tasks and get here only to
   127 // do no work.  If this method needs to be called
   125 // do no work.  If this method needs to be called
   128 // when the space is empty, fix the calculation of
   126 // when the space is empty, fix the calculation of
   129 // end_card to allow sp_top == sp->bottom().
   127 // end_card to allow sp_top == sp->bottom().
       
   128 
       
   129 // The generation (old gen) is divided into slices, which are further
       
   130 // subdivided into stripes, with one stripe per GC thread. The size of
       
   131 // a stripe is a constant, ssize.
       
   132 //
       
   133 //      +===============+        slice 0
       
   134 //      |  stripe 0     |
       
   135 //      +---------------+
       
   136 //      |  stripe 1     |
       
   137 //      +---------------+
       
   138 //      |  stripe 2     |
       
   139 //      +---------------+
       
   140 //      |  stripe 3     |
       
   141 //      +===============+        slice 1
       
   142 //      |  stripe 0     |
       
   143 //      +---------------+
       
   144 //      |  stripe 1     |
       
   145 //      +---------------+
       
   146 //      |  stripe 2     |
       
   147 //      +---------------+
       
   148 //      |  stripe 3     |
       
   149 //      +===============+        slice 2
       
   150 //      ...
       
   151 //
       
   152 // In this case there are 4 threads, so 4 stripes.  A GC thread first works on
       
   153 // its stripe within slice 0 and then moves to its stripe in the next slice
       
   154 // until it has exceeded the top of the generation.  The distance to stripe in
       
   155 // the next slice is calculated based on the number of stripes.  The next
       
   156 // stripe is at ssize * number_of_stripes (= slice_stride)..  So after
       
   157 // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1 by
       
   158 // adding slice_stride to the start of stripe 0 in slice 0 to get to the start
       
   159 // of stride 0 in slice 1.
   130 
   160 
   131 void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
   161 void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
   132                                              MutableSpace* sp,
   162                                              MutableSpace* sp,
   133                                              HeapWord* space_top,
   163                                              HeapWord* space_top,
   134                                              PSPromotionManager* pm,
   164                                              PSPromotionManager* pm,
   168 #ifdef ASSERT
   198 #ifdef ASSERT
   169     if (GCWorkerDelayMillis > 0) {
   199     if (GCWorkerDelayMillis > 0) {
   170       // Delay 1 worker so that it proceeds after all the work
   200       // Delay 1 worker so that it proceeds after all the work
   171       // has been completed.
   201       // has been completed.
   172       if (stripe_number < 2) {
   202       if (stripe_number < 2) {
   173         os::sleep(Thread::current(), GCWorkerDelayMillis, false);
   203         os::naked_sleep(GCWorkerDelayMillis);
   174       }
   204       }
   175     }
   205     }
   176 #endif
   206 #endif
   177 
   207 
   178     // If there are not objects starting within the chunk, skip it.
   208     // If there are not objects starting within the chunk, skip it.