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

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 548
ba764ed4b6f2
child 1424
148e5441d916
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

     1 /*
     2  * Copyright 2002-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_psTasks.cpp.incl"
    28 //
    29 // ScavengeRootsTask
    30 //
    32 // Define before use
    33 class PSScavengeRootsClosure: public OopClosure {
    34  private:
    35   PSPromotionManager* _promotion_manager;
    37  protected:
    38   template <class T> void do_oop_work(T *p) {
    39     if (PSScavenge::should_scavenge(p)) {
    40       // We never card mark roots, maybe call a func without test?
    41       PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
    42     }
    43   }
    44  public:
    45   PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
    46   void do_oop(oop* p)       { PSScavengeRootsClosure::do_oop_work(p); }
    47   void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
    48 };
    50 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
    51   assert(Universe::heap()->is_gc_active(), "called outside gc");
    53   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
    54   PSScavengeRootsClosure roots_closure(pm);
    56   switch (_root_type) {
    57     case universe:
    58       Universe::oops_do(&roots_closure);
    59       ReferenceProcessor::oops_do(&roots_closure);
    60       break;
    62     case jni_handles:
    63       JNIHandles::oops_do(&roots_closure);
    64       break;
    66     case threads:
    67     {
    68       ResourceMark rm;
    69       Threads::oops_do(&roots_closure);
    70     }
    71     break;
    73     case object_synchronizer:
    74       ObjectSynchronizer::oops_do(&roots_closure);
    75       break;
    77     case flat_profiler:
    78       FlatProfiler::oops_do(&roots_closure);
    79       break;
    81     case system_dictionary:
    82       SystemDictionary::oops_do(&roots_closure);
    83       break;
    85     case management:
    86       Management::oops_do(&roots_closure);
    87       break;
    89     case jvmti:
    90       JvmtiExport::oops_do(&roots_closure);
    91       break;
    93     default:
    94       fatal("Unknown root type");
    95   }
    97   // Do the real work
    98   pm->drain_stacks(false);
    99 }
   101 //
   102 // ThreadRootsTask
   103 //
   105 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
   106   assert(Universe::heap()->is_gc_active(), "called outside gc");
   108   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   109   PSScavengeRootsClosure roots_closure(pm);
   111   if (_java_thread != NULL)
   112     _java_thread->oops_do(&roots_closure);
   114   if (_vm_thread != NULL)
   115     _vm_thread->oops_do(&roots_closure);
   117   // Do the real work
   118   pm->drain_stacks(false);
   119 }
   121 //
   122 // StealTask
   123 //
   125 StealTask::StealTask(ParallelTaskTerminator* t) :
   126   _terminator(t) {}
   128 void StealTask::do_it(GCTaskManager* manager, uint which) {
   129   assert(Universe::heap()->is_gc_active(), "called outside gc");
   131   PSPromotionManager* pm =
   132     PSPromotionManager::gc_thread_promotion_manager(which);
   133   pm->drain_stacks(true);
   134   guarantee(pm->stacks_empty(),
   135             "stacks should be empty at this point");
   137   int random_seed = 17;
   138   if (pm->depth_first()) {
   139     while(true) {
   140       StarTask p;
   141       if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
   142 #if PS_PM_STATS
   143         pm->increment_steals(p);
   144 #endif // PS_PM_STATS
   145         pm->process_popped_location_depth(p);
   146         pm->drain_stacks_depth(true);
   147       } else {
   148         if (terminator()->offer_termination()) {
   149           break;
   150         }
   151       }
   152     }
   153   } else {
   154     while(true) {
   155       oop obj;
   156       if (PSPromotionManager::steal_breadth(which, &random_seed, obj)) {
   157 #if PS_PM_STATS
   158         pm->increment_steals();
   159 #endif // PS_PM_STATS
   160         obj->copy_contents(pm);
   161         pm->drain_stacks_breadth(true);
   162       } else {
   163         if (terminator()->offer_termination()) {
   164           break;
   165         }
   166       }
   167     }
   168   }
   169   guarantee(pm->stacks_empty(), "stacks should be empty at this point");
   170 }
   172 //
   173 // SerialOldToYoungRootsTask
   174 //
   176 void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
   177   assert(_gen != NULL, "Sanity");
   178   assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
   180   {
   181     PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   183     assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   184     CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
   185     // FIX ME! Assert that card_table is the type we believe it to be.
   187     card_table->scavenge_contents(_gen->start_array(),
   188                                   _gen->object_space(),
   189                                   _gen_top,
   190                                   pm);
   192     // Do the real work
   193     pm->drain_stacks(false);
   194   }
   195 }
   197 //
   198 // OldToYoungRootsTask
   199 //
   201 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
   202   assert(_gen != NULL, "Sanity");
   203   assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
   204   assert(_stripe_number < ParallelGCThreads, "Sanity");
   206   {
   207     PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
   209     assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   210     CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
   211     // FIX ME! Assert that card_table is the type we believe it to be.
   213     card_table->scavenge_contents_parallel(_gen->start_array(),
   214                                            _gen->object_space(),
   215                                            _gen_top,
   216                                            pm,
   217                                            _stripe_number);
   219     // Do the real work
   220     pm->drain_stacks(false);
   221   }
   222 }

mercurial