hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp
author xdono
Tue, 22 Sep 2009 14:06:10 -0700
changeset 3795 6227ff014cfe
parent 3696 9e5d9b5e1049
child 5076 8b74a4b60b31
permissions -rw-r--r--
6884624: Update copyright year Summary: Update copyright for files that have been modified in 2009 through Septermber Reviewed-by: tbell, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
3795
6227ff014cfe 6884624: Update copyright year
xdono
parents: 3696
diff changeset
     2
 * Copyright 2005-2009 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_psCompactionManager.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
PSOldGen*            ParCompactionManager::_old_gen = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
ParCompactionManager**  ParCompactionManager::_manager_array = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
OopTaskQueueSet*     ParCompactionManager::_stack_array = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
ObjectStartArray*    ParCompactionManager::_start_array = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
ParMarkBitMap*       ParCompactionManager::_mark_bitmap = NULL;
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
    33
RegionTaskQueueSet*   ParCompactionManager::_region_array = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
ParCompactionManager::ParCompactionManager() :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
    _action(CopyAndUpdate) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  _old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  _start_array = old_gen()->start_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  marking_stack()->initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // We want the overflow stack to be permanent
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  _overflow_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(10, true);
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
    49
#ifdef USE_RegionTaskQueueWithOverflow
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
    50
  region_stack()->initialize();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
