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

Tue, 09 Oct 2012 10:09:34 -0700

author
mikael
date
Tue, 09 Oct 2012 10:09:34 -0700
changeset 4153
b9a9ed0f8eeb
parent 4128
f81a7c0c618d
child 4298
d0aa87f04bd5
permissions
-rw-r--r--

7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp

     1 /*
     2  * Copyright (c) 2002, 2012, 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);
    54   PSPromoteRootsClosure  roots_to_old_closure(pm);
    56   switch (_root_type) {
    57     case universe:
    58       Universe::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       {
    82       SystemDictionary::oops_do(&roots_closure);
    84         // Move this to another root_type?
    85         PSScavengeKlassClosure klass_closure(pm);
    86         ClassLoaderDataGraph::oops_do(&roots_closure, &klass_closure, false);
    87       }
    88       break;
    90     case management:
    91       Management::oops_do(&roots_closure);
    92       break;
    94     case jvmti:
    95       JvmtiExport::oops_do(&roots_closure);
    96       break;
    99     case code_cache:
   100       {
   101         CodeBlobToOopClosure each_scavengable_code_blob(&roots_to_old_closure, /*do_marking=*/ true);
   102         CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
   103       }
   104       break;
   106     default:
   107       fatal("Unknown root type");
   108   }
   110   // Do the real work
   111   pm->drain_stacks(false);
   112 }
   114 //
   115 // ThreadRootsTask
   116 //
   118 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
   119   assert(Universe::heap()->is_gc_active(), "called outside gc");
   121   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   122   PSScavengeRootsClosure roots_closure(pm);
   123   CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
   125   if (_java_thread != NULL)
   126     _java_thread->oops_do(&roots_closure, &roots_in_blobs);
   128   if (_vm_thread != NULL)
   129     _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
   131   // Do the real work
   132   pm->drain_stacks(false);
   133 }
   135 //
   136 // StealTask
   137 //
   139 StealTask::StealTask(ParallelTaskTerminator* t) :
   140   _terminator(t) {}
   142 void StealTask::do_it(GCTaskManager* manager, uint which) {
   143   assert(Universe::heap()->is_gc_active(), "called outside gc");
   145   PSPromotionManager* pm =
   146     PSPromotionManager::gc_thread_promotion_manager(which);
   147   pm->drain_stacks(true);
   148   guarantee(pm->stacks_empty(),
   149             "stacks should be empty at this point");
   151   int random_seed = 17;
   152   while(true) {
   153     StarTask p;
   154     if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
   155       TASKQUEUE_STATS_ONLY(pm->record_steal(p));
   156       pm->process_popped_location_depth(p);
   157       pm->drain_stacks_depth(true);
   158     } else {
   159       if (terminator()->offer_termination()) {
   160         break;
   161       }
   162     }
   163   }
   164   guarantee(pm->stacks_empty(), "stacks should be empty at this point");
   165 }
   167 //
   168 // OldToYoungRootsTask
   169 //
   171 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
   172   // There are not old-to-young pointers if the old gen is empty.
   173   assert(!_gen->object_space()->is_empty(),
   174     "Should not be called is there is no work");
   175   assert(_gen != NULL, "Sanity");
   176   assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
   177   assert(_stripe_number < ParallelGCThreads, "Sanity");
   179   {
   180     PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   182     assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   183     CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
   184     // FIX ME! Assert that card_table is the type we believe it to be.
   186     card_table->scavenge_contents_parallel(_gen->start_array(),
   187                                            _gen->object_space(),
   188                                            _gen_top,
   189                                            pm,
   190                                            _stripe_number,
   191                                            _stripe_total);
   193     // Do the real work
   194     pm->drain_stacks(false);
   195   }
   196 }

mercurial