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

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 5237
f2110083203d
parent 0
f90c822e73f8
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

merge

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

mercurial