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