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

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 631
d1605aabd0a1
child 1424
148e5441d916
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

duke@435 1 /*
xdono@631 2 * Copyright 2002-2008 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any 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;
duke@435 69 Threads::oops_do(&roots_closure);
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
duke@435 93 default:
duke@435 94 fatal("Unknown root type");
duke@435 95 }
duke@435 96
duke@435 97 // Do the real work
duke@435 98 pm->drain_stacks(false);
duke@435 99 }
duke@435 100
duke@435 101 //
duke@435 102 // ThreadRootsTask
duke@435 103 //
duke@435 104
duke@435 105 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 106 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 107
duke@435 108 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 109 PSScavengeRootsClosure roots_closure(pm);
duke@435 110
duke@435 111 if (_java_thread != NULL)
duke@435 112 _java_thread->oops_do(&roots_closure);
duke@435 113
duke@435 114 if (_vm_thread != NULL)
duke@435 115 _vm_thread->oops_do(&roots_closure);
duke@435 116
duke@435 117 // Do the real work
duke@435 118 pm->drain_stacks(false);
duke@435 119 }
duke@435 120
duke@435 121 //
duke@435 122 // StealTask
duke@435 123 //
duke@435 124
duke@435 125 StealTask::StealTask(ParallelTaskTerminator* t) :
duke@435 126 _terminator(t) {}
duke@435 127
duke@435 128 void StealTask::do_it(GCTaskManager* manager, uint which) {
duke@435 129 assert(Universe::heap()->is_gc_active(), "called outside gc");
duke@435 130
duke@435 131 PSPromotionManager* pm =
duke@435 132 PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 133 pm->drain_stacks(true);
duke@435 134 guarantee(pm->stacks_empty(),
duke@435 135 "stacks should be empty at this point");
duke@435 136
duke@435 137 int random_seed = 17;
duke@435 138 if (pm->depth_first()) {
duke@435 139 while(true) {
coleenp@548 140 StarTask p;
duke@435 141 if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
duke@435 142 #if PS_PM_STATS
duke@435 143 pm->increment_steals(p);
duke@435 144 #endif // PS_PM_STATS
duke@435 145 pm->process_popped_location_depth(p);
duke@435 146 pm->drain_stacks_depth(true);
duke@435 147 } else {
duke@435 148 if (terminator()->offer_termination()) {
duke@435 149 break;
duke@435 150 }
duke@435 151 }
duke@435 152 }
duke@435 153 } else {
duke@435 154 while(true) {
duke@435 155 oop obj;
duke@435 156 if (PSPromotionManager::steal_breadth(which, &random_seed, obj)) {
duke@435 157 #if PS_PM_STATS
duke@435 158 pm->increment_steals();
duke@435 159 #endif // PS_PM_STATS
duke@435 160 obj->copy_contents(pm);
duke@435 161 pm->drain_stacks_breadth(true);
duke@435 162 } else {
duke@435 163 if (terminator()->offer_termination()) {
duke@435 164 break;
duke@435 165 }
duke@435 166 }
duke@435 167 }
duke@435 168 }
coleenp@548 169 guarantee(pm->stacks_empty(), "stacks should be empty at this point");
duke@435 170 }
duke@435 171
duke@435 172 //
duke@435 173 // SerialOldToYoungRootsTask
duke@435 174 //
duke@435 175
duke@435 176 void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
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
duke@435 180 {
duke@435 181 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 182
duke@435 183 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 184 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
duke@435 185 // FIX ME! Assert that card_table is the type we believe it to be.
duke@435 186
duke@435 187 card_table->scavenge_contents(_gen->start_array(),
duke@435 188 _gen->object_space(),
duke@435 189 _gen_top,
duke@435 190 pm);
duke@435 191
duke@435 192 // Do the real work
duke@435 193 pm->drain_stacks(false);
duke@435 194 }
duke@435 195 }
duke@435 196
duke@435 197 //
duke@435 198 // OldToYoungRootsTask
duke@435 199 //
duke@435 200
duke@435 201 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
duke@435 202 assert(_gen != NULL, "Sanity");
duke@435 203 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
duke@435 204 assert(_stripe_number < ParallelGCThreads, "Sanity");
duke@435 205
duke@435 206 {
duke@435 207 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
duke@435 208
duke@435 209 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 210 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
duke@435 211 // FIX ME! Assert that card_table is the type we believe it to be.
duke@435 212
duke@435 213 card_table->scavenge_contents_parallel(_gen->start_array(),
duke@435 214 _gen->object_space(),
duke@435 215 _gen_top,
duke@435 216 pm,
duke@435 217 _stripe_number);
duke@435 218
duke@435 219 // Do the real work
duke@435 220 pm->drain_stacks(false);
duke@435 221 }
duke@435 222 }

mercurial