1 /*
2 * Copyright (c) 2001, 2013, 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 *
171 // Represents a marking stack used by the CMS collector.
172 // Ideally this should be GrowableArray<> just like MSC's marking stack(s).
173 class CMSMarkStack: public CHeapObj<mtGC> {
174 //
175 friend class CMSCollector; // To get at expansion stats further below.
176 //
177
178 VirtualSpace _virtual_space; // Space for the stack
179 oop* _base; // Bottom of stack
180 size_t _index; // One more than last occupied index
181 size_t _capacity; // Max #elements
182 Mutex _par_lock; // An advisory lock used in case of parallel access
183 NOT_PRODUCT(size_t _max_depth;) // Max depth plumbed during run
184
185 protected:
186 size_t _hit_limit; // We hit max stack size limit
187 size_t _failed_double; // We failed expansion before hitting limit
188
189 public:
190 CMSMarkStack():
191 _par_lock(Mutex::event, "CMSMarkStack._par_lock", true),
192 _hit_limit(0),
193 _failed_double(0) {}
194
195 bool allocate(size_t size);
196
197 size_t capacity() const { return _capacity; }
198
199 oop pop() {
200 if (!isEmpty()) {
201 return _base[--_index] ;
202 }
203 return NULL;
204 }
205
206 bool push(oop ptr) {
207 if (isFull()) {
208 return false;
209 } else {
210 _base[_index++] = ptr;
211 NOT_PRODUCT(_max_depth = MAX2(_max_depth, _index));
|
1 /*
2 * Copyright (c) 2001, 2014, 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 *
171 // Represents a marking stack used by the CMS collector.
172 // Ideally this should be GrowableArray<> just like MSC's marking stack(s).
173 class CMSMarkStack: public CHeapObj<mtGC> {
174 //
175 friend class CMSCollector; // To get at expansion stats further below.
176 //
177
178 VirtualSpace _virtual_space; // Space for the stack
179 oop* _base; // Bottom of stack
180 size_t _index; // One more than last occupied index
181 size_t _capacity; // Max #elements
182 Mutex _par_lock; // An advisory lock used in case of parallel access
183 NOT_PRODUCT(size_t _max_depth;) // Max depth plumbed during run
184
185 protected:
186 size_t _hit_limit; // We hit max stack size limit
187 size_t _failed_double; // We failed expansion before hitting limit
188
189 public:
190 CMSMarkStack():
191 _par_lock(Mutex::event, "CMSMarkStack._par_lock", true,
192 Monitor::_safepoint_check_never),
193 _hit_limit(0),
194 _failed_double(0) {}
195
196 bool allocate(size_t size);
197
198 size_t capacity() const { return _capacity; }
199
200 oop pop() {
201 if (!isEmpty()) {
202 return _base[--_index] ;
203 }
204 return NULL;
205 }
206
207 bool push(oop ptr) {
208 if (isFull()) {
209 return false;
210 } else {
211 _base[_index++] = ptr;
212 NOT_PRODUCT(_max_depth = MAX2(_max_depth, _index));
|