hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp
author trims
Tue, 05 Apr 2011 14:12:31 -0700
changeset 8921 14bfe81f2a9d
parent 8076 96d498ec7ae1
child 10524 6594ca81279a
permissions -rw-r--r--
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass Summary: Update the copyright to be 2010 on all changed files in OpenJDK Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8921
14bfe81f2a9d 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 8076
diff changeset
     2
 * Copyright (c) 2005, 2011, 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: 5076
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5076
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: 5076
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 "code/codeCache.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    28
#include "gc_implementation/parallelScavenge/pcTasks.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    29
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    30
#include "gc_interface/collectedHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    31
#include "memory/universe.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    32
#include "oops/objArrayKlass.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    33
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    34
#include "oops/oop.pcgc.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    35
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    36
#include "runtime/fprofiler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    37
#include "runtime/jniHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    38
#include "runtime/thread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    39
#include "runtime/vmThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    40
#include "services/management.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// ThreadRootsMarkingTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  NOT_PRODUCT(TraceTime tm("ThreadRootsMarkingTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
    56
  CodeBlobToOopClosure mark_and_push_in_blobs(&mark_and_push_closure, /*do_marking=*/ true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  if (_java_thread != NULL)
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
    59
    _java_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  if (_vm_thread != NULL)
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
    62
    _vm_thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // Do the real work
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
    65
  cm->follow_marking_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  NOT_PRODUCT(TraceTime tm("MarkFromRootsTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  switch (_root_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    case universe:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      Universe::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    case reference_processing:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
      ReferenceProcessor::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    case jni_handles:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      JNIHandles::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    case threads:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      ResourceMark rm;
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
    94
      CodeBlobToOopClosure each_active_code_blob(&mark_and_push_closure, /*do_marking=*/ true);
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
    95
      Threads::oops_do(&mark_and_push_closure, &each_active_code_blob);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    case object_synchronizer:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      ObjectSynchronizer::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    case flat_profiler:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      FlatProfiler::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    case management:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      Management::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    case jvmti:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      JvmtiExport::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    case system_dictionary:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
      SystemDictionary::always_strong_oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   119
    case code_cache:
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   120
      // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   121
      //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(&mark_and_push_closure));
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   122
      break;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   123
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      fatal("Unknown root type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // Do the real work
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   129
  cm->follow_marking_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
// RefProcTaskProxy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  NOT_PRODUCT(TraceTime tm("RefProcTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  PSParallelCompact::FollowStackClosure follow_stack_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  _rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                mark_and_push_closure, follow_stack_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
// RefProcTaskExecutor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
void RefProcTaskExecutor::execute(ProcessTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  uint parallel_gc_threads = heap->gc_task_manager()->workers();
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   159
  RegionTaskQueueSet* qset = ParCompactionManager::region_array();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  ParallelTaskTerminator terminator(parallel_gc_threads, qset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  GCTaskQueue* q = GCTaskQueue::create();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    q->enqueue(new RefProcTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  if (task.marks_oops_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    if (parallel_gc_threads>1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      for (uint j=0; j<parallel_gc_threads; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        q->enqueue(new StealMarkingTask(&terminator));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  PSParallelCompact::gc_task_manager()->execute_and_wait(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
void RefProcTaskExecutor::execute(EnqueueTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  ParallelScavengeHeap* heap = PSParallelCompact::gc_heap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  uint parallel_gc_threads = heap->gc_task_manager()->workers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  GCTaskQueue* q = GCTaskQueue::create();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    q->enqueue(new RefEnqueueTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  PSParallelCompact::gc_task_manager()->execute_and_wait(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
// StealMarkingTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
StealMarkingTask::StealMarkingTask(ParallelTaskTerminator* t) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  _terminator(t) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
void StealMarkingTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  NOT_PRODUCT(TraceTime tm("StealMarkingTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  oop obj = NULL;
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   204
  ObjArrayTask task;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  int random_seed = 17;
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   206
  do {
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   207
    while (ParCompactionManager::steal_objarray(which, &random_seed, task)) {
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   208
      objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint();
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   209
      k->oop_follow_contents(cm, task.obj(), task.index());
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   210
      cm->follow_marking_stacks();
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   211
    }
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   212
    while (ParCompactionManager::steal(which, &random_seed, obj)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      obj->follow_contents(cm);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   214
      cm->follow_marking_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    }
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   216
  } while (!terminator()->offer_termination());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
//
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   220
// StealRegionCompactionTask
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   224
StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t):
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   225
  _terminator(t) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   227
void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   230
  NOT_PRODUCT(TraceTime tm("StealRegionCompactionTask",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   236
  // Has to drain stacks first because there may be regions on
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // preloaded onto the stack and this thread may never have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  // done a draining task.  Are the draining tasks needed?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   240
  cm->drain_region_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   242
  size_t region_index = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  int random_seed = 17;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // If we're the termination task, try 10 rounds of stealing before
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // setting the termination flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  while(true) {
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   249
    if (ParCompactionManager::steal(which, &random_seed, region_index)) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   250
      PSParallelCompact::fill_and_update_region(cm, region_index);
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   251
      cm->drain_region_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      if (terminator()->offer_termination()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      // Go around again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
UpdateDensePrefixTask::UpdateDensePrefixTask(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
                                   PSParallelCompact::SpaceId space_id,
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   264
                                   size_t region_index_start,
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   265
                                   size_t region_index_end) :
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   266
  _space_id(space_id), _region_index_start(region_index_start),
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   267
  _region_index_end(region_index_end) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  NOT_PRODUCT(TraceTime tm("UpdateDensePrefixTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  PSParallelCompact::update_and_deadwood_in_dense_prefix(cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
                                                         _space_id,
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   279
                                                         _region_index_start,
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   280
                                                         _region_index_end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  assert(Universe::heap()->is_gc_active(), "called outside gc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  NOT_PRODUCT(TraceTime tm("DrainStacksCompactionTask",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    PrintGCDetails && TraceParallelOldGCTasks, true, gclog_or_tty));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   292
  // Process any regions already in the compaction managers stacks.
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   293
  cm->drain_region_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
}