src/hotspot/share/gc/parallel/psTasks.hpp
author kbarrett
Thu, 18 Jul 2019 14:57:32 -0400
changeset 55740 b3ff56f955c8
parent 54669 ad45b3802d4e
child 57771 50c959cc40e8
permissions -rw-r--r--
8227653: Add VM Global OopStorage Summary: Replaced conditional JVMCI global storage with VM global storage. Reviewed-by: tschatzl, lfoltan, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50058
diff changeset
     2
 * Copyright (c) 2002, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50058
diff changeset
    25
#ifndef SHARE_GC_PARALLEL_PSTASKS_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50058
diff changeset
    26
#define SHARE_GC_PARALLEL_PSTASKS_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// psTasks.hpp is a collection of GCTasks used by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// parallelScavenge collector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class GCTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class OopClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class OopStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class ObjectStartArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class ParallelTaskTerminator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class MutableSpace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class PSOldGen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class Thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class VMThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// ScavengeRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// This task scans all the roots of a given type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class ScavengeRootsTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  enum RootType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    universe              = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    jni_handles           = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    threads               = 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    object_synchronizer   = 4,
47106
bed18a111b90 8173715: Remove FlatProfiler
gziemski
parents: 32623
diff changeset
    59
    system_dictionary     = 5,
bed18a111b90 8173715: Remove FlatProfiler
gziemski
parents: 32623
diff changeset
    60
    class_loader_data     = 6,
bed18a111b90 8173715: Remove FlatProfiler
gziemski
parents: 32623
diff changeset
    61
    management            = 7,
bed18a111b90 8173715: Remove FlatProfiler
gziemski
parents: 32623
diff changeset
    62
    jvmti                 = 8,
bed18a111b90 8173715: Remove FlatProfiler
gziemski
parents: 32623
diff changeset
    63
    code_cache            = 9
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  RootType _root_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  ScavengeRootsTask(RootType value) : _root_type(value) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  char* name() { return (char *)"scavenge-roots-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
// ThreadRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// This task scans the roots of a single thread. This task
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
// enables scanning of thread roots in parallel.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
class ThreadRootsTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
 private:
50058
f7e564cacfbc 8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents: 49621
diff changeset
    84
  Thread* _thread;
f7e564cacfbc 8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents: 49621
diff changeset
    85
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
 public:
50058
f7e564cacfbc 8202649: Move the Parallel GC specific task creation functions out of Threads
stefank
parents: 49621
diff changeset
    87
  ThreadRootsTask(Thread* root) : _thread(root) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  char* name() { return (char *)"thread-roots-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
// StealTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// This task is used to distribute work to idle threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
class StealTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
   ParallelTaskTerminator* const _terminator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  char* name() { return (char *)"steal-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  StealTask(ParallelTaskTerminator* t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  ParallelTaskTerminator* terminator() { return _terminator; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// OldToYoungRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
// This task is used to scan old to young roots in parallel
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   117
//
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   118
// A GC thread executing this tasks divides the generation (old gen)
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   119
// into slices and takes a stripe in the slice as its part of the
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   120
// work.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   121
//
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   122
//      +===============+        slice 0
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   123
//      |  stripe 0     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   124
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   125
//      |  stripe 1     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   126
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   127
//      |  stripe 2     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   128
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   129
//      |  stripe 3     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   130
//      +===============+        slice 1
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   131
//      |  stripe 0     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   132
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   133
//      |  stripe 1     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   134
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   135
//      |  stripe 2     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   136
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   137
//      |  stripe 3     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   138
//      +===============+        slice 2
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   139
//      ...
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   140
//
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   141
// A task is created for each stripe.  In this case there are 4 tasks
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   142
// created.  A GC thread first works on its stripe within slice 0
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   143
// and then moves to its stripe in the next slice until all stripes
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   144
// exceed the top of the generation.  Note that having fewer GC threads
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   145
// than stripes works because all the tasks are executed so all stripes
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   146
// will be covered.  In this example if 4 tasks have been created to cover
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   147
// all the stripes and there are only 3 threads, one of the threads will
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   148
// get the tasks with the 4th stripe.  However, there is a dependence in
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
   149
// PSCardTable::scavenge_contents_parallel() on the number
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   150
// of tasks created.  In scavenge_contents_parallel the distance
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   151
// to the next stripe is calculated based on the number of tasks.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   152
// If the stripe width is ssize, a task's next stripe is at
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   153
// ssize * number_of_tasks (= slice_stride).  In this case after
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   154
// finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   155
// by adding slice_stride to the start of stripe 0 in slice 0 to get
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   156
// to the start of stride 0 in slice 1.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
class OldToYoungRootsTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
 private:
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   160
  PSOldGen* _old_gen;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  HeapWord* _gen_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  uint _stripe_number;
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   163
  uint _stripe_total;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
 public:
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   166
  OldToYoungRootsTask(PSOldGen *old_gen,
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   167
                      HeapWord* gen_top,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   168
                      uint stripe_number,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   169
                      uint stripe_total) :
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   170
    _old_gen(old_gen),
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   171
    _gen_top(gen_top),
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   172
    _stripe_number(stripe_number),
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   173
    _stripe_total(stripe_total) { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  char* name() { return (char *)"old-to-young-roots-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   179
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50058
diff changeset
   180
#endif // SHARE_GC_PARALLEL_PSTASKS_HPP