hotspot/src/share/vm/gc/parallel/pcTasks.cpp
author kvn
Sun, 11 Dec 2016 19:07:04 -0800
changeset 42650 1f304d0c888b
parent 38250 37d739fb07fc
child 46502 116a09d8f142
permissions -rw-r--r--
8171008: Integrate AOT compiler into JDK Reviewed-by: erikj, mchung, psandoz, coleenp, iklam, stefank, simonis Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>, Christian Thalinger <cthalinger@twitter.com>, Dean Long <dean.long@oracle.com>, Dmitrij Pochepko <dmitrij.pochepko@oracle.com>, Dmitry Chuyko <dmitry.chuyko@oracle.com>, Doug Simon <doug.simon@oracle.com>, Eric Caspole <eric.caspole@oracle.com>, Igor Ignatyev <igor.ignatyev@oracle.com>, Igor Veresov <igor.veresov@oracle.com>, John Rose <john.r.rose@oracle.com>, Morris Meyer <morris.meyer@oracle.com>, Niclas Adlertz <niclas.adlertz@oracle.com>, Rickard Backman <rickard.backman@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 35061
diff changeset
     2
 * Copyright (c) 2005, 2016, 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"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38250
diff changeset
    26
#include "aot/aotLoader.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    27
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    28
#include "code/codeCache.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30556
diff changeset
    29
#include "gc/parallel/parallelScavengeHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30556
diff changeset
    30
#include "gc/parallel/pcTasks.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30556
diff changeset
    31
#include "gc/parallel/psCompactionManager.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30556
diff changeset
    32
#include "gc/parallel/psParallelCompact.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30556
diff changeset
    33
#include "gc/shared/collectedHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30556
diff changeset
    34
#include "gc/shared/gcTimer.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34130
diff changeset
    35
#include "gc/shared/gcTraceTime.inline.hpp"
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34130
diff changeset
    36
#include "logging/log.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 35061
diff changeset
    37
#include "memory/resourceArea.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    38
#include "memory/universe.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    39
#include "oops/objArrayKlass.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    40
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    41
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    42
#include "runtime/fprofiler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    43
#include "runtime/jniHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    44
#include "runtime/thread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    45
#include "runtime/vmThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6762
diff changeset
    46
#include "services/management.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29798
diff changeset
    47
#include "utilities/stack.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// ThreadRootsMarkingTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
    54
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    ParCompactionManager::gc_thread_compaction_manager(which);
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13952
diff changeset
    60
