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

Fri, 07 Sep 2012 12:04:16 -0400

author
coleenp
date
Fri, 07 Sep 2012 12:04:16 -0400
changeset 4047
aed758eda82a
parent 4037
da91efe96a93
child 4128
f81a7c0c618d
permissions
-rw-r--r--

7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
Summary: Simple renaming to be consistent with instanceKlass->InstanceKlass renaming
Reviewed-by: stefank, jmasa

duke@435 1 /*
iveresov@3536 2 * Copyright (c) 2002, 2012, 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
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/systemDictionary.hpp"
stefank@2314 27 #include "code/codeCache.hpp"
stefank@2314 28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
stefank@2314 29 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
stefank@2314 30 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
stefank@2314 31 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
stefank@2314 32 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
jcoomes@2661 33 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
stefank@2314 34 #include "gc_implementation/parallelScavenge/psTasks.hpp"
stefank@2314 35 #include "memory/iterator.hpp"
stefank@2314 36 #include "memory/universe.hpp"
stefank@2314 37 #include "oops/oop.inline.hpp"
stefank@2314 38 #include "oops/oop.psgc.inline.hpp"
stefank@2314 39 #include "runtime/fprofiler.hpp"
stefank@2314 40 #include "runtime/thread.hpp"
stefank@2314 41 #include "runtime/vmThread.hpp"
stefank@2314 42 #include "services/management.hpp"
stefank@2314 43 #include "utilities/taskqueue.hpp"
duke@435 44
duke@435 45 //
duke@435 46 // ScavengeRootsTask
duke@435 47 //
duke@435 48
duke@435 49 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 50 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 51
duke@435 52 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 53 PSScavengeRootsClosure roots_closure(pm);
iveresov@3536 54 PSPromoteRootsClosure roots_to_old_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 break;
duke@435 60
duke@435 61 case jni_handles:
duke@435 62 JNIHandles::oops_do(&roots_closure);
duke@435 63 break;
duke@435 64
duke@435 65 case threads:
duke@435 66 {
duke@435 67 ResourceMark rm;
jrose@1424 68 Threads::oops_do(&roots_closure, NULL);
duke@435 69 }
duke@435 70 break;
duke@435 71
duke@435 72 case object_synchronizer:
duke@435 73 ObjectSynchronizer::oops_do(&roots_closure);
duke@435 74 break;
duke@435 75
duke@435 76 case flat_profiler:
duke@435 77 FlatProfiler::oops_do(&roots_closure);
duke@435 78 break;
duke@435 79
duke@435 80 case system_dictionary:
coleenp@4037 81 {
duke@435 82 SystemDictionary::oops_do(&roots_closure);
coleenp@4037 83
coleenp@4037 84 // Move this to another root_type?
coleenp@4037 85 PSScavengeKlassClosure klass_closure(pm);
coleenp@4037 86 ClassLoaderDataGraph::oops_do(&roots_closure, &klass_closure, false);
coleenp@4037 87 }
duke@435 88 break;
duke@435 89
duke@435 90 case management:
duke@435 91 Management::oops_do(&roots_closure);
duke@435 92 break;
duke@435 93
duke@435 94 case jvmti:
duke@435 95 JvmtiExport::oops_do(&roots_closure);
duke@435 96 break;
duke@435 97
jrose@1424 98
jrose@1424 99 case code_cache:
jrose@1424 100 {
iveresov@3536 101 CodeBlobToOopClosure each_scavengable_code_blob(&roots_to_old_closure, /*do_marking=*/ true);
jrose@1424 102 CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
jrose@1424 103 }
jrose@1424 104 break;
jrose@1424 105
duke@435 106 default:
duke@435 107 fatal("Unknown root type");
duke@435 108 }
duke@435 109
duke@435 110 // Do the real work
duke@435 111 pm->drain_stacks(false);
duke@435 112 }
duke@435 113
duke@435 114 //
duke@435 115 // ThreadRootsTask
duke@435 116 //
duke@435 117
duke@435 118 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 119 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 120
duke@435 121 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 122 PSScavengeRootsClosure roots_closure(pm);
jrose@1424 123 CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
duke@435 124
duke@435 125 if (_java_thread != NULL)
jrose@1424 126 _java_thread->oops_do(&roots_closure, &roots_in_blobs);
duke@435 127
duke@435 128 if (_vm_thread != NULL)
jrose@1424 129 _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
duke@435 130
duke@435 131 // Do the real work
duke@435 132 pm->drain_stacks(false);
duke@435 133 }
duke@435 134
duke@435 135 //
duke@435 136 // StealTask
duke@435 137 //
duke@435 138
duke@435 139 StealTask::StealTask(ParallelTaskTerminator* t) :
duke@435 140 _terminator(t) {}
duke@435 141
duke@435 142 void StealTask::do_it(GCTaskManager* manager, uint which) {
duke@435 143 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 144
duke@435 145 PSPromotionManager* pm =
duke@435 146 PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 147 pm->drain_stacks(true);
duke@435 148 guarantee(pm->stacks_empty(),
duke@435 149 "stacks should be empty at this point");
duke@435 150
duke@435 151 int random_seed = 17;
tonyp@2061 152 while(true) {
tonyp@2061 153 StarTask p;
tonyp@2061 154 if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
tonyp@2061 155 TASKQUEUE_STATS_ONLY(pm->record_steal(p));
tonyp@2061 156 pm->process_popped_location_depth(p);
tonyp@2061 157 pm->drain_stacks_depth(true);
tonyp@2061 158 } else {
tonyp@2061 159 if (terminator()->offer_termination()) {
tonyp@2061 160 break;
duke@435 161 }
duke@435 162 }
duke@435 163 }
coleenp@548 164 guarantee(pm->stacks_empty(), "stacks should be empty at this point");
duke@435 165 }
duke@435 166
duke@435 167 //
duke@435 168 // SerialOldToYoungRootsTask
duke@435 169 //
duke@435 170
duke@435 171 void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 172 assert(_gen != NULL, "Sanity");
duke@435 173 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
duke@435 174
duke@435 175 {
duke@435 176 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 177
duke@435 178 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 179 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
duke@435 180 // FIX ME! Assert that card_table is the type we believe it to be.
duke@435 181
duke@435 182 card_table->scavenge_contents(_gen->start_array(),
duke@435 183 _gen->object_space(),
duke@435 184 _gen_top,
duke@435 185 pm);
duke@435 186
duke@435 187 // Do the real work
duke@435 188 pm->drain_stacks(false);
duke@435 189 }
duke@435 190 }
duke@435 191
duke@435 192 //
duke@435 193 // OldToYoungRootsTask
duke@435 194 //
duke@435 195
duke@435 196 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 197 assert(_gen != NULL, "Sanity");
duke@435 198 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
duke@435 199 assert(_stripe_number < ParallelGCThreads, "Sanity");
duke@435 200
duke@435 201 {
duke@435 202 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 203
duke@435 204 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 205 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
duke@435 206 // FIX ME! Assert that card_table is the type we believe it to be.
duke@435 207
duke@435 208 card_table->scavenge_contents_parallel(_gen->start_array(),
duke@435 209 _gen->object_space(),
duke@435 210 _gen_top,
duke@435 211 pm,
jmasa@3294 212 _stripe_number,
jmasa@3294 213 _stripe_total);
duke@435 214
duke@435 215 // Do the real work
duke@435 216 pm->drain_stacks(false);
duke@435 217 }
duke@435 218 }

mercurial