hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp
author stefank
Mon, 27 May 2013 15:22:59 +0200
changeset 17844 28ca9179db98
parent 17370 59a0620561fa
child 25351 7c198a690050
permissions -rw-r--r--
8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty Summary: Split SystemDictionary and ClassLoaderDataGraph root processing to help load balancing. Reviewed-by: tschatzl, johnc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
17370
59a0620561fa 8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents: 13952
diff changeset
     2
 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5080
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5080
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5080
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    26
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    27
#include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    28
#include "gc_implementation/parallelScavenge/objectStartArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    29
#include "gc_implementation/parallelScavenge/parMarkBitMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    30
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    31
#include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    32
#include "gc_implementation/parallelScavenge/psOldGen.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    33
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    34
#include "oops/objArrayKlass.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    35
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    36
#include "oops/oop.pcgc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    37
#include "utilities/stack.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
PSOldGen*            ParCompactionManager::_old_gen = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
ParCompactionManager**  ParCompactionManager::_manager_array = NULL;
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    41
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    42
RegionTaskQueue**              ParCompactionManager::_region_list = NULL;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    43
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
OopTaskQueueSet*     ParCompactionManager::_stack_array = NULL;
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
    45
ParCompactionManager::ObjArrayTaskQueueSet*
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
    46
  ParCompactionManager::_objarray_queues = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
ObjectStartArray*    ParCompactionManager::_start_array = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
ParMarkBitMap*       ParCompactionManager::_mark_bitmap = NULL;
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
    49
