src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.hpp

Mon, 01 Dec 2008 23:25:24 -0800

author
ysr
date
Mon, 01 Dec 2008 23:25:24 -0800
changeset 892
27a80744a83b
parent 810
81cd571500b0
child 905
ad8c8ca4ab0f
permissions
-rw-r--r--

6778647: snap(), snap_policy() should be renamed setup(), setup_policy()
Summary: Renamed Reference{Policy,Pocessor} methods from snap{,_policy}() to setup{,_policy}()
Reviewed-by: apetrusenko

     1 /*
     2  * Copyright 2005-2007 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 //
    26 // psPromotionManager is used by a single thread to manage object survival
    27 // during a scavenge. The promotion manager contains thread local data only.
    28 //
    29 // NOTE! Be carefull when allocating the stacks on cheap. If you are going
    30 // to use a promotion manager in more than one thread, the stacks MUST be
    31 // on cheap. This can lead to memory leaks, though, as they are not auto
    32 // deallocated.
    33 //
    34 // FIX ME FIX ME Add a destructor, and don't rely on the user to drain/flush/deallocate!
    35 //
    37 // Move to some global location
    38 #define HAS_BEEN_MOVED 0x1501d01d
    39 // End move to some global location
    42 class MutableSpace;
    43 class PSOldGen;
    44 class ParCompactionManager;
    45 class ObjectStartArray;
    46 class ParallelCompactData;
    47 class ParMarkBitMap;
    49 // Move to it's own file if this works out.
    51 class ParCompactionManager : public CHeapObj {
    52   friend class ParallelTaskTerminator;
    53   friend class ParMarkBitMap;
    54   friend class PSParallelCompact;
    55   friend class StealRegionCompactionTask;
    56   friend class UpdateAndFillClosure;
    57   friend class RefProcTaskExecutor;
    59  public:
    61 // ------------------------  Don't putback if not needed
    62   // Actions that the compaction manager should take.
    63   enum Action {
    64     Update,
    65     Copy,
    66     UpdateAndCopy,
    67     CopyAndUpdate,
    68     VerifyUpdate,
    69     ResetObjects,
    70     NotValid
    71   };
    72 // ------------------------  End don't putback if not needed
    74  private:
    75   static ParCompactionManager** _manager_array;
    76   static OopTaskQueueSet*       _stack_array;
    77   static ObjectStartArray*      _start_array;
    78   static RegionTaskQueueSet*    _region_array;
    79   static PSOldGen*              _old_gen;
    81   OopTaskQueue                  _marking_stack;
    82   GrowableArray<oop>*           _overflow_stack;
    83   // Is there a way to reuse the _marking_stack for the
    84   // saving empty regions?  For now just create a different
    85   // type of TaskQueue.
    87 #ifdef USE_RegionTaskQueueWithOverflow
    88   RegionTaskQueueWithOverflow   _region_stack;
    89 #else
    90   RegionTaskQueue               _region_stack;
    91   GrowableArray<size_t>*        _region_overflow_stack;
    92 #endif
    94 #if 1  // does this happen enough to need a per thread stack?
    95   GrowableArray<Klass*>*        _revisit_klass_stack;
    96 #endif
    97   static ParMarkBitMap* _mark_bitmap;
    99   Action _action;
   101   static PSOldGen* old_gen()             { return _old_gen; }
   102   static ObjectStartArray* start_array() { return _start_array; }
   103   static OopTaskQueueSet* stack_array()  { return _stack_array; }
   105   static void initialize(ParMarkBitMap* mbm);
   107  protected:
   108   // Array of tasks.  Needed by the ParallelTaskTerminator.
   109   static RegionTaskQueueSet* region_array()      { return _region_array; }
   110   OopTaskQueue*  marking_stack()                 { return &_marking_stack; }
   111   GrowableArray<oop>* overflow_stack()           { return _overflow_stack; }
   112 #ifdef USE_RegionTaskQueueWithOverflow
   113   RegionTaskQueueWithOverflow* region_stack()    { return &_region_stack; }
   114 #else
   115   RegionTaskQueue*  region_stack()               { return &_region_stack; }
   116   GrowableArray<size_t>* region_overflow_stack() {
   117     return _region_overflow_stack;
   118   }
   119 #endif
   121   // Pushes onto the marking stack.  If the marking stack is full,
   122   // pushes onto the overflow stack.
   123   void stack_push(oop obj);
   124   // Do not implement an equivalent stack_pop.  Deal with the
   125   // marking stack and overflow stack directly.
   127   // Pushes onto the region stack.  If the region stack is full,
   128   // pushes onto the region overflow stack.
   129   void region_stack_push(size_t region_index);
   130  public:
   132   Action action() { return _action; }
   133   void set_action(Action v) { _action = v; }
   135   inline static ParCompactionManager* manager_array(int index);
   137   ParCompactionManager();
   138   ~ParCompactionManager();
   140   void allocate_stacks();
   141   void deallocate_stacks();
   142   ParMarkBitMap* mark_bitmap() { return _mark_bitmap; }
   144   // Take actions in preparation for a compaction.
   145   static void reset();
   147   // void drain_stacks();
   149   bool should_update();
   150   bool should_copy();
   151   bool should_verify_only();
   152   bool should_reset_only();
   154 #if 1
   155   // Probably stays as a growable array
   156   GrowableArray<Klass*>* revisit_klass_stack() { return _revisit_klass_stack; }
   157 #endif
   159   // Save oop for later processing.  Must not fail.
   160   void save_for_scanning(oop m);
   161   // Get a oop for scanning.  If returns null, no oop were found.
   162   oop retrieve_for_scanning();
   164   // Save region for later processing.  Must not fail.
   165   void save_for_processing(size_t region_index);
   166   // Get a region for processing.  If returns null, no region were found.
   167   bool retrieve_for_processing(size_t& region_index);
   169   // Access function for compaction managers
   170   static ParCompactionManager* gc_thread_compaction_manager(int index);
   172   static bool steal(int queue_num, int* seed, Task& t) {
   173     return stack_array()->steal(queue_num, seed, t);
   174   }
   176   static bool steal(int queue_num, int* seed, RegionTask& t) {
   177     return region_array()->steal(queue_num, seed, t);
   178   }
   180   // Process tasks remaining on any stack
   181   void drain_marking_stacks(OopClosure *blk);
   183   // Process tasks remaining on any stack
   184   void drain_region_stacks();
   186   // Process tasks remaining on any stack
   187   void drain_region_overflow_stack();
   189   // Debugging support
   190 #ifdef ASSERT
   191   bool stacks_have_been_allocated();
   192 #endif
   193 };
   195 inline ParCompactionManager* ParCompactionManager::manager_array(int index) {
   196   assert(_manager_array != NULL, "access of NULL manager_array");
   197   assert(index >= 0 && index <= (int)ParallelGCThreads,
   198     "out of range manager_array access");
   199   return _manager_array[index];
   200 }

mercurial