30556
750fee2bdb45 8078345: Move PSParallelCompact::mark_and_push to ParCompactionManager
stefank
parents: 30173
diff changeset
    61
  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    62
  MarkingCodeBlobClosure mark_and_push_in_blobs(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  if (_java_thread != NULL)
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13952
diff changeset
    65
    _java_thread->oops_do(
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13952
diff changeset
    66
        &mark_and_push_closure,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13952
diff changeset
    67
        &mark_and_push_in_blobs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  if (_vm_thread != NULL)
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13952
diff changeset
    70
    _vm_thread->oops_do(
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13952
diff changeset
    71
        &mark_and_push_closure,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents: 13952
diff changeset
    72
        &mark_and_push_in_blobs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Do the real work
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
    75
  cm->follow_marking_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
}
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 MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
    80
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    ParCompactionManager::gc_thread_compaction_manager(which);
30556
750fee2bdb45 8078345: Move PSParallelCompact::mark_and_push to ParCompactionManager
stefank
parents: 30173
diff changeset
    84
  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
750fee2bdb45 8078345: Move PSParallelCompact::mark_and_push to ParCompactionManager
stefank
parents: 30173
diff changeset
    85
  ParCompactionManager::FollowKlassClosure follow_klass_closure(&mark_and_push_closure);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  switch (_root_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    case universe:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      Universe::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    case jni_handles:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      JNIHandles::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    case threads:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      ResourceMark rm;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    99
      MarkingCodeBlobClosure each_active_code_blob(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations);
38074
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 37260
diff changeset
   100
      Threads::oops_do(&mark_and_push_closure, &each_active_code_blob);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    case object_synchronizer:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      ObjectSynchronizer::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    case flat_profiler:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      FlatProfiler::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    case management:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      Management::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    case jvmti:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      JvmtiExport::oops_do(&mark_and_push_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    case system_dictionary:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      SystemDictionary::always_strong_oops_do(&mark_and_push_closure);
17844
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 17370
diff changeset
   122
      break;
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 17370
diff changeset
   123
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 17370
diff changeset
   124
    case class_loader_data:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11174
diff changeset
   125
      ClassLoaderDataGraph::always_strong_oops_do(&mark_and_push_closure, &follow_klass_closure, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   128
    case code_cache:
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   129
      // 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
   130
      //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(&mark_and_push_closure));
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38250
diff changeset
   131
      AOTLoader::oops_do(&mark_and_push_closure);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   132
      break;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 1407
diff changeset
   133
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      fatal("Unknown root type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Do the real work
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   139
  cm->follow_marking_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// RefProcTaskProxy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
{
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   149
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    ParCompactionManager::gc_thread_compaction_manager(which);
30556
750fee2bdb45 8078345: Move PSParallelCompact::mark_and_push to ParCompactionManager
stefank
parents: 30173
diff changeset
   153
  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
750fee2bdb45 8078345: Move PSParallelCompact::mark_and_push to ParCompactionManager
stefank
parents: 30173
diff changeset
   154
  ParCompactionManager::FollowStackClosure follow_stack_closure(cm);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  _rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
                mark_and_push_closure, follow_stack_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
// RefProcTaskExecutor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
void RefProcTaskExecutor::execute(ProcessTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
{
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   165
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  uint parallel_gc_threads = heap->gc_task_manager()->workers();
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10524
diff changeset
   167
  uint active_gc_threads = heap->gc_task_manager()->active_workers();
37260
664b7520c44b 8153176: ParOldGC: Use correct TaskQueueSet for ParallelTaskTerminator in marking.
mgerdin
parents: 37248
diff changeset
   168
  OopTaskQueueSet* qset = ParCompactionManager::stack_array();
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10524
diff changeset
   169
  ParallelTaskTerminator terminator(active_gc_threads, qset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  GCTaskQueue* q = GCTaskQueue::create();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    q->enqueue(new RefProcTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  if (task.marks_oops_alive()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    if (parallel_gc_threads>1) {
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10524
diff changeset
   176
      for (uint j=0; j<active_gc_threads; j++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
        q->enqueue(new StealMarkingTask(&terminator));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  PSParallelCompact::gc_task_manager()->execute_and_wait(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
void RefProcTaskExecutor::execute(EnqueueTask& task)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
{
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   186
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  uint parallel_gc_threads = heap->gc_task_manager()->workers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  GCTaskQueue* q = GCTaskQueue::create();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  for(uint i=0; i<parallel_gc_threads; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    q->enqueue(new RefEnqueueTaskProxy(task, i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  PSParallelCompact::gc_task_manager()->execute_and_wait(q);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
// StealMarkingTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
StealMarkingTask::StealMarkingTask(ParallelTaskTerminator* t) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  _terminator(t) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
void StealMarkingTask::do_it(GCTaskManager* manager, uint which) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   203
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    ParCompactionManager::gc_thread_compaction_manager(which);
30556
750fee2bdb45 8078345: Move PSParallelCompact::mark_and_push to ParCompactionManager
stefank
parents: 30173
diff changeset
   207
  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  oop obj = NULL;
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   210
  ObjArrayTask task;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  int random_seed = 17;
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   212
  do {
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   213
    while (ParCompactionManager::steal_objarray(which, &random_seed, task)) {
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29701
diff changeset
   214
      cm->follow_contents((objArrayOop)task.obj(), task.index());
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   215
      cm->follow_marking_stacks();
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   216
    }
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   217
    while (ParCompactionManager::steal(which, &random_seed, obj)) {
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29701
diff changeset
   218
      cm->follow_contents(obj);
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   219
      cm->follow_marking_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    }
5076
8b74a4b60b31 4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents: 3919
diff changeset
   221
  } while (!terminator()->offer_termination());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
//
38250
37d739fb07fc 8155992: Change name of StealRegionCompactionTask to something that emphasizes the compaction task.
jmasa
parents: 38170
diff changeset
   225
// CompactionWithStealingTask
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
38250
37d739fb07fc 8155992: Change name of StealRegionCompactionTask to something that emphasizes the compaction task.
jmasa
parents: 38170
diff changeset
   228
CompactionWithStealingTask::CompactionWithStealingTask(ParallelTaskTerminator* t):
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   229
  _terminator(t) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
38250
37d739fb07fc 8155992: Change name of StealRegionCompactionTask to something that emphasizes the compaction task.
jmasa
parents: 38170
diff changeset
   231
void CompactionWithStealingTask::do_it(GCTaskManager* manager, uint which) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 30150
diff changeset
   232
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
38170
ff88a25a7799 8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents: 38074
diff changeset
   237
  // Drain the stacks that have been preloaded with regions
ff88a25a7799 8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents: 38074
diff changeset
   238
  // that are ready to fill.
1
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
38170
ff88a25a7799 8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents: 38074
diff changeset
   242
  guarantee(cm->region_stack()->is_empty(), "Not empty");
ff88a25a7799 8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005
jmasa
parents: 38074
diff changeset
   243
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   244
  size_t region_index = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  int random_seed = 17;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  while(true) {
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   248
    if (ParCompactionManager::steal(which, &random_seed, region_index)) {
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   249
      PSParallelCompact::fill_and_update_region(cm, region_index);
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   250
      cm->drain_region_stacks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
      if (terminator()->offer_termination()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      // Go around again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
UpdateDensePrefixTask::UpdateDensePrefixTask(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
                                   PSParallelCompact::SpaceId space_id,
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   263
                                   size_t region_index_start,
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   264
                                   size_t region_index_end) :
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   265
  _space_id(space_id), _region_index_start(region_index_start),
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   266
  _region_index_end(region_index_end) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  ParCompactionManager* cm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    ParCompactionManager::gc_thread_compaction_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  PSParallelCompact::update_and_deadwood_in_dense_prefix(cm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
                                                         _space_id,
1407
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   275
                                                         _region_index_start,
9006b01ba3fd 6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents: 670
diff changeset
   276
                                                         _region_index_end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
}