RegionTaskQueueSet*  ParCompactionManager::_region_array = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    51
uint*                 ParCompactionManager::_recycled_stack_index = NULL;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    52
int                   ParCompactionManager::_recycled_top = -1;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    53
int                   ParCompactionManager::_recycled_bottom = -1;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    54
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
ParCompactionManager::ParCompactionManager() :
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    56
    _action(CopyAndUpdate),
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    57
    _region_stack(NULL),
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    58
    _region_stack_index((uint)max_uintx) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  _old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  _start_array = old_gen()->start_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  marking_stack()->initialize();
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
    67
  _objarray_stack.initialize();
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    68
}
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    69
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    70
ParCompactionManager::~ParCompactionManager() {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    71
  delete _recycled_stack_index;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  assert(PSParallelCompact::gc_task_manager() != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    "Needed for initialization");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  _mark_bitmap = mbm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  assert(_manager_array == NULL, "Attempt to initialize twice");
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11178
diff changeset
    83
  _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1, mtGC);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
    84
  guarantee(_manager_array != NULL, "Could not allocate manager_array");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    86
  _region_list = NEW_C_HEAP_ARRAY(RegionTaskQueue*,
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11178
diff changeset
    87
                         parallel_gc_threads+1, mtGC);
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    88
  guarantee(_region_list != NULL, "Could not initialize promotion manager");
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    89
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11178
diff changeset
    90
  _recycled_stack_index = NEW_C_HEAP_ARRAY(uint, parallel_gc_threads, mtGC);
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    91
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    92
  // parallel_gc-threads + 1 to be consistent with the number of
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    93
  // compaction managers.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    94
  for(uint i=0; i<parallel_gc_threads + 1; i++) {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    95
    _region_list[i] = new RegionTaskQueue();
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    96
    region_list(i)->initialize();
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    97
  }
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
    98
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  _stack_array = new OopTaskQueueSet(parallel_gc_threads);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   100
  guarantee(_stack_array != NULL, "Could not allocate stack_array");
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   101
  _objarray_queues = new ObjArrayTaskQueueSet(parallel_gc_threads);
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   102
  guarantee(_objarray_queues != NULL, "Could not allocate objarray_queues");
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   103
  _region_array = new RegionTaskQueueSet(parallel_gc_threads);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   104
  guarantee(_region_array != NULL, "Could not allocate region_array");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Create and register the ParCompactionManager(s) for the worker threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    _manager_array[i] = new ParCompactionManager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    stack_array()->register_queue(i, _manager_array[i]->marking_stack());
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   111
    _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack);
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   112
    region_array()->register_queue(i, region_list(i));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // The VMThread gets its own ParCompactionManager, which is not available
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // for work stealing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  _manager_array[parallel_gc_threads] = new ParCompactionManager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  guarantee(_manager_array[parallel_gc_threads] != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    "Could not create ParCompactionManager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  assert(PSParallelCompact::gc_task_manager()->workers() != 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    "Not initialized?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   124
int ParCompactionManager::pop_recycled_stack_index() {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   125
  assert(_recycled_bottom <= _recycled_top, "list is empty");
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   126
  // Get the next available index
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   127
  if (_recycled_bottom < _recycled_top) {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   128
    uint cur, next, last;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   129
    do {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   130
      cur = _recycled_bottom;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   131
      next = cur + 1;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   132
      last = Atomic::cmpxchg(next, &_recycled_bottom, cur);
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   133
    } while (cur != last);
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   134
    return _recycled_stack_index[next];
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   135
  } else {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   136
    return -1;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   137
  }
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   138
}
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   139
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   140
void ParCompactionManager::push_recycled_stack_index(uint v) {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   141
  // Get the next available index
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   142
  int cur = Atomic::add(1, &_recycled_top);
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   143
  _recycled_stack_index[cur] = v;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   144
  assert(_recycled_bottom <= _recycled_top, "list top and bottom are wrong");
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   145
}
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   146
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
bool ParCompactionManager::should_update() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  assert(action() != NotValid, "Action is not set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  return (action() == ParCompactionManager::Update) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
         (action() == ParCompactionManager::CopyAndUpdate) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
         (action() == ParCompactionManager::UpdateAndCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
bool ParCompactionManager::should_copy() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  assert(action() != NotValid, "Action is not set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  return (action() == ParCompactionManager::Copy) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
         (action() == ParCompactionManager::CopyAndUpdate) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
         (action() == ParCompactionManager::UpdateAndCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   161
void ParCompactionManager::region_list_push(uint list_index,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   162
                                            size_t region_index) {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   163
  region_list(list_index)->push(region_index);
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   164
}
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   165
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   166
void ParCompactionManager::verify_region_list_empty(uint list_index) {
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   167
  assert(region_list(list_index)->is_empty(), "Not empty");
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   168
}
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   169
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
ParCompactionManager*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
ParCompactionManager::gc_thread_compaction_manager(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  assert(_manager_array != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  return _manager_array[index];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   177
void ParCompactionManager::follow_marking_stacks() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  do {
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   179
    // Drain the overflow stack first, to allow stealing from the marking stack.
5080
eff0cc882603 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 5076
diff changeset
   180
    oop obj;
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   181
    while (marking_stack()->pop_overflow(obj)) {
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   182
      obj->follow_contents(this);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   183
    }
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   184
    while (marking_stack()->pop_local(obj)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      obj->follow_contents(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
5080
eff0cc882603 6935839: excessive marking stack growth during full gcs
jcoomes
parents: 5076
diff changeset
   188
    // Process ObjArrays one at a time to avoid marking stack bloat.
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   189
    ObjArrayTask task;
17370
59a0620561fa 8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents: 13952
diff changeset
   190
    if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) {
59a0620561fa 8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents: 13952
diff changeset
   191
      ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   192
      k->oop_follow_contents(this, task.obj(), task.index());
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   193
    }
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   194
  } while (!marking_stacks_empty());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3795
diff changeset
   196
  assert(marking_stacks_empty(), "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   199
void ParCompactionManager::drain_region_stacks() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  do {
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   201
    // Drain overflow stack first so other threads can steal.
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   202
    size_t region_index;
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   203
    while (region_stack()->pop_overflow(region_index)) {
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   204
      PSParallelCompact::fill_and_update_region(this, region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
5918
73b96456819a 6957084: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   207
    while (region_stack()->pop_local(region_index)) {
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   208
      PSParallelCompact::fill_and_update_region(this, region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    }
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   210
  } while (!region_stack()->is_empty());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
}