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

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 5237
f2110083203d
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

duke@435 1 /*
sla@5237 2 * Copyright (c) 2002, 2013, 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"
sla@5237 31 #include "gc_implementation/shared/gcTrace.hpp"
stefank@2314 32 #include "memory/allocation.hpp"
stefank@2314 33 #include "oops/oop.hpp"
stefank@2314 34 #include "utilities/stack.hpp"
stefank@2314 35
duke@435 36 class GCTaskManager;
duke@435 37 class GCTaskQueue;
duke@435 38 class OopStack;
duke@435 39 class ReferenceProcessor;
duke@435 40 class ParallelScavengeHeap;
sla@5237 41 class ParallelScavengeTracer;
duke@435 42 class PSIsAliveClosure;
duke@435 43 class PSRefProcTaskExecutor;
sla@5237 44 class STWGCTimer;
duke@435 45
duke@435 46 class PSScavenge: AllStatic {
duke@435 47 friend class PSIsAliveClosure;
duke@435 48 friend class PSKeepAliveClosure;
duke@435 49 friend class PSPromotionManager;
duke@435 50
duke@435 51 enum ScavengeSkippedCause {
duke@435 52 not_skipped = 0,
duke@435 53 to_space_not_empty,
duke@435 54 promoted_too_large,
duke@435 55 full_follows_scavenge
duke@435 56 };
duke@435 57
duke@435 58 // Saved value of to_space->top(), used to prevent objects in to_space from
duke@435 59 // being rescanned.
duke@435 60 static HeapWord* _to_space_top_before_gc;
duke@435 61
duke@435 62 // Number of consecutive attempts to scavenge that were skipped
duke@435 63 static int _consecutive_skipped_scavenges;
duke@435 64
duke@435 65
duke@435 66 protected:
duke@435 67 // Flags/counters
stefank@5202 68 static ReferenceProcessor* _ref_processor; // Reference processor for scavenging.
stefank@5202 69 static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing
stefank@5202 70 static CardTableExtension* _card_table; // We cache the card table for fast access.
stefank@5202 71 static bool _survivor_overflow; // Overflow this collection
stefank@5202 72 static uint _tenuring_threshold; // tenuring threshold for next scavenge
stefank@5202 73 static elapsedTimer _accumulated_time; // total time spent on scavenge
sla@5237 74 static STWGCTimer _gc_timer; // GC time book keeper
sla@5237 75 static ParallelScavengeTracer _gc_tracer; // GC tracing
stefank@5202 76 // The lowest address possible for the young_gen.
stefank@5202 77 // This is used to decide if an oop should be scavenged,
stefank@5202 78 // cards should be marked, etc.
stefank@5202 79 static HeapWord* _young_generation_boundary;
stefank@5202 80 // Used to optimize compressed oops young gen boundary checking.
stefank@5202 81 static uintptr_t _young_generation_boundary_compressed;
zgu@3900 82 static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
zgu@3900 83 static Stack<oop, mtGC> _preserved_oop_stack; // List of oops that need their mark restored.
stefank@5202 84 static CollectorCounters* _counters; // collector performance counters
duke@435 85
duke@435 86 static void clean_up_failed_promotion();
duke@435 87
duke@435 88 static bool should_attempt_scavenge();
duke@435 89
duke@435 90 static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
duke@435 91 static inline void save_to_space_top_before_gc();
duke@435 92
duke@435 93 // Private accessors
duke@435 94 static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; }
apetushkov@9858 95 static const ParallelScavengeTracer* gc_tracer() { return &_gc_tracer; }
duke@435 96
duke@435 97 public:
duke@435 98 // Accessors
jwilhelm@4129 99 static uint tenuring_threshold() { return _tenuring_threshold; }
duke@435 100 static elapsedTimer* accumulated_time() { return &_accumulated_time; }
duke@435 101 static int consecutive_skipped_scavenges()
duke@435 102 { return _consecutive_skipped_scavenges; }
duke@435 103
duke@435 104 // Performance Counters
duke@435 105 static CollectorCounters* counters() { return _counters; }
duke@435 106
duke@435 107 // Used by scavenge_contents && psMarkSweep
duke@435 108 static ReferenceProcessor* const reference_processor() {
duke@435 109 assert(_ref_processor != NULL, "Sanity");
duke@435 110 return _ref_processor;
duke@435 111 }
duke@435 112 // Used to add tasks
duke@435 113 static GCTaskManager* const gc_task_manager();
duke@435 114 // The promotion managers tell us if they encountered overflow
duke@435 115 static void set_survivor_overflow(bool state) {
duke@435 116 _survivor_overflow = state;
duke@435 117 }
duke@435 118 // Adaptive size policy support. When the young generation/old generation
duke@435 119 // boundary moves, _young_generation_boundary must be reset
duke@435 120 static void set_young_generation_boundary(HeapWord* v) {
duke@435 121 _young_generation_boundary = v;
stefank@5202 122 if (UseCompressedOops) {
stefank@5202 123 _young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);
stefank@5202 124 }
duke@435 125 }
duke@435 126
duke@435 127 // Called by parallelScavengeHeap to init the tenuring threshold
duke@435 128 static void initialize();
duke@435 129
jcoomes@3540 130 // Scavenge entry point. This may invoke a full gc; return true if so.
jcoomes@3540 131 static bool invoke();
jcoomes@3540 132 // Return true if a collection was done; false otherwise.
duke@435 133 static bool invoke_no_policy();
duke@435 134
duke@435 135 // If an attempt to promote fails, this method is invoked
duke@435 136 static void oop_promotion_failed(oop obj, markOop obj_mark);
duke@435 137
coleenp@548 138 template <class T> static inline bool should_scavenge(T* p);
duke@435 139
duke@435 140 // These call should_scavenge() above and, if it returns true, also check that
duke@435 141 // the object was not newly copied into to_space. The version with the bool
duke@435 142 // argument is a convenience wrapper that fetches the to_space pointer from
duke@435 143 // the heap and calls the other version (if the arg is true).
coleenp@548 144 template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
coleenp@548 145 template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
duke@435 146
iveresov@3536 147 template <class T, bool promote_immediately>
iveresov@3536 148 inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);
duke@435 149
coleenp@4037 150 static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p);
coleenp@4037 151
duke@435 152 // Is an object in the young generation
stefank@5202 153 // This assumes that the 'o' is in the heap,
duke@435 154 // so it only checks one side of the complete predicate.
stefank@5202 155
stefank@5202 156 inline static bool is_obj_in_young(oop o) {
stefank@5202 157 return (HeapWord*)o >= _young_generation_boundary;
stefank@5202 158 }
stefank@5202 159
stefank@5202 160 inline static bool is_obj_in_young(narrowOop o) {
stefank@5202 161 return (uintptr_t)o >= _young_generation_boundary_compressed;
stefank@5202 162 }
stefank@5202 163
duke@435 164 inline static bool is_obj_in_young(HeapWord* o) {
stefank@5202 165 return o >= _young_generation_boundary;
duke@435 166 }
duke@435 167 };
stefank@2314 168
stefank@2314 169 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP

mercurial