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

Fri, 10 Feb 2012 17:40:20 -0800

author
iveresov
date
Fri, 10 Feb 2012 17:40:20 -0800
changeset 3536
95f6641e38e0
parent 3294
bca17e38de00
child 4037
da91efe96a93
permissions
-rw-r--r--

7144296: PS: Optimize nmethods processing
Summary: Prunes scavenge roots in code list every young GC, promote objects directly pointed by the code immediately
Reviewed-by: johnc, jcoomes

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

mercurial