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

Fri, 16 Jul 2010 21:33:21 -0700

author
jcoomes
date
Fri, 16 Jul 2010 21:33:21 -0700
changeset 2020
a93a9eda13f7
parent 1907
c18cbe5936b8
child 2061
9d7a8ab3736b
permissions
-rw-r--r--

6962947: shared TaskQueue statistics
Reviewed-by: tonyp, ysr

duke@435 1 /*
jcoomes@2020 2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_psTasks.cpp.incl"
duke@435 27
duke@435 28 //
duke@435 29 // ScavengeRootsTask
duke@435 30 //
duke@435 31
duke@435 32 // Define before use
duke@435 33 class PSScavengeRootsClosure: public OopClosure {
duke@435 34 private:
duke@435 35 PSPromotionManager* _promotion_manager;
duke@435 36
coleenp@548 37 protected:
coleenp@548 38 template <class T> void do_oop_work(T *p) {
coleenp@548 39 if (PSScavenge::should_scavenge(p)) {
duke@435 40 // We never card mark roots, maybe call a func without test?
duke@435 41 PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
duke@435 42 }
duke@435 43 }
coleenp@548 44 public:
coleenp@548 45 PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
coleenp@548 46 void do_oop(oop* p) { PSScavengeRootsClosure::do_oop_work(p); }
coleenp@548 47 void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
duke@435 48 };
duke@435 49
duke@435 50 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 51 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 52
duke@435 53 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 54 PSScavengeRootsClosure roots_closure(pm);
duke@435 55
duke@435 56 switch (_root_type) {
duke@435 57 case universe:
duke@435 58 Universe::oops_do(&roots_closure);
duke@435 59 ReferenceProcessor::oops_do(&roots_closure);
duke@435 60 break;
duke@435 61
duke@435 62 case jni_handles:
duke@435 63 JNIHandles::oops_do(&roots_closure);
duke@435 64 break;
duke@435 65
duke@435 66 case threads:
duke@435 67 {
duke@435 68 ResourceMark rm;
jrose@1424 69 Threads::oops_do(&roots_closure, NULL);
duke@435 70 }
duke@435 71 break;
duke@435 72
duke@435 73 case object_synchronizer:
duke@435 74 ObjectSynchronizer::oops_do(&roots_closure);
duke@435 75 break;
duke@435 76
duke@435 77 case flat_profiler:
duke@435 78 FlatProfiler::oops_do(&roots_closure);
duke@435 79 break;
duke@435 80
duke@435 81 case system_dictionary:
duke@435 82 SystemDictionary::oops_do(&roots_closure);
duke@435 83 break;
duke@435 84
duke@435 85 case management:
duke@435 86 Management::oops_do(&roots_closure);
duke@435 87 break;
duke@435 88
duke@435 89 case jvmti:
duke@435 90 JvmtiExport::oops_do(&roots_closure);
duke@435 91 break;
duke@435 92
jrose@1424 93
jrose@1424 94 case code_cache:
jrose@1424 95 {
jrose@1424 96 CodeBlobToOopClosure each_scavengable_code_blob(&roots_closure, /*do_marking=*/ true);
jrose@1424 97 CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
jrose@1424 98 }
jrose@1424 99 break;
jrose@1424 100
duke@435 101 default:
duke@435 102 fatal("Unknown root type");
duke@435 103 }
duke@435 104
duke@435 105 // Do the real work
duke@435 106 pm->drain_stacks(false);
duke@435 107 }
duke@435 108
duke@435 109 //
duke@435 110 // ThreadRootsTask
duke@435 111 //
duke@435 112
duke@435 113 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 114 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 115
duke@435 116 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 117 PSScavengeRootsClosure roots_closure(pm);
jrose@1424 118 CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
duke@435 119
duke@435 120 if (_java_thread != NULL)
jrose@1424 121 _java_thread->oops_do(&roots_closure, &roots_in_blobs);
duke@435 122
duke@435 123 if (_vm_thread != NULL)
jrose@1424 124 _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
duke@435 125
duke@435 126 // Do the real work
duke@435 127 pm->drain_stacks(false);
duke@435 128 }
duke@435 129
duke@435 130 //
duke@435 131 // StealTask
duke@435 132 //
duke@435 133
duke@435 134 StealTask::StealTask(ParallelTaskTerminator* t) :
duke@435 135 _terminator(t) {}
duke@435 136
duke@435 137 void StealTask::do_it(GCTaskManager* manager, uint which) {
duke@435 138 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 139
duke@435 140 PSPromotionManager* pm =
duke@435 141 PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 142 pm->drain_stacks(true);
duke@435 143 guarantee(pm->stacks_empty(),
duke@435 144 "stacks should be empty at this point");
duke@435 145
duke@435 146 int random_seed = 17;
duke@435 147 if (pm->depth_first()) {
duke@435 148 while(true) {
coleenp@548 149 StarTask p;
duke@435 150 if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
jcoomes@2020 151 TASKQUEUE_STATS_ONLY(pm->record_steal(p));
duke@435 152 pm->process_popped_location_depth(p);
duke@435 153 pm->drain_stacks_depth(true);
duke@435 154 } else {
duke@435 155 if (terminator()->offer_termination()) {
duke@435 156 break;
duke@435 157 }
duke@435 158 }
duke@435 159 }
duke@435 160 } else {
duke@435 161 while(true) {
duke@435 162 oop obj;
duke@435 163 if (PSPromotionManager::steal_breadth(which, &random_seed, obj)) {
duke@435 164 obj->copy_contents(pm);
duke@435 165 pm->drain_stacks_breadth(true);
duke@435 166 } else {
duke@435 167 if (terminator()->offer_termination()) {
duke@435 168 break;
duke@435 169 }
duke@435 170 }
duke@435 171 }
duke@435 172 }
coleenp@548 173 guarantee(pm->stacks_empty(), "stacks should be empty at this point");
duke@435 174 }
duke@435 175
duke@435 176 //
duke@435 177 // SerialOldToYoungRootsTask
duke@435 178 //
duke@435 179
duke@435 180 void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 181 assert(_gen != NULL, "Sanity");
duke@435 182 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
duke@435 183
duke@435 184 {
duke@435 185 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 186
duke@435 187 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 188 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
duke@435 189 // FIX ME! Assert that card_table is the type we believe it to be.
duke@435 190
duke@435 191 card_table->scavenge_contents(_gen->start_array(),
duke@435 192 _gen->object_space(),
duke@435 193 _gen_top,
duke@435 194 pm);
duke@435 195
duke@435 196 // Do the real work
duke@435 197 pm->drain_stacks(false);
duke@435 198 }
duke@435 199 }
duke@435 200
duke@435 201 //
duke@435 202 // OldToYoungRootsTask
duke@435 203 //
duke@435 204
duke@435 205 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 206 assert(_gen != NULL, "Sanity");
duke@435 207 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
duke@435 208 assert(_stripe_number < ParallelGCThreads, "Sanity");
duke@435 209
duke@435 210 {
duke@435 211 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 212
duke@435 213 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 214 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
duke@435 215 // FIX ME! Assert that card_table is the type we believe it to be.
duke@435 216
duke@435 217 card_table->scavenge_contents_parallel(_gen->start_array(),
duke@435 218 _gen->object_space(),
duke@435 219 _gen_top,
duke@435 220 pm,
duke@435 221 _stripe_number);
duke@435 222
duke@435 223 // Do the real work
duke@435 224 pm->drain_stacks(false);
duke@435 225 }
duke@435 226 }

mercurial