1 /*
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1118 dec_committed_words(vsl->committed_words());
1119 dec_virtual_space_count();
1120 purged_vsl = vsl;
1121 delete vsl;
1122 } else {
1123 prev_vsl = vsl;
1124 }
1125 }
1126 #ifdef ASSERT
1127 if (purged_vsl != NULL) {
1128 // List should be stable enough to use an iterator here.
1129 VirtualSpaceListIterator iter(virtual_space_list());
1130 while (iter.repeat()) {
1131 VirtualSpaceNode* vsl = iter.get_next();
1132 assert(vsl != purged_vsl, "Purge of vsl failed");
1133 }
1134 }
1135 #endif
1136 }
1137
1138
1139 // This function looks at the mmap regions in the metaspace without locking.
1140 // The chunks are added with store ordering and not deleted except for at
1141 // unloading time during a safepoint.
1142 bool VirtualSpaceList::contains(const void* ptr) {
1143 // List should be stable enough to use an iterator here because removing virtual
1144 // space nodes is only allowed at a safepoint.
1145 VirtualSpaceListIterator iter(virtual_space_list());
1146 while (iter.repeat()) {
1147 VirtualSpaceNode* vsn = iter.get_next();
1148 if (vsn->contains(ptr)) {
1149 return true;
1150 }
1151 }
1152 return false;
1153 }
1154
1155 void VirtualSpaceList::retire_current_virtual_space() {
1156 assert_lock_strong(SpaceManager::expand_lock());
1157
1158 VirtualSpaceNode* vsn = current_virtual_space();
|
1 /*
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1118 dec_committed_words(vsl->committed_words());
1119 dec_virtual_space_count();
1120 purged_vsl = vsl;
1121 delete vsl;
1122 } else {
1123 prev_vsl = vsl;
1124 }
1125 }
1126 #ifdef ASSERT
1127 if (purged_vsl != NULL) {
1128 // List should be stable enough to use an iterator here.
1129 VirtualSpaceListIterator iter(virtual_space_list());
1130 while (iter.repeat()) {
1131 VirtualSpaceNode* vsl = iter.get_next();
1132 assert(vsl != purged_vsl, "Purge of vsl failed");
1133 }
1134 }
1135 #endif
1136 }
1137
1138 // This function looks at the mmap regions in the metaspace without locking.
1139 // The chunks are added with store ordering and not deleted except for at
1140 // unloading time during a safepoint.
1141 bool VirtualSpaceList::contains(const void* ptr) {
1142 // List should be stable enough to use an iterator here because removing virtual
1143 // space nodes is only allowed at a safepoint.
1144 VirtualSpaceListIterator iter(virtual_space_list());
1145 while (iter.repeat()) {
1146 VirtualSpaceNode* vsn = iter.get_next();
1147 if (vsn->contains(ptr)) {
1148 return true;
1149 }
1150 }
1151 return false;
1152 }
1153
1154 void VirtualSpaceList::retire_current_virtual_space() {
1155 assert_lock_strong(SpaceManager::expand_lock());
1156
1157 VirtualSpaceNode* vsn = current_virtual_space();
|