src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 1
2d8a650513c2
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
aoqi@0 27
aoqi@0 28 #include "memory/allocation.hpp"
aoqi@0 29 #include "utilities/growableArray.hpp"
aoqi@0 30
aoqi@0 31 //
aoqi@0 32 // psTasks.hpp is a collection of GCTasks used by the
aoqi@0 33 // parallelScavenge collector.
aoqi@0 34 //
aoqi@0 35
aoqi@0 36 class GCTask;
aoqi@0 37 class OopClosure;
aoqi@0 38 class OopStack;
aoqi@0 39 class ObjectStartArray;
aoqi@0 40 class ParallelTaskTerminator;
aoqi@0 41 class MutableSpace;
aoqi@0 42 class PSOldGen;
aoqi@0 43 class Thread;
aoqi@0 44 class VMThread;
aoqi@0 45
aoqi@0 46 //
aoqi@0 47 // ScavengeRootsTask
aoqi@0 48 //
aoqi@0 49 // This task scans all the roots of a given type.
aoqi@0 50 //
aoqi@0 51 //
aoqi@0 52
aoqi@0 53 class ScavengeRootsTask : public GCTask {
aoqi@0 54 public:
aoqi@0 55 enum RootType {
aoqi@0 56 universe = 1,
aoqi@0 57 jni_handles = 2,
aoqi@0 58 threads = 3,
aoqi@0 59 object_synchronizer = 4,
aoqi@0 60 flat_profiler = 5,
aoqi@0 61 system_dictionary = 6,
aoqi@0 62 class_loader_data = 7,
aoqi@0 63 management = 8,
aoqi@0 64 jvmti = 9,
aoqi@0 65 code_cache = 10
aoqi@0 66 };
aoqi@0 67 private:
aoqi@0 68 RootType _root_type;
aoqi@0 69 public:
aoqi@0 70 ScavengeRootsTask(RootType value) : _root_type(value) {}
aoqi@0 71
aoqi@0 72 char* name() { return (char *)"scavenge-roots-task"; }
aoqi@0 73
aoqi@0 74 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 75 };
aoqi@0 76
aoqi@0 77 //
aoqi@0 78 // ThreadRootsTask
aoqi@0 79 //
aoqi@0 80 // This task scans the roots of a single thread. This task
aoqi@0 81 // enables scanning of thread roots in parallel.
aoqi@0 82 //
aoqi@0 83
aoqi@0 84 class ThreadRootsTask : public GCTask {
aoqi@0 85 private:
aoqi@0 86 JavaThread* _java_thread;
aoqi@0 87 VMThread* _vm_thread;
aoqi@0 88 public:
aoqi@0 89 ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {}
aoqi@0 90 ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {}
aoqi@0 91
aoqi@0 92 char* name() { return (char *)"thread-roots-task"; }
aoqi@0 93
aoqi@0 94 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 95 };
aoqi@0 96
aoqi@0 97 //
aoqi@0 98 // StealTask
aoqi@0 99 //
aoqi@0 100 // This task is used to distribute work to idle threads.
aoqi@0 101 //
aoqi@0 102
aoqi@0 103 class StealTask : public GCTask {
aoqi@0 104 private:
aoqi@0 105 ParallelTaskTerminator* const _terminator;
aoqi@0 106 public:
aoqi@0 107 char* name() { return (char *)"steal-task"; }
aoqi@0 108
aoqi@0 109 StealTask(ParallelTaskTerminator* t);
aoqi@0 110
aoqi@0 111 ParallelTaskTerminator* terminator() { return _terminator; }
aoqi@0 112
aoqi@0 113 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 114 };
aoqi@0 115
aoqi@0 116 //
aoqi@0 117 // OldToYoungRootsTask
aoqi@0 118 //
aoqi@0 119 // This task is used to scan old to young roots in parallel
aoqi@0 120 //
aoqi@0 121 // A GC thread executing this tasks divides the generation (old gen)
aoqi@0 122 // into slices and takes a stripe in the slice as its part of the
aoqi@0 123 // work.
aoqi@0 124 //
aoqi@0 125 // +===============+ slice 0
aoqi@0 126 // | stripe 0 |
aoqi@0 127 // +---------------+
aoqi@0 128 // | stripe 1 |
aoqi@0 129 // +---------------+
aoqi@0 130 // | stripe 2 |
aoqi@0 131 // +---------------+
aoqi@0 132 // | stripe 3 |
aoqi@0 133 // +===============+ slice 1
aoqi@0 134 // | stripe 0 |
aoqi@0 135 // +---------------+
aoqi@0 136 // | stripe 1 |
aoqi@0 137 // +---------------+
aoqi@0 138 // | stripe 2 |
aoqi@0 139 // +---------------+
aoqi@0 140 // | stripe 3 |
aoqi@0 141 // +===============+ slice 2
aoqi@0 142 // ...
aoqi@0 143 //
aoqi@0 144 // A task is created for each stripe. In this case there are 4 tasks
aoqi@0 145 // created. A GC thread first works on its stripe within slice 0
aoqi@0 146 // and then moves to its stripe in the next slice until all stripes
aoqi@0 147 // exceed the top of the generation. Note that having fewer GC threads
aoqi@0 148 // than stripes works because all the tasks are executed so all stripes
aoqi@0 149 // will be covered. In this example if 4 tasks have been created to cover
aoqi@0 150 // all the stripes and there are only 3 threads, one of the threads will
aoqi@0 151 // get the tasks with the 4th stripe. However, there is a dependence in
aoqi@0 152 // CardTableExtension::scavenge_contents_parallel() on the number
aoqi@0 153 // of tasks created. In scavenge_contents_parallel the distance
aoqi@0 154 // to the next stripe is calculated based on the number of tasks.
aoqi@0 155 // If the stripe width is ssize, a task's next stripe is at
aoqi@0 156 // ssize * number_of_tasks (= slice_stride). In this case after
aoqi@0 157 // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1
aoqi@0 158 // by adding slice_stride to the start of stripe 0 in slice 0 to get
aoqi@0 159 // to the start of stride 0 in slice 1.
aoqi@0 160
aoqi@0 161 class OldToYoungRootsTask : public GCTask {
aoqi@0 162 private:
aoqi@0 163 PSOldGen* _gen;
aoqi@0 164 HeapWord* _gen_top;
aoqi@0 165 uint _stripe_number;
aoqi@0 166 uint _stripe_total;
aoqi@0 167
aoqi@0 168 public:
aoqi@0 169 OldToYoungRootsTask(PSOldGen *gen,
aoqi@0 170 HeapWord* gen_top,
aoqi@0 171 uint stripe_number,
aoqi@0 172 uint stripe_total) :
aoqi@0 173 _gen(gen),
aoqi@0 174 _gen_top(gen_top),
aoqi@0 175 _stripe_number(stripe_number),
aoqi@0 176 _stripe_total(stripe_total) { }
aoqi@0 177
aoqi@0 178 char* name() { return (char *)"old-to-young-roots-task"; }
aoqi@0 179
aoqi@0 180 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 181 };
aoqi@0 182
aoqi@0 183 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP

mercurial