hotspot/src/share/vm/gc/parallel/psTasks.hpp
author jwilhelm
Mon, 29 Feb 2016 15:47:41 +0100
changeset 36581 8d65a7db1582
parent 32623 390a27af5657
child 47106 bed18a111b90
permissions -rw-r--r--
6787054: Par compact - remove code that clears source_region Reviewed-by: mgerdin, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22234
diff changeset
     2
 * Copyright (c) 2002, 2015, 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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22234
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PSTASKS_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22234
diff changeset
    26
#define SHARE_VM_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 "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// psTasks.hpp is a collection of GCTasks used by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// parallelScavenge collector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class GCTask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class OopClosure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class OopStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class ObjectStartArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class ParallelTaskTerminator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class MutableSpace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class PSOldGen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class Thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class VMThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// ScavengeRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// This task scans all the roots of a given type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class ScavengeRootsTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  enum RootType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    universe              = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    jni_handles           = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    threads               = 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    object_synchronizer   = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    flat_profiler         = 5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    system_dictionary     = 6,
17844
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 13924
diff changeset
    62
    class_loader_data     = 7,
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 13924
diff changeset
    63
    management            = 8,
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 13924
diff changeset
    64
    jvmti                 = 9,
28ca9179db98 8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents: 13924
diff changeset
    65
    code_cache            = 10
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  RootType _root_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  ScavengeRootsTask(RootType value) : _root_type(value) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  char* name() { return (char *)"scavenge-roots-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// ThreadRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
// This task scans the roots of a single thread. This task
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// enables scanning of thread roots in parallel.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
class ThreadRootsTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  JavaThread* _java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  VMThread* _vm_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  char* name() { return (char *)"thread-roots-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
// StealTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// This task is used to distribute work to idle threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
class StealTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
   ParallelTaskTerminator* const _terminator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  char* name() { return (char *)"steal-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  StealTask(ParallelTaskTerminator* t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  ParallelTaskTerminator* terminator() { return _terminator; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
// OldToYoungRootsTask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// 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
   120
//
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   121
// 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
   122
// 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
   123
// work.
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
//      +===============+        slice 0
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   126
//      |  stripe 0     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   127
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   128
//      |  stripe 1     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   129
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   130
//      |  stripe 2     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   131
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   132
//      |  stripe 3     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   133
//      +===============+        slice 1
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   134
//      |  stripe 0     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   135
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   136
//      |  stripe 1     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   137
//      +---------------+
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   138
//      |  stripe 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
//      |  stripe 3     |
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   141
//      +===============+        slice 2
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   142
//      ...
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   143
//
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   144
// 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
   145
// 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
   146
// 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
   147
// 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
   148
// 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
   149
// 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
   150
// 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
   151
// get the tasks with the 4th stripe.  However, there is a dependence in
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   152
// CardTableExtension::scavenge_contents_parallel() on the number
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   153
// of tasks created.  In scavenge_contents_parallel the distance
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   154
// 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
   155
// 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
   156
// 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
   157
// 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
   158
// 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
   159
// to the start of stride 0 in slice 1.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
class OldToYoungRootsTask : public GCTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
 private:
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   163
  PSOldGen* _old_gen;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  HeapWord* _gen_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  uint _stripe_number;
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   166
  uint _stripe_total;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
 public:
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   169
  OldToYoungRootsTask(PSOldGen *old_gen,
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   170
                      HeapWord* gen_top,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   171
                      uint stripe_number,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   172
                      uint stripe_total) :
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 30764
diff changeset
   173
    _old_gen(old_gen),
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   174
    _gen_top(gen_top),
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   175
    _stripe_number(stripe_number),
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   176
    _stripe_total(stripe_total) { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  char* name() { return (char *)"old-to-young-roots-task"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  virtual void do_it(GCTaskManager* manager, uint which);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   182
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22234
diff changeset
   183
#endif // SHARE_VM_GC_PARALLEL_PSTASKS_HPP