#else
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
    52
  region_stack()->initialize();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // We want the overflow stack to be permanent
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
    55
  _region_overflow_stack =
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    new (ResourceObj::C_HEAP) GrowableArray<size_t>(10, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Note that _revisit_klass_stack is allocated out of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // C heap (as opposed to out of ResourceArena).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  int size =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    (SystemDictionary::number_of_classes() * 2) * 2 / ParallelGCThreads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  _revisit_klass_stack = new (ResourceObj::C_HEAP) GrowableArray<Klass*>(size, true);
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 1623
diff changeset
    64
  // From some experiments (#klass/k)^2 for k = 10 seems a better fit, but this will
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 1623
diff changeset
    65
  // have to do for now until we are able to investigate a more optimal setting.
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 1623
diff changeset
    66
  _revisit_mdo_stack = new (ResourceObj::C_HEAP) GrowableArray<DataLayout*>(size*2, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
ParCompactionManager::~ParCompactionManager() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  delete _overflow_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  delete _revisit_klass_stack;
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 1623
diff changeset
    73
  delete _revisit_mdo_stack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // _manager_array and _stack_array are statics
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // shared with all instances of ParCompactionManager
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // should not be deallocated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  assert(PSParallelCompact::gc_task_manager() != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    "Needed for initialization");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  _mark_bitmap = mbm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  uint parallel_gc_threads = PSParallelCompact::gc_task_manager()->workers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  assert(_manager_array == NULL, "Attempt to initialize twice");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  guarantee(_manager_array != NULL, "Could not initialize promotion manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  _stack_array = new OopTaskQueueSet(parallel_gc_threads);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  guarantee(_stack_array != NULL, "Count not initialize promotion manager");
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
    93
  _region_array = new RegionTaskQueueSet(parallel_gc_threads);
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
    94
  guarantee(_region_array != NULL, "Count not initialize promotion manager");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Create and register the ParCompactionManager(s) for the worker threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    _manager_array[i] = new ParCompactionManager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    stack_array()->register_queue(i, _manager_array[i]->marking_stack());
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   101
#ifdef USE_RegionTaskQueueWithOverflow
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   102
    region_array()->register_queue(i, _manager_array[i]->region_stack()->task_queue());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
#else
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   104
    region_array()->register_queue(i, _manager_array[i]->region_stack());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // The VMThread gets its own ParCompactionManager, which is not available
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // for work stealing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  _manager_array[parallel_gc_threads] = new ParCompactionManager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  guarantee(_manager_array[parallel_gc_threads] != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    "Could not create ParCompactionManager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  assert(PSParallelCompact::gc_task_manager()->workers() != 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    "Not initialized?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
bool ParCompactionManager::should_update() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  assert(action() != NotValid, "Action is not set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  return (action() == ParCompactionManager::Update) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
         (action() == ParCompactionManager::CopyAndUpdate) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
         (action() == ParCompactionManager::UpdateAndCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
bool ParCompactionManager::should_copy() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  assert(action() != NotValid, "Action is not set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  return (action() == ParCompactionManager::Copy) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
         (action() == ParCompactionManager::CopyAndUpdate) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
         (action() == ParCompactionManager::UpdateAndCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
bool ParCompactionManager::should_verify_only() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  assert(action() != NotValid, "Action is not set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  return action() == ParCompactionManager::VerifyUpdate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
bool ParCompactionManager::should_reset_only() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  assert(action() != NotValid, "Action is not set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  return action() == ParCompactionManager::ResetObjects;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
// For now save on a stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
void ParCompactionManager::save_for_scanning(oop m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  stack_push(m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
void ParCompactionManager::stack_push(oop obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  if(!marking_stack()->push(obj)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    overflow_stack()->push(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
oop ParCompactionManager::retrieve_for_scanning() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Should not be used in the parallel case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   160
// Save region on a stack
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   161
void ParCompactionManager::save_for_processing(size_t region_index) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  const ParallelCompactData& sd = PSParallelCompact::summary_data();
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   164
  ParallelCompactData::RegionData* const region_ptr = sd.region(region_index);
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   165
  assert(region_ptr->claimed(), "must be claimed");
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   166
  assert(region_ptr->_pushed++ == 0, "should only be pushed once");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
#endif
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   168
  region_stack_push(region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   171
void ParCompactionManager::region_stack_push(size_t region_index) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   173
#ifdef USE_RegionTaskQueueWithOverflow
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   174
  region_stack()->save(region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
#else
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   176
  if(!region_stack()->push(region_index)) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   177
    region_overflow_stack()->push(region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   182
bool ParCompactionManager::retrieve_for_processing(size_t& region_index) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   183
#ifdef USE_RegionTaskQueueWithOverflow
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   184
  return region_stack()->retrieve(region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Should not be used in the parallel case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
ParCompactionManager*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
ParCompactionManager::gc_thread_compaction_manager(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  assert(_manager_array != NULL, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  return _manager_array[index];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
void ParCompactionManager::reset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  for(uint i=0; i<ParallelGCThreads+1; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    manager_array(i)->revisit_klass_stack()->clear();
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 1623
diff changeset
   202
    manager_array(i)->revisit_mdo_stack()->clear();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
void ParCompactionManager::drain_marking_stacks(OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  MutableSpace* to_space = heap->young_gen()->to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  MutableSpace* old_space = heap->old_gen()->object_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  MutableSpace* perm_space = heap->perm_gen()->object_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    // Drain overflow stack first, so other threads can steal from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    // claimed stack while we work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    while(!overflow_stack()->is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
      oop obj = overflow_stack()->pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
      obj->follow_contents(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    oop obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    // obj is a reference!!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    while (marking_stack()->pop_local(obj)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      // It would be nice to assert about the type of objects we might
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      // pop, but they can come from anywhere, unfortunately.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      obj->follow_contents(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  } while((marking_stack()->size() != 0) || (overflow_stack()->length() != 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  assert(marking_stack()->size() == 0, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  assert(overflow_stack()->length() == 0, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   238
void ParCompactionManager::drain_region_overflow_stack() {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   239
  size_t region_index = (size_t) -1;
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   240
  while(region_stack()->retrieve_from_overflow(region_index)) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   241
    PSParallelCompact::fill_and_update_region(this, region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   245
void ParCompactionManager::drain_region_stacks() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  MutableSpace* to_space = heap->young_gen()->to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  MutableSpace* old_space = heap->old_gen()->object_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  MutableSpace* perm_space = heap->perm_gen()->object_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
#if 1 // def DO_PARALLEL - the serial code hasn't been updated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   257
#ifdef USE_RegionTaskQueueWithOverflow
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    // Drain overflow stack first, so other threads can steal from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    // claimed stack while we work.
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   260
    size_t region_index = (size_t) -1;
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   261
    while(region_stack()->retrieve_from_overflow(region_index)) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   262
      PSParallelCompact::fill_and_update_region(this, region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   265
    while (region_stack()->retrieve_from_stealable_queue(region_index)) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   266
      PSParallelCompact::fill_and_update_region(this, region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    }
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   268
  } while (!region_stack()->is_empty());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    // Drain overflow stack first, so other threads can steal from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    // claimed stack while we work.
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   272
    while(!region_overflow_stack()->is_empty()) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   273
      size_t region_index = region_overflow_stack()->pop();
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   274
      PSParallelCompact::fill_and_update_region(this, region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   277
    size_t region_index = -1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    // obj is a reference!!!
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   279
    while (region_stack()->pop_local(region_index)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
      // It would be nice to assert about the type of objects we might
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
      // pop, but they can come from anywhere, unfortunately.
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   282
      PSParallelCompact::fill_and_update_region(this, region_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    }
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   284
  } while((region_stack()->size() != 0) ||
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   285
          (region_overflow_stack()->length() != 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   288
#ifdef USE_RegionTaskQueueWithOverflow
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   289
  assert(region_stack()->is_empty(), "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
#else
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   291
  assert(region_stack()->size() == 0, "Sanity");
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 1
diff changeset
   292
  assert(region_overflow_stack()->length() == 0, "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  oop obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  while (obj = retrieve_for_scanning()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    obj->follow_contents(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
bool ParCompactionManager::stacks_have_been_allocated() {
3696
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 1623
diff changeset
   304
  return (revisit_klass_stack()->data_addr() != NULL &&
9e5d9b5e1049 4957990: Perm heap bloat in JVM
ysr
parents: 1623
diff changeset
   305
          revisit_mdo_stack()->data_addr() != NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
#endif