Thu, 07 Aug 2014 22:28:53 +0200
8054341: Remove some obsolete code in G1CollectedHeap class
Summary: Remove dead code.
Reviewed-by: stefank, brutisso
ysr@777 | 1 | /* |
drchase@6680 | 2 | * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
ysr@777 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ysr@777 | 4 | * |
ysr@777 | 5 | * This code is free software; you can redistribute it and/or modify it |
ysr@777 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ysr@777 | 7 | * published by the Free Software Foundation. |
ysr@777 | 8 | * |
ysr@777 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ysr@777 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ysr@777 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ysr@777 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
ysr@777 | 13 | * accompanied this code). |
ysr@777 | 14 | * |
ysr@777 | 15 | * You should have received a copy of the GNU General Public License version |
ysr@777 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
ysr@777 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ysr@777 | 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. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP |
stefank@2314 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "gc_implementation/g1/concurrentMark.hpp" |
stefank@2314 | 29 | #include "gc_implementation/g1/g1CollectedHeap.hpp" |
tonyp@2715 | 30 | #include "gc_implementation/g1/g1AllocRegion.inline.hpp" |
tonyp@2315 | 31 | #include "gc_implementation/g1/g1CollectorPolicy.hpp" |
mgerdin@5860 | 32 | #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
brutisso@6385 | 33 | #include "gc_implementation/g1/heapRegionSet.inline.hpp" |
tonyp@2469 | 34 | #include "gc_implementation/g1/heapRegionSeq.inline.hpp" |
goetz@6911 | 35 | #include "runtime/orderAccess.inline.hpp" |
stefank@2314 | 36 | #include "utilities/taskqueue.hpp" |
stefank@2314 | 37 | |
ysr@777 | 38 | // Inline functions for G1CollectedHeap |
ysr@777 | 39 | |
tschatzl@6541 | 40 | // Return the region with the given index. It assumes the index is valid. |
tschatzl@6541 | 41 | inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); } |
tschatzl@6541 | 42 | |
tschatzl@7010 | 43 | inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const { |
tschatzl@7010 | 44 | assert(is_in_reserved(addr), |
tschatzl@7010 | 45 | err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")", |
tschatzl@7010 | 46 | p2i(addr), p2i(_reserved.start()), p2i(_reserved.end()))); |
tschatzl@7010 | 47 | return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes); |
tschatzl@7010 | 48 | } |
tschatzl@7010 | 49 | |
tonyp@2963 | 50 | template <class T> |
ysr@777 | 51 | inline HeapRegion* |
tonyp@2963 | 52 | G1CollectedHeap::heap_region_containing(const T addr) const { |
tonyp@2963 | 53 | HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr); |
ysr@777 | 54 | // hr can be null if addr in perm_gen |
ysr@777 | 55 | if (hr != NULL && hr->continuesHumongous()) { |
ysr@777 | 56 | hr = hr->humongous_start_region(); |
ysr@777 | 57 | } |
ysr@777 | 58 | return hr; |
ysr@777 | 59 | } |
ysr@777 | 60 | |
tonyp@2963 | 61 | template <class T> |
ysr@777 | 62 | inline HeapRegion* |
tonyp@2963 | 63 | G1CollectedHeap::heap_region_containing_raw(const T addr) const { |
tonyp@2963 | 64 | assert(_g1_reserved.contains((const void*) addr), "invariant"); |
tonyp@2963 | 65 | HeapRegion* res = _hrs.addr_to_region_unsafe((HeapWord*) addr); |
ysr@777 | 66 | return res; |
ysr@777 | 67 | } |
ysr@777 | 68 | |
goetz@6911 | 69 | inline void G1CollectedHeap::reset_gc_time_stamp() { |
goetz@6911 | 70 | _gc_time_stamp = 0; |
goetz@6911 | 71 | OrderAccess::fence(); |
goetz@6911 | 72 | // Clear the cached CSet starting regions and time stamps. |
goetz@6911 | 73 | // Their validity is dependent on the GC timestamp. |
goetz@6911 | 74 | clear_cset_start_regions(); |
goetz@6911 | 75 | } |
goetz@6911 | 76 | |
goetz@6911 | 77 | inline void G1CollectedHeap::increment_gc_time_stamp() { |
goetz@6911 | 78 | ++_gc_time_stamp; |
goetz@6911 | 79 | OrderAccess::fence(); |
goetz@6911 | 80 | } |
goetz@6911 | 81 | |
tschatzl@6541 | 82 | inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) { |
tschatzl@6541 | 83 | _old_set.remove(hr); |
tschatzl@6541 | 84 | } |
tschatzl@6541 | 85 | |
ysr@777 | 86 | inline bool G1CollectedHeap::obj_in_cs(oop obj) { |
tonyp@2963 | 87 | HeapRegion* r = _hrs.addr_to_region((HeapWord*) obj); |
ysr@777 | 88 | return r != NULL && r->in_collection_set(); |
ysr@777 | 89 | } |
ysr@777 | 90 | |
tonyp@2315 | 91 | inline HeapWord* |
tonyp@2715 | 92 | G1CollectedHeap::attempt_allocation(size_t word_size, |
mgerdin@4853 | 93 | unsigned int* gc_count_before_ret, |
mgerdin@4853 | 94 | int* gclocker_retry_count_ret) { |
tonyp@2715 | 95 | assert_heap_not_locked_and_not_at_safepoint(); |
tonyp@2715 | 96 | assert(!isHumongous(word_size), "attempt_allocation() should not " |
tonyp@2715 | 97 | "be called for humongous allocation requests"); |
ysr@777 | 98 | |
tonyp@2715 | 99 | HeapWord* result = _mutator_alloc_region.attempt_allocation(word_size, |
tonyp@2715 | 100 | false /* bot_updates */); |
tonyp@2715 | 101 | if (result == NULL) { |
mgerdin@4853 | 102 | result = attempt_allocation_slow(word_size, |
mgerdin@4853 | 103 | gc_count_before_ret, |
mgerdin@4853 | 104 | gclocker_retry_count_ret); |
tonyp@2715 | 105 | } |
tonyp@2715 | 106 | assert_heap_not_locked(); |
tonyp@2315 | 107 | if (result != NULL) { |
tonyp@2315 | 108 | dirty_young_block(result, word_size); |
tonyp@2315 | 109 | } |
tonyp@2715 | 110 | return result; |
tonyp@2454 | 111 | } |
tonyp@2454 | 112 | |
tonyp@3028 | 113 | inline HeapWord* G1CollectedHeap::survivor_attempt_allocation(size_t |
tonyp@3028 | 114 | word_size) { |
tonyp@3028 | 115 | assert(!isHumongous(word_size), |
tonyp@3028 | 116 | "we should not be seeing humongous-size allocations in this path"); |
tonyp@3028 | 117 | |
tonyp@3028 | 118 | HeapWord* result = _survivor_gc_alloc_region.attempt_allocation(word_size, |
tonyp@3028 | 119 | false /* bot_updates */); |
tonyp@3028 | 120 | if (result == NULL) { |
tonyp@3028 | 121 | MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag); |
tonyp@3028 | 122 | result = _survivor_gc_alloc_region.attempt_allocation_locked(word_size, |
tonyp@3028 | 123 | false /* bot_updates */); |
tonyp@3028 | 124 | } |
tonyp@3028 | 125 | if (result != NULL) { |
tonyp@3028 | 126 | dirty_young_block(result, word_size); |
tonyp@3028 | 127 | } |
tonyp@3028 | 128 | return result; |
tonyp@3028 | 129 | } |
tonyp@3028 | 130 | |
tonyp@3028 | 131 | inline HeapWord* G1CollectedHeap::old_attempt_allocation(size_t word_size) { |
tonyp@3028 | 132 | assert(!isHumongous(word_size), |
tonyp@3028 | 133 | "we should not be seeing humongous-size allocations in this path"); |
tonyp@3028 | 134 | |
tonyp@3028 | 135 | HeapWord* result = _old_gc_alloc_region.attempt_allocation(word_size, |
tonyp@3028 | 136 | true /* bot_updates */); |
tonyp@3028 | 137 | if (result == NULL) { |
tonyp@3028 | 138 | MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag); |
tonyp@3028 | 139 | result = _old_gc_alloc_region.attempt_allocation_locked(word_size, |
tonyp@3028 | 140 | true /* bot_updates */); |
tonyp@3028 | 141 | } |
tonyp@3028 | 142 | return result; |
tonyp@3028 | 143 | } |
tonyp@3028 | 144 | |
tonyp@2315 | 145 | // It dirties the cards that cover the block so that so that the post |
tonyp@2315 | 146 | // write barrier never queues anything when updating objects on this |
tonyp@2315 | 147 | // block. It is assumed (and in fact we assert) that the block |
tonyp@2315 | 148 | // belongs to a young region. |
tonyp@2315 | 149 | inline void |
tonyp@2315 | 150 | G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) { |
tonyp@2315 | 151 | assert_heap_not_locked(); |
tonyp@2315 | 152 | |
tonyp@2315 | 153 | // Assign the containing region to containing_hr so that we don't |
tonyp@2315 | 154 | // have to keep calling heap_region_containing_raw() in the |
tonyp@2315 | 155 | // asserts below. |
tonyp@2315 | 156 | DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);) |
tonyp@2315 | 157 | assert(containing_hr != NULL && start != NULL && word_size > 0, |
tonyp@2315 | 158 | "pre-condition"); |
tonyp@2315 | 159 | assert(containing_hr->is_in(start), "it should contain start"); |
tonyp@2315 | 160 | assert(containing_hr->is_young(), "it should be young"); |
tonyp@2315 | 161 | assert(!containing_hr->isHumongous(), "it should not be humongous"); |
tonyp@2315 | 162 | |
tonyp@2315 | 163 | HeapWord* end = start + word_size; |
tonyp@2315 | 164 | assert(containing_hr->is_in(end - 1), "it should also contain end - 1"); |
tonyp@2315 | 165 | |
tonyp@2315 | 166 | MemRegion mr(start, end); |
mgerdin@5860 | 167 | g1_barrier_set()->g1_mark_as_young(mr); |
ysr@777 | 168 | } |
ysr@777 | 169 | |
jcoomes@2064 | 170 | inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const { |
ysr@777 | 171 | return _task_queues->queue(i); |
ysr@777 | 172 | } |
ysr@777 | 173 | |
johnc@4016 | 174 | inline bool G1CollectedHeap::isMarkedPrev(oop obj) const { |
ysr@777 | 175 | return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj); |
ysr@777 | 176 | } |
ysr@777 | 177 | |
ysr@777 | 178 | inline bool G1CollectedHeap::isMarkedNext(oop obj) const { |
ysr@777 | 179 | return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj); |
ysr@777 | 180 | } |
stefank@2314 | 181 | |
tschatzl@6541 | 182 | // This is a fast test on whether a reference points into the |
tschatzl@6541 | 183 | // collection set or not. Assume that the reference |
tschatzl@6541 | 184 | // points into the heap. |
tschatzl@7010 | 185 | inline bool G1CollectedHeap::is_in_cset(oop obj) { |
tschatzl@7010 | 186 | bool ret = _in_cset_fast_test.is_in_cset((HeapWord*)obj); |
tschatzl@6541 | 187 | // let's make sure the result is consistent with what the slower |
tschatzl@6541 | 188 | // test returns |
tschatzl@6541 | 189 | assert( ret || !obj_in_cs(obj), "sanity"); |
tschatzl@6541 | 190 | assert(!ret || obj_in_cs(obj), "sanity"); |
tschatzl@6541 | 191 | return ret; |
tschatzl@6541 | 192 | } |
tschatzl@6541 | 193 | |
tschatzl@7010 | 194 | bool G1CollectedHeap::is_in_cset_or_humongous(const oop obj) { |
tschatzl@7010 | 195 | return _in_cset_fast_test.is_in_cset_or_humongous((HeapWord*)obj); |
tschatzl@7010 | 196 | } |
tschatzl@7010 | 197 | |
tschatzl@7010 | 198 | G1CollectedHeap::in_cset_state_t G1CollectedHeap::in_cset_state(const oop obj) { |
tschatzl@7010 | 199 | return _in_cset_fast_test.at((HeapWord*)obj); |
tschatzl@7010 | 200 | } |
tschatzl@7010 | 201 | |
tschatzl@7010 | 202 | void G1CollectedHeap::register_humongous_region_with_in_cset_fast_test(uint index) { |
tschatzl@7010 | 203 | _in_cset_fast_test.set_humongous(index); |
tschatzl@7010 | 204 | } |
tschatzl@7010 | 205 | |
johnc@4016 | 206 | #ifndef PRODUCT |
johnc@4016 | 207 | // Support for G1EvacuationFailureALot |
johnc@4016 | 208 | |
johnc@4016 | 209 | inline bool |
johnc@4016 | 210 | G1CollectedHeap::evacuation_failure_alot_for_gc_type(bool gcs_are_young, |
johnc@4016 | 211 | bool during_initial_mark, |
johnc@4016 | 212 | bool during_marking) { |
johnc@4016 | 213 | bool res = false; |
johnc@4016 | 214 | if (during_marking) { |
johnc@4016 | 215 | res |= G1EvacuationFailureALotDuringConcMark; |
johnc@4016 | 216 | } |
johnc@4016 | 217 | if (during_initial_mark) { |
johnc@4016 | 218 | res |= G1EvacuationFailureALotDuringInitialMark; |
johnc@4016 | 219 | } |
johnc@4016 | 220 | if (gcs_are_young) { |
johnc@4016 | 221 | res |= G1EvacuationFailureALotDuringYoungGC; |
johnc@4016 | 222 | } else { |
johnc@4016 | 223 | // GCs are mixed |
johnc@4016 | 224 | res |= G1EvacuationFailureALotDuringMixedGC; |
johnc@4016 | 225 | } |
johnc@4016 | 226 | return res; |
johnc@4016 | 227 | } |
johnc@4016 | 228 | |
johnc@4016 | 229 | inline void |
johnc@4016 | 230 | G1CollectedHeap::set_evacuation_failure_alot_for_current_gc() { |
johnc@4016 | 231 | if (G1EvacuationFailureALot) { |
johnc@4016 | 232 | // Note we can't assert that _evacuation_failure_alot_for_current_gc |
johnc@4016 | 233 | // is clear here. It may have been set during a previous GC but that GC |
johnc@4016 | 234 | // did not copy enough objects (i.e. G1EvacuationFailureALotCount) to |
johnc@4016 | 235 | // trigger an evacuation failure and clear the flags and and counts. |
johnc@4016 | 236 | |
johnc@4016 | 237 | // Check if we have gone over the interval. |
johnc@4016 | 238 | const size_t gc_num = total_collections(); |
johnc@4016 | 239 | const size_t elapsed_gcs = gc_num - _evacuation_failure_alot_gc_number; |
johnc@4016 | 240 | |
johnc@4016 | 241 | _evacuation_failure_alot_for_current_gc = (elapsed_gcs >= G1EvacuationFailureALotInterval); |
johnc@4016 | 242 | |
johnc@4016 | 243 | // Now check if G1EvacuationFailureALot is enabled for the current GC type. |
johnc@4016 | 244 | const bool gcs_are_young = g1_policy()->gcs_are_young(); |
johnc@4016 | 245 | const bool during_im = g1_policy()->during_initial_mark_pause(); |
johnc@4016 | 246 | const bool during_marking = mark_in_progress(); |
johnc@4016 | 247 | |
johnc@4016 | 248 | _evacuation_failure_alot_for_current_gc &= |
johnc@4016 | 249 | evacuation_failure_alot_for_gc_type(gcs_are_young, |
johnc@4016 | 250 | during_im, |
johnc@4016 | 251 | during_marking); |
johnc@4016 | 252 | } |
johnc@4016 | 253 | } |
johnc@4016 | 254 | |
johnc@4016 | 255 | inline bool |
johnc@4016 | 256 | G1CollectedHeap::evacuation_should_fail() { |
johnc@4016 | 257 | if (!G1EvacuationFailureALot || !_evacuation_failure_alot_for_current_gc) { |
johnc@4016 | 258 | return false; |
johnc@4016 | 259 | } |
johnc@4016 | 260 | // G1EvacuationFailureALot is in effect for current GC |
johnc@4016 | 261 | // Access to _evacuation_failure_alot_count is not atomic; |
johnc@4016 | 262 | // the value does not have to be exact. |
johnc@4016 | 263 | if (++_evacuation_failure_alot_count < G1EvacuationFailureALotCount) { |
johnc@4016 | 264 | return false; |
johnc@4016 | 265 | } |
johnc@4016 | 266 | _evacuation_failure_alot_count = 0; |
johnc@4016 | 267 | return true; |
johnc@4016 | 268 | } |
johnc@4016 | 269 | |
johnc@4016 | 270 | inline void G1CollectedHeap::reset_evacuation_should_fail() { |
johnc@4016 | 271 | if (G1EvacuationFailureALot) { |
johnc@4016 | 272 | _evacuation_failure_alot_gc_number = total_collections(); |
johnc@4016 | 273 | _evacuation_failure_alot_count = 0; |
johnc@4016 | 274 | _evacuation_failure_alot_for_current_gc = false; |
johnc@4016 | 275 | } |
johnc@4016 | 276 | } |
johnc@4016 | 277 | #endif // #ifndef PRODUCT |
johnc@4016 | 278 | |
tschatzl@6541 | 279 | inline bool G1CollectedHeap::is_in_young(const oop obj) { |
tschatzl@6541 | 280 | HeapRegion* hr = heap_region_containing(obj); |
tschatzl@6541 | 281 | return hr != NULL && hr->is_young(); |
tschatzl@6541 | 282 | } |
tschatzl@6541 | 283 | |
tschatzl@6541 | 284 | // We don't need barriers for initializing stores to objects |
tschatzl@6541 | 285 | // in the young gen: for the SATB pre-barrier, there is no |
tschatzl@6541 | 286 | // pre-value that needs to be remembered; for the remembered-set |
tschatzl@6541 | 287 | // update logging post-barrier, we don't maintain remembered set |
tschatzl@6541 | 288 | // information for young gen objects. |
tschatzl@6541 | 289 | inline bool G1CollectedHeap::can_elide_initializing_store_barrier(oop new_obj) { |
tschatzl@6541 | 290 | return is_in_young(new_obj); |
tschatzl@6541 | 291 | } |
tschatzl@6541 | 292 | |
tschatzl@6541 | 293 | inline bool G1CollectedHeap::is_obj_dead(const oop obj) const { |
tschatzl@6541 | 294 | const HeapRegion* hr = heap_region_containing(obj); |
tschatzl@6541 | 295 | if (hr == NULL) { |
tschatzl@6541 | 296 | if (obj == NULL) return false; |
tschatzl@6541 | 297 | else return true; |
tschatzl@6541 | 298 | } |
tschatzl@6541 | 299 | else return is_obj_dead(obj, hr); |
tschatzl@6541 | 300 | } |
tschatzl@6541 | 301 | |
tschatzl@6541 | 302 | inline bool G1CollectedHeap::is_obj_ill(const oop obj) const { |
tschatzl@6541 | 303 | const HeapRegion* hr = heap_region_containing(obj); |
tschatzl@6541 | 304 | if (hr == NULL) { |
tschatzl@6541 | 305 | if (obj == NULL) return false; |
tschatzl@6541 | 306 | else return true; |
tschatzl@6541 | 307 | } |
tschatzl@6541 | 308 | else return is_obj_ill(obj, hr); |
tschatzl@6541 | 309 | } |
tschatzl@6541 | 310 | |
tschatzl@7010 | 311 | inline void G1CollectedHeap::set_humongous_is_live(oop obj) { |
tschatzl@7010 | 312 | uint region = addr_to_region((HeapWord*)obj); |
tschatzl@7010 | 313 | // We not only set the "live" flag in the humongous_is_live table, but also |
tschatzl@7010 | 314 | // reset the entry in the _in_cset_fast_test table so that subsequent references |
tschatzl@7010 | 315 | // to the same humongous object do not go into the slow path again. |
tschatzl@7010 | 316 | // This is racy, as multiple threads may at the same time enter here, but this |
tschatzl@7010 | 317 | // is benign. |
tschatzl@7010 | 318 | // During collection we only ever set the "live" flag, and only ever clear the |
tschatzl@7010 | 319 | // entry in the in_cset_fast_table. |
tschatzl@7010 | 320 | // We only ever evaluate the contents of these tables (in the VM thread) after |
tschatzl@7010 | 321 | // having synchronized the worker threads with the VM thread, or in the same |
tschatzl@7010 | 322 | // thread (i.e. within the VM thread). |
tschatzl@7010 | 323 | if (!_humongous_is_live.is_live(region)) { |
tschatzl@7010 | 324 | _humongous_is_live.set_live(region); |
tschatzl@7010 | 325 | _in_cset_fast_test.clear_humongous(region); |
tschatzl@7010 | 326 | } |
tschatzl@7010 | 327 | } |
tschatzl@7010 | 328 | |
stefank@2314 | 329 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP |