src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp

Mon, 19 Aug 2019 10:11:31 +0200

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 7091
a8ea2f110d87
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com

tonyp@2472 1 /*
jwilhelm@6422 2 * Copyright (c) 2011, 2014, 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"));
tschatzl@7050 33 assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked"));
tschatzl@7050 34 assert(hr->prev() == NULL, hrs_ext_msg(this, "should not already be linked"));
tonyp@2472 35
brutisso@6385 36 _count.increment(1u, hr->capacity());
brutisso@6385 37 hr->set_containing_set(this);
brutisso@6385 38 verify_region(hr);
tonyp@2472 39 }
tonyp@2472 40
brutisso@6385 41 inline void HeapRegionSetBase::remove(HeapRegion* hr) {
brutisso@6385 42 check_mt_safety();
brutisso@6385 43 verify_region(hr);
tschatzl@7050 44 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked"));
tschatzl@7050 45 assert(hr->prev() == NULL, hrs_ext_msg(this, "should already be unlinked"));
tonyp@2472 46
tonyp@2472 47 hr->set_containing_set(NULL);
brutisso@6385 48 assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition"));
brutisso@6385 49 _count.decrement(1u, hr->capacity());
tonyp@2472 50 }
tonyp@2472 51
jwilhelm@6422 52 inline void FreeRegionList::add_ordered(HeapRegion* hr) {
tschatzl@7050 53 assert((length() == 0 && _head == NULL && _tail == NULL && _last == NULL) ||
jwilhelm@6422 54 (length() > 0 && _head != NULL && _tail != NULL),
jwilhelm@6422 55 hrs_ext_msg(this, "invariant"));
jwilhelm@6422 56 // add() will verify the region and check mt safety.
jwilhelm@6422 57 add(hr);
jwilhelm@6422 58
jwilhelm@6422 59 // Now link the region
jwilhelm@6422 60 if (_head != NULL) {
jwilhelm@6422 61 HeapRegion* curr;
jwilhelm@6422 62
tschatzl@7091 63 if (_last != NULL && _last->hrm_index() < hr->hrm_index()) {
jwilhelm@6422 64 curr = _last;
jwilhelm@6422 65 } else {
jwilhelm@6422 66 curr = _head;
jwilhelm@6422 67 }
jwilhelm@6422 68
jwilhelm@6422 69 // Find first entry with a Region Index larger than entry to insert.
tschatzl@7091 70 while (curr != NULL && curr->hrm_index() < hr->hrm_index()) {
jwilhelm@6422 71 curr = curr->next();
jwilhelm@6422 72 }
jwilhelm@6422 73
jwilhelm@6422 74 hr->set_next(curr);
jwilhelm@6422 75
jwilhelm@6422 76 if (curr == NULL) {
jwilhelm@6422 77 // Adding at the end
jwilhelm@6422 78 hr->set_prev(_tail);
jwilhelm@6422 79 _tail->set_next(hr);
jwilhelm@6422 80 _tail = hr;
jwilhelm@6422 81 } else if (curr->prev() == NULL) {
jwilhelm@6422 82 // Adding at the beginning
jwilhelm@6422 83 hr->set_prev(NULL);
jwilhelm@6422 84 _head = hr;
jwilhelm@6422 85 curr->set_prev(hr);
jwilhelm@6422 86 } else {
jwilhelm@6422 87 hr->set_prev(curr->prev());
jwilhelm@6422 88 hr->prev()->set_next(hr);
jwilhelm@6422 89 curr->set_prev(hr);
jwilhelm@6422 90 }
jwilhelm@6422 91 } else {
jwilhelm@6422 92 // The list was empty
jwilhelm@6422 93 _tail = hr;
jwilhelm@6422 94 _head = hr;
jwilhelm@6422 95 }
jwilhelm@6422 96 _last = hr;
jwilhelm@6422 97 }
jwilhelm@6422 98
tschatzl@7050 99 inline HeapRegion* FreeRegionList::remove_from_head_impl() {
tschatzl@7050 100 HeapRegion* result = _head;
tschatzl@7050 101 _head = result->next();
tonyp@2472 102 if (_head == NULL) {
tonyp@2472 103 _tail = NULL;
jwilhelm@6422 104 } else {
jwilhelm@6422 105 _head->set_prev(NULL);
tonyp@2472 106 }
tschatzl@7050 107 result->set_next(NULL);
tschatzl@7050 108 return result;
tschatzl@7050 109 }
tschatzl@7050 110
tschatzl@7050 111 inline HeapRegion* FreeRegionList::remove_from_tail_impl() {
tschatzl@7050 112 HeapRegion* result = _tail;
tschatzl@7050 113
tschatzl@7050 114 _tail = result->prev();
tschatzl@7050 115 if (_tail == NULL) {
tschatzl@7050 116 _head = NULL;
tschatzl@7050 117 } else {
tschatzl@7050 118 _tail->set_next(NULL);
tschatzl@7050 119 }
tschatzl@7050 120 result->set_prev(NULL);
tschatzl@7050 121 return result;
tschatzl@7050 122 }
tschatzl@7050 123
tschatzl@7050 124 inline HeapRegion* FreeRegionList::remove_region(bool from_head) {
tschatzl@7050 125 check_mt_safety();
tschatzl@7050 126 verify_optional();
tschatzl@7050 127
tschatzl@7050 128 if (is_empty()) {
tschatzl@7050 129 return NULL;
tschatzl@7050 130 }
tschatzl@7050 131 assert(length() > 0 && _head != NULL && _tail != NULL,
tschatzl@7050 132 hrs_ext_msg(this, "invariant"));
tschatzl@7050 133
tschatzl@7050 134 HeapRegion* hr;
tschatzl@7050 135
tschatzl@7050 136 if (from_head) {
tschatzl@7050 137 hr = remove_from_head_impl();
tschatzl@7050 138 } else {
tschatzl@7050 139 hr = remove_from_tail_impl();
tschatzl@7050 140 }
tonyp@2472 141
jwilhelm@6422 142 if (_last == hr) {
jwilhelm@6422 143 _last = NULL;
jwilhelm@6422 144 }
jwilhelm@6422 145
jwilhelm@6422 146 // remove() will verify the region and check mt safety.
brutisso@6385 147 remove(hr);
tonyp@2472 148 return hr;
tonyp@2472 149 }
tonyp@2472 150
tschatzl@7050 151 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
tonyp@2472 152

mercurial