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

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
   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  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
  27 
  28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
  29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
  30 #include "gc_implementation/shared/collectorCounters.hpp"

  31 #include "memory/allocation.hpp"
  32 #include "oops/oop.hpp"
  33 #include "utilities/stack.hpp"
  34 
  35 class GCTaskManager;
  36 class GCTaskQueue;
  37 class OopStack;
  38 class ReferenceProcessor;
  39 class ParallelScavengeHeap;

  40 class PSIsAliveClosure;
  41 class PSRefProcTaskExecutor;

  42 
  43 class PSScavenge: AllStatic {
  44   friend class PSIsAliveClosure;
  45   friend class PSKeepAliveClosure;
  46   friend class PSPromotionManager;
  47 
  48  enum ScavengeSkippedCause {
  49    not_skipped = 0,
  50    to_space_not_empty,
  51    promoted_too_large,
  52    full_follows_scavenge
  53  };
  54 
  55   // Saved value of to_space->top(), used to prevent objects in to_space from
  56   // being rescanned.
  57   static HeapWord* _to_space_top_before_gc;
  58 
  59   // Number of consecutive attempts to scavenge that were skipped
  60   static int                _consecutive_skipped_scavenges;
  61 
  62 
  63  protected:
  64   // Flags/counters
  65   static ReferenceProcessor* _ref_processor;        // Reference processor for scavenging.
  66   static PSIsAliveClosure    _is_alive_closure;     // Closure used for reference processing
  67   static CardTableExtension* _card_table;           // We cache the card table for fast access.
  68   static bool                _survivor_overflow;    // Overflow this collection
  69   static uint                _tenuring_threshold;   // tenuring threshold for next scavenge
  70   static elapsedTimer        _accumulated_time;     // total time spent on scavenge


  71   static HeapWord*           _young_generation_boundary; // The lowest address possible for the young_gen.
  72                                                          // This is used to decide if an oop should be scavenged,
  73                                                          // cards should be marked, etc.
  74   static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
  75   static Stack<oop, mtGC>     _preserved_oop_stack;  // List of oops that need their mark restored.
  76   static CollectorCounters*      _counters;          // collector performance counters
  77   static bool                    _promotion_failed;
  78 
  79   static void clean_up_failed_promotion();
  80 
  81   static bool should_attempt_scavenge();
  82 
  83   static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
  84   static inline void save_to_space_top_before_gc();
  85 
  86   // Private accessors
  87   static CardTableExtension* const card_table()       { assert(_card_table != NULL, "Sanity"); return _card_table; }
  88 
  89  public:
  90   // Accessors
  91   static uint             tenuring_threshold()  { return _tenuring_threshold; }
  92   static elapsedTimer*    accumulated_time()    { return &_accumulated_time; }
  93   static bool             promotion_failed()    { return _promotion_failed; }
  94   static int              consecutive_skipped_scavenges()
  95     { return _consecutive_skipped_scavenges; }
  96 
  97   // Performance Counters
  98   static CollectorCounters* counters()           { return _counters; }
  99 
 100   // Used by scavenge_contents && psMarkSweep
 101   static ReferenceProcessor* const reference_processor() {
 102     assert(_ref_processor != NULL, "Sanity");
 103     return _ref_processor;
 104   }
 105   // Used to add tasks
 106   static GCTaskManager* const gc_task_manager();
 107   // The promotion managers tell us if they encountered overflow
 108   static void set_survivor_overflow(bool state) {
 109     _survivor_overflow = state;
 110   }
 111   // Adaptive size policy support.  When the young generation/old generation
 112   // boundary moves, _young_generation_boundary must be reset
 113   static void set_young_generation_boundary(HeapWord* v) {


   1 /*
   2  * Copyright (c) 2002, 2013, 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  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
  27 
  28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
  29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
  30 #include "gc_implementation/shared/collectorCounters.hpp"
  31 #include "gc_implementation/shared/gcTrace.hpp"
  32 #include "memory/allocation.hpp"
  33 #include "oops/oop.hpp"
  34 #include "utilities/stack.hpp"
  35 
  36 class GCTaskManager;
  37 class GCTaskQueue;
  38 class OopStack;
  39 class ReferenceProcessor;
  40 class ParallelScavengeHeap;
  41 class ParallelScavengeTracer;
  42 class PSIsAliveClosure;
  43 class PSRefProcTaskExecutor;
  44 class STWGCTimer;
  45 
  46 class PSScavenge: AllStatic {
  47   friend class PSIsAliveClosure;
  48   friend class PSKeepAliveClosure;
  49   friend class PSPromotionManager;
  50 
  51  enum ScavengeSkippedCause {
  52    not_skipped = 0,
  53    to_space_not_empty,
  54    promoted_too_large,
  55    full_follows_scavenge
  56  };
  57 
  58   // Saved value of to_space->top(), used to prevent objects in to_space from
  59   // being rescanned.
  60   static HeapWord* _to_space_top_before_gc;
  61 
  62   // Number of consecutive attempts to scavenge that were skipped
  63   static int                _consecutive_skipped_scavenges;
  64 
  65 
  66  protected:
  67   // Flags/counters
  68   static ReferenceProcessor* _ref_processor;        // Reference processor for scavenging.
  69   static PSIsAliveClosure    _is_alive_closure;     // Closure used for reference processing
  70   static CardTableExtension* _card_table;           // We cache the card table for fast access.
  71   static bool                _survivor_overflow;    // Overflow this collection
  72   static uint                _tenuring_threshold;   // tenuring threshold for next scavenge
  73   static elapsedTimer        _accumulated_time;     // total time spent on scavenge
  74   static STWGCTimer          _gc_timer;             // GC time book keeper
  75   static ParallelScavengeTracer _gc_tracer;         // GC tracing
  76   static HeapWord*           _young_generation_boundary; // The lowest address possible for the young_gen.
  77                                                          // This is used to decide if an oop should be scavenged,
  78                                                          // cards should be marked, etc.
  79   static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
  80   static Stack<oop, mtGC>     _preserved_oop_stack;  // List of oops that need their mark restored.
  81   static CollectorCounters*      _counters;          // collector performance counters

  82 
  83   static void clean_up_failed_promotion();
  84 
  85   static bool should_attempt_scavenge();
  86 
  87   static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
  88   static inline void save_to_space_top_before_gc();
  89 
  90   // Private accessors
  91   static CardTableExtension* const card_table()       { assert(_card_table != NULL, "Sanity"); return _card_table; }
  92 
  93  public:
  94   // Accessors
  95   static uint             tenuring_threshold()  { return _tenuring_threshold; }
  96   static elapsedTimer*    accumulated_time()    { return &_accumulated_time; }

  97   static int              consecutive_skipped_scavenges()
  98     { return _consecutive_skipped_scavenges; }
  99 
 100   // Performance Counters
 101   static CollectorCounters* counters()           { return _counters; }
 102 
 103   // Used by scavenge_contents && psMarkSweep
 104   static ReferenceProcessor* const reference_processor() {
 105     assert(_ref_processor != NULL, "Sanity");
 106     return _ref_processor;
 107   }
 108   // Used to add tasks
 109   static GCTaskManager* const gc_task_manager();
 110   // The promotion managers tell us if they encountered overflow
 111   static void set_survivor_overflow(bool state) {
 112     _survivor_overflow = state;
 113   }
 114   // Adaptive size policy support.  When the young generation/old generation
 115   // boundary moves, _young_generation_boundary must be reset
 116   static void set_young_generation_boundary(HeapWord* v) {