Thu, 07 Aug 2014 22:28:53 +0200
8054341: Remove some obsolete code in G1CollectedHeap class
Summary: Remove dead code.
Reviewed-by: stefank, brutisso
johnc@5078 | 1 | /* |
johnc@5078 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
johnc@5078 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
johnc@5078 | 4 | * |
johnc@5078 | 5 | * This code is free software; you can redistribute it and/or modify it |
johnc@5078 | 6 | * under the terms of the GNU General Public License version 2 only, as |
johnc@5078 | 7 | * published by the Free Software Foundation. |
johnc@5078 | 8 | * |
johnc@5078 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
johnc@5078 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
johnc@5078 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
johnc@5078 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
johnc@5078 | 13 | * accompanied this code). |
johnc@5078 | 14 | * |
johnc@5078 | 15 | * You should have received a copy of the GNU General Public License version |
johnc@5078 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
johnc@5078 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
johnc@5078 | 18 | * |
johnc@5078 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
johnc@5078 | 20 | * or visit www.oracle.com if you need additional information or have any |
johnc@5078 | 21 | * questions. |
johnc@5078 | 22 | * |
johnc@5078 | 23 | */ |
johnc@5078 | 24 | |
johnc@5078 | 25 | #include "precompiled.hpp" |
johnc@5078 | 26 | #include "gc_implementation/g1/dirtyCardQueue.hpp" |
johnc@5078 | 27 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
johnc@5078 | 28 | #include "gc_implementation/g1/g1HotCardCache.hpp" |
johnc@5078 | 29 | #include "gc_implementation/g1/g1RemSet.hpp" |
johnc@5078 | 30 | #include "gc_implementation/g1/heapRegion.hpp" |
johnc@5078 | 31 | #include "runtime/atomic.hpp" |
johnc@5078 | 32 | |
johnc@5078 | 33 | G1HotCardCache::G1HotCardCache(G1CollectedHeap *g1h): |
johnc@5078 | 34 | _g1h(g1h), _hot_cache(NULL), _use_cache(false), _card_counts(g1h) {} |
johnc@5078 | 35 | |
johnc@5078 | 36 | void G1HotCardCache::initialize() { |
johnc@5078 | 37 | if (default_use_cache()) { |
johnc@5078 | 38 | _use_cache = true; |
johnc@5078 | 39 | |
johnc@5078 | 40 | _hot_cache_size = (1 << G1ConcRSLogCacheSize); |
johnc@5078 | 41 | _hot_cache = NEW_C_HEAP_ARRAY(jbyte*, _hot_cache_size, mtGC); |
johnc@5078 | 42 | |
johnc@5078 | 43 | _n_hot = 0; |
johnc@5078 | 44 | _hot_cache_idx = 0; |
johnc@5078 | 45 | |
johnc@5078 | 46 | // For refining the cards in the hot cache in parallel |
vkempik@6552 | 47 | uint n_workers = (ParallelGCThreads > 0 ? |
johnc@5078 | 48 | _g1h->workers()->total_workers() : 1); |
vkempik@6552 | 49 | _hot_cache_par_chunk_size = MAX2(1, _hot_cache_size / (int)n_workers); |
johnc@5078 | 50 | _hot_cache_par_claimed_idx = 0; |
johnc@5078 | 51 | |
johnc@5078 | 52 | _card_counts.initialize(); |
johnc@5078 | 53 | } |
johnc@5078 | 54 | } |
johnc@5078 | 55 | |
johnc@5078 | 56 | G1HotCardCache::~G1HotCardCache() { |
johnc@5078 | 57 | if (default_use_cache()) { |
johnc@5078 | 58 | assert(_hot_cache != NULL, "Logic"); |
johnc@5078 | 59 | FREE_C_HEAP_ARRAY(jbyte*, _hot_cache, mtGC); |
johnc@5078 | 60 | } |
johnc@5078 | 61 | } |
johnc@5078 | 62 | |
johnc@5078 | 63 | jbyte* G1HotCardCache::insert(jbyte* card_ptr) { |
johnc@5078 | 64 | uint count = _card_counts.add_card_count(card_ptr); |
johnc@5078 | 65 | if (!_card_counts.is_hot(count)) { |
johnc@5078 | 66 | // The card is not hot so do not store it in the cache; |
johnc@5078 | 67 | // return it for immediate refining. |
johnc@5078 | 68 | return card_ptr; |
johnc@5078 | 69 | } |
johnc@5078 | 70 | |
johnc@5078 | 71 | // Otherwise, the card is hot. |
johnc@5078 | 72 | jbyte* res = NULL; |
johnc@5078 | 73 | MutexLockerEx x(HotCardCache_lock, Mutex::_no_safepoint_check_flag); |
johnc@5078 | 74 | if (_n_hot == _hot_cache_size) { |
johnc@5078 | 75 | res = _hot_cache[_hot_cache_idx]; |
johnc@5078 | 76 | _n_hot--; |
johnc@5078 | 77 | } |
johnc@5078 | 78 | |
johnc@5078 | 79 | // Now _n_hot < _hot_cache_size, and we can insert at _hot_cache_idx. |
johnc@5078 | 80 | _hot_cache[_hot_cache_idx] = card_ptr; |
johnc@5078 | 81 | _hot_cache_idx++; |
johnc@5078 | 82 | |
johnc@5078 | 83 | if (_hot_cache_idx == _hot_cache_size) { |
johnc@5078 | 84 | // Wrap around |
johnc@5078 | 85 | _hot_cache_idx = 0; |
johnc@5078 | 86 | } |
johnc@5078 | 87 | _n_hot++; |
johnc@5078 | 88 | |
johnc@5078 | 89 | return res; |
johnc@5078 | 90 | } |
johnc@5078 | 91 | |
vkempik@6552 | 92 | void G1HotCardCache::drain(uint worker_i, |
johnc@5078 | 93 | G1RemSet* g1rs, |
johnc@5078 | 94 | DirtyCardQueue* into_cset_dcq) { |
johnc@5078 | 95 | if (!default_use_cache()) { |
johnc@5078 | 96 | assert(_hot_cache == NULL, "Logic"); |
johnc@5078 | 97 | return; |
johnc@5078 | 98 | } |
johnc@5078 | 99 | |
johnc@5078 | 100 | assert(_hot_cache != NULL, "Logic"); |
johnc@5078 | 101 | assert(!use_cache(), "cache should be disabled"); |
johnc@5078 | 102 | int start_idx; |
johnc@5078 | 103 | |
johnc@5078 | 104 | while ((start_idx = _hot_cache_par_claimed_idx) < _n_hot) { // read once |
johnc@5078 | 105 | int end_idx = start_idx + _hot_cache_par_chunk_size; |
johnc@5078 | 106 | |
johnc@5078 | 107 | if (start_idx == |
johnc@5078 | 108 | Atomic::cmpxchg(end_idx, &_hot_cache_par_claimed_idx, start_idx)) { |
johnc@5078 | 109 | // The current worker has successfully claimed the chunk [start_idx..end_idx) |
johnc@5078 | 110 | end_idx = MIN2(end_idx, _n_hot); |
johnc@5078 | 111 | for (int i = start_idx; i < end_idx; i++) { |
johnc@5078 | 112 | jbyte* card_ptr = _hot_cache[i]; |
johnc@5078 | 113 | if (card_ptr != NULL) { |
johnc@5078 | 114 | if (g1rs->refine_card(card_ptr, worker_i, true)) { |
johnc@5078 | 115 | // The part of the heap spanned by the card contains references |
johnc@5078 | 116 | // that point into the current collection set. |
johnc@5078 | 117 | // We need to record the card pointer in the DirtyCardQueueSet |
johnc@5078 | 118 | // that we use for such cards. |
johnc@5078 | 119 | // |
johnc@5078 | 120 | // The only time we care about recording cards that contain |
johnc@5078 | 121 | // references that point into the collection set is during |
johnc@5078 | 122 | // RSet updating while within an evacuation pause. |
johnc@5078 | 123 | // In this case worker_i should be the id of a GC worker thread |
johnc@5078 | 124 | assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint"); |
vkempik@6552 | 125 | assert(worker_i < (ParallelGCThreads == 0 ? 1 : ParallelGCThreads), |
vkempik@6552 | 126 | err_msg("incorrect worker id: "UINT32_FORMAT, worker_i)); |
johnc@5078 | 127 | |
johnc@5078 | 128 | into_cset_dcq->enqueue(card_ptr); |
johnc@5078 | 129 | } |
johnc@5078 | 130 | } |
johnc@5078 | 131 | } |
johnc@5078 | 132 | } |
johnc@5078 | 133 | } |
johnc@5078 | 134 | // The existing entries in the hot card cache, which were just refined |
johnc@5078 | 135 | // above, are discarded prior to re-enabling the cache near the end of the GC. |
johnc@5078 | 136 | } |
johnc@5078 | 137 | |
johnc@5078 | 138 | void G1HotCardCache::resize_card_counts(size_t heap_capacity) { |
johnc@5078 | 139 | _card_counts.resize(heap_capacity); |
johnc@5078 | 140 | } |
johnc@5078 | 141 | |
johnc@5078 | 142 | void G1HotCardCache::reset_card_counts(HeapRegion* hr) { |
johnc@5078 | 143 | _card_counts.clear_region(hr); |
johnc@5078 | 144 | } |
johnc@5078 | 145 | |
johnc@5078 | 146 | void G1HotCardCache::reset_card_counts() { |
johnc@5078 | 147 | _card_counts.clear_all(); |
johnc@5078 | 148 | } |