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

Thu, 30 May 2013 10:58:16 +0200

author
stefank
date
Thu, 30 May 2013 10:58:16 +0200
changeset 5202
47bdfb3d010f
parent 4129
22b8d3d181d9
child 5237
f2110083203d
permissions
-rw-r--r--

8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
Summary: Compare compressed oops to a compressed young gen boundary instead of uncompressing the oops before doing the young gen boundary check.
Reviewed-by: brutisso, jmasa

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
stefank@5202 65 static ReferenceProcessor* _ref_processor; // Reference processor for scavenging.
stefank@5202 66 static PSIsAliveClosure _is_alive_closure; // Closure used for reference processing
stefank@5202 67 static CardTableExtension* _card_table; // We cache the card table for fast access.
stefank@5202 68 static bool _survivor_overflow; // Overflow this collection
stefank@5202 69 static uint _tenuring_threshold; // tenuring threshold for next scavenge
stefank@5202 70 static elapsedTimer _accumulated_time; // total time spent on scavenge
stefank@5202 71 // The lowest address possible for the young_gen.
stefank@5202 72 // This is used to decide if an oop should be scavenged,
stefank@5202 73 // cards should be marked, etc.
stefank@5202 74 static HeapWord* _young_generation_boundary;
stefank@5202 75 // Used to optimize compressed oops young gen boundary checking.
stefank@5202 76 static uintptr_t _young_generation_boundary_compressed;
zgu@3900 77 static Stack<markOop, mtGC> _preserved_mark_stack; // List of marks to be restored after failed promotion
zgu@3900 78 static Stack<oop, mtGC> _preserved_oop_stack; // List of oops that need their mark restored.
stefank@5202 79 static CollectorCounters* _counters; // collector performance counters
stefank@5202 80 static bool _promotion_failed;
duke@435 81
duke@435 82 static void clean_up_failed_promotion();
duke@435 83
duke@435 84 static bool should_attempt_scavenge();
duke@435 85
duke@435 86 static HeapWord* to_space_top_before_gc() { return _to_space_top_before_gc; }
duke@435 87 static inline void save_to_space_top_before_gc();
duke@435 88
duke@435 89 // Private accessors
duke@435 90 static CardTableExtension* const card_table() { assert(_card_table != NULL, "Sanity"); return _card_table; }
duke@435 91
duke@435 92 public:
duke@435 93 // Accessors
jwilhelm@4129 94 static uint tenuring_threshold() { return _tenuring_threshold; }
duke@435 95 static elapsedTimer* accumulated_time() { return &_accumulated_time; }
jcoomes@2191 96 static bool promotion_failed() { return _promotion_failed; }
duke@435 97 static int consecutive_skipped_scavenges()
duke@435 98 { return _consecutive_skipped_scavenges; }
duke@435 99
duke@435 100 // Performance Counters
duke@435 101 static CollectorCounters* counters() { return _counters; }
duke@435 102
duke@435 103 // Used by scavenge_contents && psMarkSweep
duke@435 104 static ReferenceProcessor* const reference_processor() {
duke@435 105 assert(_ref_processor != NULL, "Sanity");
duke@435 106 return _ref_processor;
duke@435 107 }
duke@435 108 // Used to add tasks
duke@435 109 static GCTaskManager* const gc_task_manager();
duke@435 110 // The promotion managers tell us if they encountered overflow
duke@435 111 static void set_survivor_overflow(bool state) {
duke@435 112 _survivor_overflow = state;
duke@435 113 }
duke@435 114 // Adaptive size policy support. When the young generation/old generation
duke@435 115 // boundary moves, _young_generation_boundary must be reset
duke@435 116 static void set_young_generation_boundary(HeapWord* v) {
duke@435 117 _young_generation_boundary = v;
stefank@5202 118 if (UseCompressedOops) {
stefank@5202 119 _young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);
stefank@5202 120 }
duke@435 121 }
duke@435 122
duke@435 123 // Called by parallelScavengeHeap to init the tenuring threshold
duke@435 124 static void initialize();
duke@435 125
jcoomes@3540 126 // Scavenge entry point. This may invoke a full gc; return true if so.
jcoomes@3540 127 static bool invoke();
jcoomes@3540 128 // Return true if a collection was done; false otherwise.
duke@435 129 static bool invoke_no_policy();
duke@435 130
duke@435 131 // If an attempt to promote fails, this method is invoked
duke@435 132 static void oop_promotion_failed(oop obj, markOop obj_mark);
duke@435 133
coleenp@548 134 template <class T> static inline bool should_scavenge(T* p);
duke@435 135
duke@435 136 // These call should_scavenge() above and, if it returns true, also check that
duke@435 137 // the object was not newly copied into to_space. The version with the bool
duke@435 138 // argument is a convenience wrapper that fetches the to_space pointer from
duke@435 139 // the heap and calls the other version (if the arg is true).
coleenp@548 140 template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
coleenp@548 141 template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
duke@435 142
iveresov@3536 143 template <class T, bool promote_immediately>
iveresov@3536 144 inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p);
duke@435 145
coleenp@4037 146 static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p);
coleenp@4037 147
duke@435 148 // Is an object in the young generation
stefank@5202 149 // This assumes that the 'o' is in the heap,
duke@435 150 // so it only checks one side of the complete predicate.
stefank@5202 151
stefank@5202 152 inline static bool is_obj_in_young(oop o) {
stefank@5202 153 return (HeapWord*)o >= _young_generation_boundary;
stefank@5202 154 }
stefank@5202 155
stefank@5202 156 inline static bool is_obj_in_young(narrowOop o) {
stefank@5202 157 return (uintptr_t)o >= _young_generation_boundary_compressed;
stefank@5202 158 }
stefank@5202 159
duke@435 160 inline static bool is_obj_in_young(HeapWord* o) {
stefank@5202 161 return o >= _young_generation_boundary;
duke@435 162 }
duke@435 163 };
stefank@2314 164
stefank@2314 165 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_HPP

mercurial