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

Fri, 10 May 2013 08:27:30 -0700

author
minqi
date
Fri, 10 May 2013 08:27:30 -0700
changeset 5097
92ef81e2f571
parent 4298
d0aa87f04bd5
child 5194
eda078b01c65
permissions
-rw-r--r--

8003557: NPG: Klass* const k should be const Klass* k.
Summary: With NPG, const KlassOop klass which is in fact a definition converted to Klass* const, which is not the original intention. The right usage is converting them to const Klass*.
Reviewed-by: coleenp, kvn
Contributed-by: yumin.qi@oracle.com

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;
stefank@4298 68 CLDToOopClosure* cld_closure = NULL; // Not needed. All CLDs are already visited.
stefank@4298 69 Threads::oops_do(&roots_closure, cld_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:
coleenp@4037 82 {
duke@435 83 SystemDictionary::oops_do(&roots_closure);
coleenp@4037 84
coleenp@4037 85 // Move this to another root_type?
coleenp@4037 86 PSScavengeKlassClosure klass_closure(pm);
coleenp@4037 87 ClassLoaderDataGraph::oops_do(&roots_closure, &klass_closure, false);
coleenp@4037 88 }
duke@435 89 break;
duke@435 90
duke@435 91 case management:
duke@435 92 Management::oops_do(&roots_closure);
duke@435 93 break;
duke@435 94
duke@435 95 case jvmti:
duke@435 96 JvmtiExport::oops_do(&roots_closure);
duke@435 97 break;
duke@435 98
jrose@1424 99
jrose@1424 100 case code_cache:
jrose@1424 101 {
iveresov@3536 102 CodeBlobToOopClosure each_scavengable_code_blob(&roots_to_old_closure, /*do_marking=*/ true);
jrose@1424 103 CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
jrose@1424 104 }
jrose@1424 105 break;
jrose@1424 106
duke@435 107 default:
duke@435 108 fatal("Unknown root type");
duke@435 109 }
duke@435 110
duke@435 111 // Do the real work
duke@435 112 pm->drain_stacks(false);
duke@435 113 }
duke@435 114
duke@435 115 //
duke@435 116 // ThreadRootsTask
duke@435 117 //
duke@435 118
duke@435 119 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 120 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 121
duke@435 122 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 123 PSScavengeRootsClosure roots_closure(pm);
stefank@4298 124 CLDToOopClosure* roots_from_clds = NULL; // Not needed. All CLDs are already visited.
jrose@1424 125 CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
duke@435 126
duke@435 127 if (_java_thread != NULL)
stefank@4298 128 _java_thread->oops_do(&roots_closure, roots_from_clds, &roots_in_blobs);
duke@435 129
duke@435 130 if (_vm_thread != NULL)
stefank@4298 131 _vm_thread->oops_do(&roots_closure, roots_from_clds, &roots_in_blobs);
duke@435 132
duke@435 133 // Do the real work
duke@435 134 pm->drain_stacks(false);
duke@435 135 }
duke@435 136
duke@435 137 //
duke@435 138 // StealTask
duke@435 139 //
duke@435 140
duke@435 141 StealTask::StealTask(ParallelTaskTerminator* t) :
duke@435 142 _terminator(t) {}
duke@435 143
duke@435 144 void StealTask::do_it(GCTaskManager* manager, uint which) {
duke@435 145 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 146
duke@435 147 PSPromotionManager* pm =
duke@435 148 PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 149 pm->drain_stacks(true);
duke@435 150 guarantee(pm->stacks_empty(),
duke@435 151 "stacks should be empty at this point");
duke@435 152
duke@435 153 int random_seed = 17;
tonyp@2061 154 while(true) {
tonyp@2061 155 StarTask p;
tonyp@2061 156 if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
tonyp@2061 157 TASKQUEUE_STATS_ONLY(pm->record_steal(p));
tonyp@2061 158 pm->process_popped_location_depth(p);
tonyp@2061 159 pm->drain_stacks_depth(true);
tonyp@2061 160 } else {
tonyp@2061 161 if (terminator()->offer_termination()) {
tonyp@2061 162 break;
duke@435 163 }
duke@435 164 }
duke@435 165 }
coleenp@548 166 guarantee(pm->stacks_empty(), "stacks should be empty at this point");
duke@435 167 }
duke@435 168
duke@435 169 //
duke@435 170 // OldToYoungRootsTask
duke@435 171 //
duke@435 172
duke@435 173 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
jmasa@4128 174 // There are not old-to-young pointers if the old gen is empty.
jmasa@4128 175 assert(!_gen->object_space()->is_empty(),
jmasa@4128 176 "Should not be called is there is no work");
duke@435 177 assert(_gen != NULL, "Sanity");
duke@435 178 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
duke@435 179 assert(_stripe_number < ParallelGCThreads, "Sanity");
duke@435 180
duke@435 181 {
duke@435 182 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 183
duke@435 184 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 185 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
duke@435 186 // FIX ME! Assert that card_table is the type we believe it to be.
duke@435 187
duke@435 188 card_table->scavenge_contents_parallel(_gen->start_array(),
duke@435 189 _gen->object_space(),
duke@435 190 _gen_top,
duke@435 191 pm,
jmasa@3294 192 _stripe_number,
jmasa@3294 193 _stripe_total);
duke@435 194
duke@435 195 // Do the real work
duke@435 196 pm->drain_stacks(false);
duke@435 197 }
duke@435 198 }

mercurial