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

Fri, 17 May 2013 11:57:05 +0200

author
ehelin
date
Fri, 17 May 2013 11:57:05 +0200
changeset 5159
001ec9515f84
parent 4129
22b8d3d181d9
child 5202
47bdfb3d010f
permissions
-rw-r--r--

8014277: Remove ObjectClosure as base class for BoolObjectClosure
Reviewed-by: brutisso, tschatzl

duke@435 1 /*
iveresov@3536 2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
stefank@2314 29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
stefank@2314 30 #include "gc_implementation/shared/collectorCounters.hpp"
stefank@2314 31 #include "memory/allocation.hpp"
stefank@2314 32 #include "oops/oop.hpp"
stefank@2314 33 #include "utilities/stack.hpp"
stefank@2314 34
duke@435 35 class GCTaskManager;
duke@435 36 class GCTaskQueue;
duke@435 37 class OopStack;
duke@435 38 class ReferenceProcessor;
duke@435 39 class ParallelScavengeHeap;
duke@435 40 class PSIsAliveClosure;
duke@435 41 class PSRefProcTaskExecutor;
duke@435 42
duke@435 43 class PSScavenge: AllStatic {
duke@435 44 friend class PSIsAliveClosure;
duke@435 45 friend class PSKeepAliveClosure;
duke@435 46 friend class PSPromotionManager;
duke@435 47
duke@435 48 enum ScavengeSkippedCause {
duke@435 49 not_skipped = 0,
duke@435 50 to_space_not_empty,
duke@435 51 promoted_too_large,
duke@435 52 full_follows_scavenge
duke@435 53 };
duke@435 54
duke@435 55 // Saved value of to_space->top(), used to prevent objects in to_space from
duke@435 56 // being rescanned.
duke@435 57 static HeapWord* _to_space_top_before_gc;
duke@435 58
duke@435 59 // Number of consecutive attempts to scavenge that were skipped
duke@435 60 static int _consecutive_skipped_scavenges;
duke@435 61
duke@435 62
duke@435 63 protected:
duke@435 64 // Flags/counters
duke@435 65 static ReferenceProcessor* _ref_processor; // Reference processor for scavenging.
duke@435 66 static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing
duke@435 67 static CardTableExtension* _card_table; // We cache the card table for fast access.
duke@435 68 static bool _survivor_overflow; // Overflow this collection
jwilhelm@4129 69 static uint _tenuring_threshold; // tenuring threshold for next scavenge
duke@435 70 static elapsedTimer _accumulated_time; // total time spent on scavenge
duke@435 71 static HeapWord* _young_generation_boundary; // The lowest address possible for the young_gen.
duke@435 72 // This is used to decide if an oop should be scavenged,
duke@435 73 // cards should be marked, etc.
zgu@3900 74 static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
zgu@3900 75 static Stack<oop, mtGC> _preserved_oop_stack; // List of oops that need their mark restored.
jwilhelm@4129 76 static CollectorCounters* _counters; // collector performance counters
jcoomes@2191 77 static bool _promotion_failed;
duke@435 78
duke@435 79 static void clean_up_failed_promotion();
duke@435 80
duke@435 81 static bool should_attempt_scavenge();
duke@435 82
duke@435 83 static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
duke@435 84 static inline void save_to_space_top_before_gc();
duke@435 85
duke@435 86 // Private accessors
duke@435 87 static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; }
duke@435 88
duke@435 89 public:
duke@435 90 // Accessors
jwilhelm@4129 91 static uint tenuring_threshold() { return _tenuring_threshold; }
duke@435 92 static elapsedTimer* accumulated_time() { return &_accumulated_time; }
jcoomes@2191 93 static bool promotion_failed() { return _promotion_failed; }
duke@435 94 static int consecutive_skipped_scavenges()
duke@435 95 { return _consecutive_skipped_scavenges; }
duke@435 96
duke@435 97 // Performance Counters
duke@435 98 static CollectorCounters* counters() { return _counters; }
duke@435 99
duke@435 100 // Used by scavenge_contents && psMarkSweep
duke@435 101 static ReferenceProcessor* const reference_processor() {
duke@435 102 assert(_ref_processor != NULL, "Sanity");
duke@435 103 return _ref_processor;
duke@435 104 }
duke@435 105 // Used to add tasks
duke@435 106 static GCTaskManager* const gc_task_manager();
duke@435 107 // The promotion managers tell us if they encountered overflow
duke@435 108 static void set_survivor_overflow(bool state) {
duke@435 109 _survivor_overflow = state;
duke@435 110 }
duke@435 111 // Adaptive size policy support. When the young generation/old generation
duke@435 112 // boundary moves, _young_generation_boundary must be reset
duke@435 113 static void set_young_generation_boundary(HeapWord* v) {
duke@435 114 _young_generation_boundary = v;
duke@435 115 }
duke@435 116
duke@435 117 // Called by parallelScavengeHeap to init the tenuring threshold
duke@435 118 static void initialize();
duke@435 119
jcoomes@3540 120 // Scavenge entry point. This may invoke a full gc; return true if so.
jcoomes@3540 121 static bool invoke();
jcoomes@3540 122 // Return true if a collection was done; false otherwise.
duke@435 123 static bool invoke_no_policy();
duke@435 124
duke@435 125 // If an attempt to promote fails, this method is invoked
duke@435 126 static void oop_promotion_failed(oop obj, markOop obj_mark);
duke@435 127
coleenp@548 128 template <class T> static inline bool should_scavenge(T* p);
duke@435 129
duke@435 130 // These call should_scavenge() above and, if it returns true, also check that
duke@435 131 // the object was not newly copied into to_space. The version with the bool
duke@435 132 // argument is a convenience wrapper that fetches the to_space pointer from
duke@435 133 // the heap and calls the other version (if the arg is true).
coleenp@548 134 template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
coleenp@548 135 template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
duke@435 136
iveresov@3536 137 template <class T, bool promote_immediately>
iveresov@3536 138 inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);
duke@435 139
coleenp@4037 140 static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p);
coleenp@4037 141
duke@435 142 // Is an object in the young generation
duke@435 143 // This assumes that the HeapWord argument is in the heap,
duke@435 144 // so it only checks one side of the complete predicate.
duke@435 145 inline static bool is_obj_in_young(HeapWord* o) {
duke@435 146 const bool result = (o >= _young_generation_boundary);
duke@435 147 return result;
duke@435 148 }
duke@435 149 };
stefank@2314 150
stefank@2314 151 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP

mercurial