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

Tue, 22 Mar 2011 13:36:33 -0700

author
jcoomes
date
Tue, 22 Mar 2011 13:36:33 -0700
changeset 2661
b099aaf51bf8
parent 2314
f95d63e2154a
child 2708
1d1603768966
permissions
-rw-r--r--

6962931: move interned strings out of the perm gen
Reviewed-by: never, coleenp, ysr, jwilhelm

     1 /*
     2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "classfile/systemDictionary.hpp"
    27 #include "code/codeCache.hpp"
    28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
    29 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
    30 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
    31 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
    32 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
    33 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
    34 #include "gc_implementation/parallelScavenge/psTasks.hpp"
    35 #include "memory/iterator.hpp"
    36 #include "memory/universe.hpp"
    37 #include "oops/oop.inline.hpp"
    38 #include "oops/oop.psgc.inline.hpp"
    39 #include "runtime/fprofiler.hpp"
    40 #include "runtime/thread.hpp"
    41 #include "runtime/vmThread.hpp"
    42 #include "services/management.hpp"
    43 #include "utilities/taskqueue.hpp"
    45 //
    46 // ScavengeRootsTask
    47 //
    49 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
    50   assert(Universe::heap()->is_gc_active(), "called outside gc");
    52   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
    53   PSScavengeRootsClosure roots_closure(pm);
    55   switch (_root_type) {
    56     case universe:
    57       Universe::oops_do(&roots_closure);
    58       ReferenceProcessor::oops_do(&roots_closure);
    59       break;
    61     case jni_handles:
    62       JNIHandles::oops_do(&roots_closure);
    63       break;
    65     case threads:
    66     {
    67       ResourceMark rm;
    68       Threads::oops_do(&roots_closure, NULL);
    69     }
    70     break;
    72     case object_synchronizer:
    73       ObjectSynchronizer::oops_do(&roots_closure);
    74       break;
    76     case flat_profiler:
    77       FlatProfiler::oops_do(&roots_closure);
    78       break;
    80     case system_dictionary:
    81       SystemDictionary::oops_do(&roots_closure);
    82       break;
    84     case management:
    85       Management::oops_do(&roots_closure);
    86       break;
    88     case jvmti:
    89       JvmtiExport::oops_do(&roots_closure);
    90       break;
    93     case code_cache:
    94       {
    95         CodeBlobToOopClosure each_scavengable_code_blob(&roots_closure, /*do_marking=*/ true);
    96         CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
    97       }
    98       break;
   100     default:
   101       fatal("Unknown root type");
   102   }
   104   // Do the real work
   105   pm->drain_stacks(false);
   106 }
   108 //
   109 // ThreadRootsTask
   110 //
   112 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
   113   assert(Universe::heap()->is_gc_active(), "called outside gc");
   115   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   116   PSScavengeRootsClosure roots_closure(pm);
   117   CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
   119   if (_java_thread != NULL)
   120     _java_thread->oops_do(&roots_closure, &roots_in_blobs);
   122   if (_vm_thread != NULL)
   123     _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
   125   // Do the real work
   126   pm->drain_stacks(false);
   127 }
   129 //
   130 // StealTask
   131 //
   133 StealTask::StealTask(ParallelTaskTerminator* t) :
   134   _terminator(t) {}
   136 void StealTask::do_it(GCTaskManager* manager, uint which) {
   137   assert(Universe::heap()->is_gc_active(), "called outside gc");
   139   PSPromotionManager* pm =
   140     PSPromotionManager::gc_thread_promotion_manager(which);
   141   pm->drain_stacks(true);
   142   guarantee(pm->stacks_empty(),
   143             "stacks should be empty at this point");
   145   int random_seed = 17;
   146   while(true) {
   147     StarTask p;
   148     if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
   149       TASKQUEUE_STATS_ONLY(pm->record_steal(p));
   150       pm->process_popped_location_depth(p);
   151       pm->drain_stacks_depth(true);
   152     } else {
   153       if (terminator()->offer_termination()) {
   154         break;
   155       }
   156     }
   157   }
   158   guarantee(pm->stacks_empty(), "stacks should be empty at this point");
   159 }
   161 //
   162 // SerialOldToYoungRootsTask
   163 //
   165 void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
   166   assert(_gen != NULL, "Sanity");
   167   assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
   169   {
   170     PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   172     assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   173     CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
   174     // FIX ME! Assert that card_table is the type we believe it to be.
   176     card_table->scavenge_contents(_gen->start_array(),
   177                                   _gen->object_space(),
   178                                   _gen_top,
   179                                   pm);
   181     // Do the real work
   182     pm->drain_stacks(false);
   183   }
   184 }
   186 //
   187 // OldToYoungRootsTask
   188 //
   190 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
   191   assert(_gen != NULL, "Sanity");
   192   assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
   193   assert(_stripe_number < ParallelGCThreads, "Sanity");
   195   {
   196     PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   198     assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   199     CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
   200     // FIX ME! Assert that card_table is the type we believe it to be.
   202     card_table->scavenge_contents_parallel(_gen->start_array(),
   203                                            _gen->object_space(),
   204                                            _gen_top,
   205                                            pm,
   206                                            _stripe_number);
   208     // Do the real work
   209     pm->drain_stacks(false);
   210   }
   211 }

mercurial