src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp

Print this page
rev 6480 : imported patch 8035400-move-g1parscanthreadstate-into-own-files
rev 6481 : imported patch 8035400-2-bengt-fixes
rev 6482 : imported patch 8035401-fix-visibility-of-g1parscanthreadstate
rev 6483 : imported patch 8035401-3-fix-constructor
rev 6484 : [mq]: 8035401-2-another-inline-try
rev 6485 : [mq]: 8040977-g1-crashes-with-G1DeferredRSUpdate-disabled


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  27 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
  28 #include "gc_implementation/g1/g1ParScanThreadState.inline.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "oops/oop.pcgc.inline.hpp"
  31 #include "runtime/prefetch.inline.hpp"
  32 
  33 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
  34 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
  35 #endif // _MSC_VER
  36 
  37 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp)
  38   : _g1h(g1h),
  39     _refs(g1h->task_queue(queue_num)),
  40     _dcq(&g1h->dirty_card_queue_set()),
  41     _ct_bs(g1h->g1_barrier_set()),
  42     _g1_rem(g1h->g1_rem_set()),
  43     _hash_seed(17), _queue_num(queue_num),
  44     _term_attempts(0),
  45     _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
  46     _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)),
  47     _age_table(false), _scanner(g1h, this, rp),
  48     _strong_roots_time(0), _term_time(0),
  49     _alloc_buffer_waste(0), _undo_waste(0) {

  50   // we allocate G1YoungSurvRateNumRegions plus one entries, since
  51   // we "sacrifice" entry 0 to keep track of surviving bytes for
  52   // non-young regions (where the age is -1)
  53   // We also add a few elements at the beginning and at the end in
  54   // an attempt to eliminate cache contention
  55   uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
  56   uint array_length = PADDING_ELEM_NUM +
  57                       real_length +
  58                       PADDING_ELEM_NUM;
  59   _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
  60   if (_surviving_young_words_base == NULL)
  61     vm_exit_out_of_memory(array_length * sizeof(size_t), OOM_MALLOC_ERROR,
  62                           "Not enough space for young surv histo.");
  63   _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
  64   memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
  65 
  66   _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
  67   _alloc_buffers[GCAllocForTenured]  = &_tenured_alloc_buffer;
  68 
  69   _start = os::elapsedTime();




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  27 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
  28 #include "gc_implementation/g1/g1ParScanThreadState.inline.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "oops/oop.pcgc.inline.hpp"
  31 #include "runtime/prefetch.inline.hpp"
  32 




  33 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp)
  34   : _g1h(g1h),
  35     _refs(g1h->task_queue(queue_num)),
  36     _dcq(&g1h->dirty_card_queue_set()),
  37     _ct_bs(g1h->g1_barrier_set()),
  38     _g1_rem(g1h->g1_rem_set()),
  39     _hash_seed(17), _queue_num(queue_num),
  40     _term_attempts(0),
  41     _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
  42     _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)),
  43     _age_table(false), _scanner(g1h, rp),
  44     _strong_roots_time(0), _term_time(0),
  45     _alloc_buffer_waste(0), _undo_waste(0) {
  46   _scanner.set_par_scan_thread_state(this);
  47   // we allocate G1YoungSurvRateNumRegions plus one entries, since
  48   // we "sacrifice" entry 0 to keep track of surviving bytes for
  49   // non-young regions (where the age is -1)
  50   // We also add a few elements at the beginning and at the end in
  51   // an attempt to eliminate cache contention
  52   uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
  53   uint array_length = PADDING_ELEM_NUM +
  54                       real_length +
  55                       PADDING_ELEM_NUM;
  56   _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
  57   if (_surviving_young_words_base == NULL)
  58     vm_exit_out_of_memory(array_length * sizeof(size_t), OOM_MALLOC_ERROR,
  59                           "Not enough space for young surv histo.");
  60   _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
  61   memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
  62 
  63   _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
  64   _alloc_buffers[GCAllocForTenured]  = &_tenured_alloc_buffer;
  65 
  66   _start = os::elapsedTime();