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

Fri, 29 Apr 2016 00:06:10 +0800

author
aoqi
date
Fri, 29 Apr 2016 00:06:10 +0800
changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 25
873fd82b133d
permissions
-rw-r--r--

Added MIPS 64-bit port.

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@1 25 /*
aoqi@1 26 * This file has been modified by Loongson Technology in 2015. These
aoqi@1 27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
aoqi@1 28 * available on the same license terms set forth above.
aoqi@1 29 */
aoqi@1 30
aoqi@0 31 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
aoqi@0 32 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP
aoqi@0 33
aoqi@0 34 #include "memory/allocation.hpp"
aoqi@0 35 #include "utilities/growableArray.hpp"
aoqi@0 36
aoqi@0 37 //
aoqi@0 38 // psTasks.hpp is a collection of GCTasks used by the
aoqi@0 39 // parallelScavenge collector.
aoqi@0 40 //
aoqi@0 41
aoqi@0 42 class GCTask;
aoqi@0 43 class OopClosure;
aoqi@0 44 class OopStack;
aoqi@0 45 class ObjectStartArray;
aoqi@0 46 class ParallelTaskTerminator;
aoqi@0 47 class MutableSpace;
aoqi@0 48 class PSOldGen;
aoqi@0 49 class Thread;
aoqi@0 50 class VMThread;
aoqi@0 51
aoqi@0 52 //
aoqi@0 53 // ScavengeRootsTask
aoqi@0 54 //
aoqi@0 55 // This task scans all the roots of a given type.
aoqi@0 56 //
aoqi@0 57 //
aoqi@0 58
aoqi@0 59 class ScavengeRootsTask : public GCTask {
aoqi@0 60 public:
aoqi@0 61 enum RootType {
aoqi@0 62 universe = 1,
aoqi@0 63 jni_handles = 2,
aoqi@0 64 threads = 3,
aoqi@0 65 object_synchronizer = 4,
aoqi@0 66 flat_profiler = 5,
aoqi@0 67 system_dictionary = 6,
aoqi@0 68 class_loader_data = 7,
aoqi@0 69 management = 8,
aoqi@0 70 jvmti = 9,
aoqi@0 71 code_cache = 10
aoqi@0 72 };
aoqi@0 73 private:
aoqi@0 74 RootType _root_type;
aoqi@0 75 public:
aoqi@1 76 ScavengeRootsTask(RootType value) : _root_type(value) {set_task_numa_id(-1);}
aoqi@0 77
aoqi@0 78 char* name() { return (char *)"scavenge-roots-task"; }
aoqi@0 79
aoqi@0 80 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 81 };
aoqi@0 82
aoqi@0 83 //
aoqi@0 84 // ThreadRootsTask
aoqi@0 85 //
aoqi@0 86 // This task scans the roots of a single thread. This task
aoqi@0 87 // enables scanning of thread roots in parallel.
aoqi@0 88 //
aoqi@0 89
aoqi@0 90 class ThreadRootsTask : public GCTask {
aoqi@0 91 private:
aoqi@0 92 JavaThread* _java_thread;
aoqi@0 93 VMThread* _vm_thread;
aoqi@0 94 public:
aoqi@1 95 ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {set_task_numa_id(root->lgrp_id());}
aoqi@1 96 ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {set_task_numa_id(root->lgrp_id());}
aoqi@0 97
aoqi@0 98 char* name() { return (char *)"thread-roots-task"; }
aoqi@0 99
aoqi@0 100 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 101 };
aoqi@0 102
aoqi@0 103 //
aoqi@0 104 // StealTask
aoqi@0 105 //
aoqi@0 106 // This task is used to distribute work to idle threads.
aoqi@0 107 //
aoqi@0 108
aoqi@0 109 class StealTask : public GCTask {
aoqi@0 110 private:
aoqi@0 111 ParallelTaskTerminator* const _terminator;
aoqi@0 112 public:
aoqi@0 113 char* name() { return (char *)"steal-task"; }
aoqi@0 114
aoqi@0 115 StealTask(ParallelTaskTerminator* t);
aoqi@0 116
aoqi@0 117 ParallelTaskTerminator* terminator() { return _terminator; }
aoqi@0 118
aoqi@0 119 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 120 };
aoqi@0 121
aoqi@0 122 //
aoqi@0 123 // OldToYoungRootsTask
aoqi@0 124 //
aoqi@0 125 // This task is used to scan old to young roots in parallel
aoqi@0 126 //
aoqi@0 127 // A GC thread executing this tasks divides the generation (old gen)
aoqi@0 128 // into slices and takes a stripe in the slice as its part of the
aoqi@0 129 // work.
aoqi@0 130 //
aoqi@0 131 // +===============+ slice 0
aoqi@0 132 // | stripe 0 |
aoqi@0 133 // +---------------+
aoqi@0 134 // | stripe 1 |
aoqi@0 135 // +---------------+
aoqi@0 136 // | stripe 2 |
aoqi@0 137 // +---------------+
aoqi@0 138 // | stripe 3 |
aoqi@0 139 // +===============+ slice 1
aoqi@0 140 // | stripe 0 |
aoqi@0 141 // +---------------+
aoqi@0 142 // | stripe 1 |
aoqi@0 143 // +---------------+
aoqi@0 144 // | stripe 2 |
aoqi@0 145 // +---------------+
aoqi@0 146 // | stripe 3 |
aoqi@0 147 // +===============+ slice 2
aoqi@0 148 // ...
aoqi@0 149 //
aoqi@0 150 // A task is created for each stripe. In this case there are 4 tasks
aoqi@0 151 // created. A GC thread first works on its stripe within slice 0
aoqi@0 152 // and then moves to its stripe in the next slice until all stripes
aoqi@0 153 // exceed the top of the generation. Note that having fewer GC threads
aoqi@0 154 // than stripes works because all the tasks are executed so all stripes
aoqi@0 155 // will be covered. In this example if 4 tasks have been created to cover
aoqi@0 156 // all the stripes and there are only 3 threads, one of the threads will
aoqi@0 157 // get the tasks with the 4th stripe. However, there is a dependence in
aoqi@0 158 // CardTableExtension::scavenge_contents_parallel() on the number
aoqi@0 159 // of tasks created. In scavenge_contents_parallel the distance
aoqi@0 160 // to the next stripe is calculated based on the number of tasks.
aoqi@0 161 // If the stripe width is ssize, a task's next stripe is at
aoqi@0 162 // ssize * number_of_tasks (= slice_stride). In this case after
aoqi@0 163 // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1
aoqi@0 164 // by adding slice_stride to the start of stripe 0 in slice 0 to get
aoqi@0 165 // to the start of stride 0 in slice 1.
aoqi@0 166
aoqi@0 167 class OldToYoungRootsTask : public GCTask {
aoqi@0 168 private:
aoqi@0 169 PSOldGen* _gen;
aoqi@0 170 HeapWord* _gen_top;
aoqi@0 171 uint _stripe_number;
aoqi@0 172 uint _stripe_total;
aoqi@0 173
aoqi@0 174 public:
aoqi@0 175 OldToYoungRootsTask(PSOldGen *gen,
aoqi@0 176 HeapWord* gen_top,
aoqi@0 177 uint stripe_number,
aoqi@0 178 uint stripe_total) :
aoqi@0 179 _gen(gen),
aoqi@0 180 _gen_top(gen_top),
aoqi@0 181 _stripe_number(stripe_number),
aoqi@1 182 _stripe_total(stripe_total) {set_task_numa_id(-1);}
aoqi@0 183
aoqi@0 184 char* name() { return (char *)"old-to-young-roots-task"; }
aoqi@0 185
aoqi@0 186 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@0 187 };
aoqi@0 188
aoqi@1 189 class OldToYoungRootsTask_OldNUMA : public GCTask {
aoqi@1 190 private:
aoqi@1 191 PSOldGen* _gen;
aoqi@1 192 HeapWord** _gen_top;
aoqi@1 193 uint _stripe_number;
aoqi@1 194 uint _stripe_total;
aoqi@1 195
aoqi@1 196 public:
aoqi@1 197 OldToYoungRootsTask_OldNUMA(PSOldGen *gen,
aoqi@1 198 HeapWord** gen_top,
aoqi@1 199 uint stripe_number,
aoqi@1 200 uint stripe_total) :
aoqi@1 201 _gen(gen),
aoqi@1 202 _gen_top(gen_top),
aoqi@1 203 _stripe_number(stripe_number),
aoqi@1 204 _stripe_total(stripe_total) {set_task_numa_id(-1);}
aoqi@1 205
aoqi@1 206 char* name() { return (char *)"OldNUMA-old-to-young-roots-task"; }
aoqi@1 207
aoqi@1 208 virtual void do_it(GCTaskManager* manager, uint which);
aoqi@1 209 };
aoqi@1 210
aoqi@1 211
aoqi@0 212 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP

mercurial