hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp
author xdono
Wed, 02 Jul 2008 12:55:16 -0700
changeset 670 ddf3e9583f2f
parent 360 21d113ecbf6a
child 1407 9006b01ba3fd
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 360
diff changeset
     2
 * Copyright 2005-2008 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/_pcTasks.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// ThreadRootsMarkingTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  NOT_PRODUCT(TraceTime tm("ThreadRootsMarkingTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  if (_java_thread != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    _java_thread->oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  if (_vm_thread != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _vm_thread->oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // Do the real work
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  cm->drain_marking_stacks(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  NOT_PRODUCT(TraceTime tm("MarkFromRootsTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // cm->allocate_stacks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  assert(cm->stacks_have_been_allocated(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    "Stack space has not been allocated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  switch (_root_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    case universe:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
      Universe::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    case reference_processing:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      ReferenceProcessor::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    case jni_handles:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      JNIHandles::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    case threads:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
      Threads::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    case object_synchronizer:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      ObjectSynchronizer::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    case flat_profiler:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      FlatProfiler::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    case management:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      Management::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    case jvmti:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      JvmtiExport::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    case system_dictionary:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      SystemDictionary::always_strong_oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    case vm_symbols:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      vmSymbols::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      fatal("Unknown root type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // Do the real work
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  cm->drain_marking_stacks(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // cm->deallocate_stacks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// RefProcTaskProxy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  NOT_PRODUCT(TraceTime tm("RefProcTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // cm->allocate_stacks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  assert(cm->stacks_have_been_allocated(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    "Stack space has not been allocated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  PSParallelCompact::FollowStackClosure follow_stack_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  _rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
                mark_and_push_closure, follow_stack_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
// RefProcTaskExecutor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
void RefProcTaskExecutor::execute(ProcessTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  uint parallel_gc_threads = heap->gc_task_manager()->workers();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   149
  ChunkTaskQueueSet* qset = ParCompactionManager::chunk_array();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  ParallelTaskTerminator terminator(parallel_gc_threads, qset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  GCTaskQueue* q = GCTaskQueue::create();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    q->enqueue(new RefProcTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  if (task.marks_oops_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    if (parallel_gc_threads>1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      for (uint j=0; j<parallel_gc_threads; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        q->enqueue(new StealMarkingTask(&terminator));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  PSParallelCompact::gc_task_manager()->execute_and_wait(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
void RefProcTaskExecutor::execute(EnqueueTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  uint parallel_gc_threads = heap->gc_task_manager()->workers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  GCTaskQueue* q = GCTaskQueue::create();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    q->enqueue(new RefEnqueueTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  PSParallelCompact::gc_task_manager()->execute_and_wait(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
// StealMarkingTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
StealMarkingTask::StealMarkingTask(ParallelTaskTerminator* t) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  _terminator(t) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
void StealMarkingTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  NOT_PRODUCT(TraceTime tm("StealMarkingTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  oop obj = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  int random_seed = 17;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  while(true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    if (ParCompactionManager::steal(which, &random_seed, obj)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
      obj->follow_contents(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      cm->drain_marking_stacks(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      if (terminator()->offer_termination()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      }
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
// StealChunkCompactionTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
StealChunkCompactionTask::StealChunkCompactionTask(ParallelTaskTerminator* t) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  _terminator(t) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
void StealChunkCompactionTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  NOT_PRODUCT(TraceTime tm("StealChunkCompactionTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // Has to drain stacks first because there may be chunks on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  // preloaded onto the stack and this thread may never have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // done a draining task.  Are the draining tasks needed?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  cm->drain_chunk_stacks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  size_t chunk_index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  int random_seed = 17;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  // If we're the termination task, try 10 rounds of stealing before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // setting the termination flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  while(true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    if (ParCompactionManager::steal(which, &random_seed, chunk_index)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      PSParallelCompact::fill_and_update_chunk(cm, chunk_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      cm->drain_chunk_stacks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      if (terminator()->offer_termination()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      // Go around again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
UpdateDensePrefixTask::UpdateDensePrefixTask(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
                                   PSParallelCompact::SpaceId space_id,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
                                   size_t chunk_index_start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
                                   size_t chunk_index_end) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  _space_id(space_id), _chunk_index_start(chunk_index_start),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  _chunk_index_end(chunk_index_end)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
{}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  NOT_PRODUCT(TraceTime tm("UpdateDensePrefixTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  PSParallelCompact::update_and_deadwood_in_dense_prefix(cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
                                                         _space_id,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
                                                         _chunk_index_start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
                                                         _chunk_index_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  NOT_PRODUCT(TraceTime tm("DrainStacksCompactionTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  // Process any chunks already in the compaction managers stacks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  cm->drain_chunk_stacks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
}