src/hotspot/share/gc/parallel/psTasks.cpp
author stefank
Mon, 07 May 2018 16:12:07 +0200
changeset 50058 f7e564cacfbc
parent 49982 9042ffe5b7fe
child 51292 0538a5cdb474
permissions -rw-r--r--
8202649: Move the Parallel GC specific task creation functions out of Threads Reviewed-by: ehelin, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47580
diff changeset
     2
 * Copyright (c) 2002, 2018, 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: 3908
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3908
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: 3908
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: 6248
diff changeset
    25
#include "precompiled.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38074
diff changeset
    26
#include "aot/aotLoader.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    27
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    28
#include "code/codeCache.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    29
#include "gc/parallel/gcTaskManager.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47580
diff changeset
    30
#include "gc/parallel/psCardTable.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    31
#include "gc/parallel/psPromotionManager.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    32
#include "gc/parallel/psPromotionManager.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    33
#include "gc/parallel/psScavenge.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    34
#include "gc/parallel/psTasks.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    35
#include "gc/shared/taskqueue.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    36
#include "memory/iterator.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 32623
diff changeset
    37
#include "memory/resourceArea.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    38
#include "memory/universe.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    39
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    40
#include "runtime/thread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    41
#include "runtime/vmThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    42
#include "services/management.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// ScavengeRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29792
diff changeset
    49
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  PSScavengeRootsClosure roots_closure(pm);
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 11174
diff changeset
    53
  PSPromoteRootsClosure  roots_to_old_closure(pm);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  switch (_root_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    case universe:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
      Universe::oops_do(&roots_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    case jni_handles:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
      JNIHandles::oops_do(&roots_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    case threads:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
      ResourceMark rm;
38074
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 37248
diff changeset
    67
      Threads::oops_do(&roots_closure, NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    }
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 object_synchronizer:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      ObjectSynchronizer::oops_do(&roots_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 system_dictionary:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      SystemDictionary::oops_do(&roots_closure);
17844
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 14582
diff changeset
    77
      break;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11753
diff changeset
    78
17844
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 14582
diff changeset
    79
    case class_loader_data:
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 14582
diff changeset
    80
    {
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    81
      PSScavengeCLDClosure cld_closure(pm);
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    82
      ClassLoaderDataGraph::cld_do(&cld_closure);
17844
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 14582
diff changeset
    83
    }
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 14582
diff changeset
    84
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    case management:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      Management::oops_do(&roots_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 jvmti:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      JvmtiExport::oops_do(&roots_closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
    94
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
    95
    case code_cache:
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
    96
      {
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    97
        MarkingCodeBlobClosure each_scavengable_code_blob(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
    98
        CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38074
diff changeset
    99
        AOTLoader::oops_do(&roots_closure);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
   100
      }
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
   101
      break;
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 670
diff changeset
   102
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      fatal("Unknown root type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Do the real work
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  pm->drain_stacks(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// ThreadRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29792
diff changeset
   116
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  PSScavengeRootsClosure roots_closure(pm);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   120
  MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
50058
f7e564cacfbc 8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents: 49982
diff changeset
   122
  _thread->oops_do(&roots_closure, &roots_in_blobs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Do the real work
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  pm->drain_stacks(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// StealTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
StealTask::StealTask(ParallelTaskTerminator* t) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  _terminator(t) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
void StealTask::do_it(GCTaskManager* manager, uint which) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29792
diff changeset
   136
  assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  PSPromotionManager* pm =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    PSPromotionManager::gc_thread_promotion_manager(which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  pm->drain_stacks(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  guarantee(pm->stacks_empty(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
            "stacks should be empty at this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  int random_seed = 17;
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   145
  while(true) {
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   146
    StarTask p;
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   147
    if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   148
      TASKQUEUE_STATS_ONLY(pm->record_steal(p));
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   149
      pm->process_popped_location_depth(p);
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   150
      pm->drain_stacks_depth(true);
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   151
    } else {
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   152
      if (terminator()->offer_termination()) {
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 6067
diff changeset
   153
        break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   157
  guarantee(pm->stacks_empty(), "stacks should be empty at this point");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// OldToYoungRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   165
  // There are not old-to-young pointers if the old gen is empty.
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   166
  assert(!_old_gen->object_space()->is_empty(),
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   167
    "Should not be called is there is no work");
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   168
  assert(_old_gen != NULL, "Sanity");
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   169
  assert(_old_gen->object_space()->contains(_gen_top) || _gen_top == _old_gen->object_space()->top(), "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  assert(_stripe_number < ParallelGCThreads, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47580
diff changeset
   174
    PSCardTable* card_table = ParallelScavengeHeap::heap()->card_table();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   176
    card_table->scavenge_contents_parallel(_old_gen->start_array(),
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   177
                                           _old_gen->object_space(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
                                           _gen_top,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
                                           pm,
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10524
diff changeset
   180
                                           _stripe_number,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 10524
diff changeset
   181
                                           _stripe_total);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    // Do the real work
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    pm->drain_stacks(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
}