Mon, 24 Mar 2014 15:30:14 +0100
8035406: Improve data structure for Code Cache remembered sets
Summary: Change the code cache remembered sets data structure from a GrowableArray to a chunked list of nmethods. This makes the data structure more amenable to parallelization, and decreases freeing time.
Reviewed-by: mgerdin, brutisso
tonyp@2472 | 1 | /* |
tonyp@3713 | 2 | * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
tonyp@2472 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
tonyp@2472 | 4 | * |
tonyp@2472 | 5 | * This code is free software; you can redistribute it and/or modify it |
tonyp@2472 | 6 | * under the terms of the GNU General Public License version 2 only, as |
tonyp@2472 | 7 | * published by the Free Software Foundation. |
tonyp@2472 | 8 | * |
tonyp@2472 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
tonyp@2472 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
tonyp@2472 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
tonyp@2472 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
tonyp@2472 | 13 | * accompanied this code). |
tonyp@2472 | 14 | * |
tonyp@2472 | 15 | * You should have received a copy of the GNU General Public License version |
tonyp@2472 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
tonyp@2472 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
tonyp@2472 | 18 | * |
tonyp@2472 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
tonyp@2472 | 20 | * or visit www.oracle.com if you need additional information or have any |
tonyp@2472 | 21 | * questions. |
tonyp@2472 | 22 | * |
tonyp@2472 | 23 | */ |
tonyp@2472 | 24 | |
tonyp@2472 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP |
tonyp@2472 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP |
tonyp@2472 | 27 | |
tonyp@2472 | 28 | #include "gc_implementation/g1/heapRegionSet.hpp" |
tonyp@2472 | 29 | |
brutisso@6385 | 30 | inline void HeapRegionSetBase::add(HeapRegion* hr) { |
brutisso@6385 | 31 | check_mt_safety(); |
brutisso@6385 | 32 | assert(hr->containing_set() == NULL, hrs_ext_msg(this, "should not already have a containing set %u")); |
brutisso@6385 | 33 | assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked")); |
tonyp@2472 | 34 | |
brutisso@6385 | 35 | _count.increment(1u, hr->capacity()); |
brutisso@6385 | 36 | hr->set_containing_set(this); |
brutisso@6385 | 37 | verify_region(hr); |
tonyp@2472 | 38 | } |
tonyp@2472 | 39 | |
brutisso@6385 | 40 | inline void HeapRegionSetBase::remove(HeapRegion* hr) { |
brutisso@6385 | 41 | check_mt_safety(); |
brutisso@6385 | 42 | verify_region(hr); |
tonyp@2643 | 43 | assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked")); |
tonyp@2472 | 44 | |
tonyp@2472 | 45 | hr->set_containing_set(NULL); |
brutisso@6385 | 46 | assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition")); |
brutisso@6385 | 47 | _count.decrement(1u, hr->capacity()); |
tonyp@2472 | 48 | } |
tonyp@2472 | 49 | |
brutisso@6385 | 50 | inline void FreeRegionList::add_as_head(HeapRegion* hr) { |
tonyp@2714 | 51 | assert((length() == 0 && _head == NULL && _tail == NULL) || |
tonyp@2714 | 52 | (length() > 0 && _head != NULL && _tail != NULL), |
tonyp@2714 | 53 | hrs_ext_msg(this, "invariant")); |
brutisso@6385 | 54 | // add() will verify the region and check mt safety. |
brutisso@6385 | 55 | add(hr); |
tonyp@2714 | 56 | |
tonyp@2714 | 57 | // Now link the region. |
tonyp@2714 | 58 | if (_head != NULL) { |
tonyp@2714 | 59 | hr->set_next(_head); |
tonyp@2714 | 60 | } else { |
tonyp@2714 | 61 | _tail = hr; |
tonyp@2714 | 62 | } |
tonyp@2714 | 63 | _head = hr; |
tonyp@2714 | 64 | } |
tonyp@2714 | 65 | |
brutisso@6385 | 66 | inline void FreeRegionList::add_as_tail(HeapRegion* hr) { |
brutisso@6385 | 67 | check_mt_safety(); |
tonyp@2472 | 68 | assert((length() == 0 && _head == NULL && _tail == NULL) || |
tonyp@2472 | 69 | (length() > 0 && _head != NULL && _tail != NULL), |
tonyp@2643 | 70 | hrs_ext_msg(this, "invariant")); |
brutisso@6385 | 71 | // add() will verify the region and check mt safety |
brutisso@6385 | 72 | add(hr); |
tonyp@2472 | 73 | |
tonyp@2472 | 74 | // Now link the region. |
tonyp@2472 | 75 | if (_tail != NULL) { |
tonyp@2472 | 76 | _tail->set_next(hr); |
tonyp@2472 | 77 | } else { |
tonyp@2472 | 78 | _head = hr; |
tonyp@2472 | 79 | } |
tonyp@2472 | 80 | _tail = hr; |
tonyp@2472 | 81 | } |
tonyp@2472 | 82 | |
brutisso@6385 | 83 | inline HeapRegion* FreeRegionList::remove_head() { |
tonyp@2643 | 84 | assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty")); |
tonyp@2472 | 85 | assert(length() > 0 && _head != NULL && _tail != NULL, |
tonyp@2643 | 86 | hrs_ext_msg(this, "invariant")); |
tonyp@2472 | 87 | |
tonyp@2472 | 88 | // We need to unlink it first. |
tonyp@2472 | 89 | HeapRegion* hr = _head; |
tonyp@2472 | 90 | _head = hr->next(); |
tonyp@2472 | 91 | if (_head == NULL) { |
tonyp@2472 | 92 | _tail = NULL; |
tonyp@2472 | 93 | } |
tonyp@2472 | 94 | hr->set_next(NULL); |
tonyp@2472 | 95 | |
brutisso@6385 | 96 | // remove() will verify the region and check mt safety |
brutisso@6385 | 97 | remove(hr); |
tonyp@2472 | 98 | return hr; |
tonyp@2472 | 99 | } |
tonyp@2472 | 100 | |
brutisso@6385 | 101 | inline HeapRegion* FreeRegionList::remove_head_or_null() { |
brutisso@6385 | 102 | check_mt_safety(); |
tonyp@2472 | 103 | if (!is_empty()) { |
tonyp@2472 | 104 | return remove_head(); |
tonyp@2472 | 105 | } else { |
tonyp@2472 | 106 | return NULL; |
tonyp@2472 | 107 | } |
tonyp@2472 | 108 | } |
tonyp@2472 | 109 | |
tonyp@2472 | 110 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP |