1 /*
2 * Copyright (c) 1997, 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 *
138 const void* _p;
139 Space* sp;
140 virtual void do_space(Space* s) {
141 if (sp == NULL) {
142 if (s->is_in(_p)) sp = s;
143 }
144 }
145 GenerationIsInClosure(const void* p) : _p(p), sp(NULL) {}
146 };
147
148 bool Generation::is_in(const void* p) const {
149 GenerationIsInClosure blk(p);
150 ((Generation*)this)->space_iterate(&blk);
151 return blk.sp != NULL;
152 }
153
154 Generation* Generation::next_gen() const {
155 GenCollectedHeap* gch = GenCollectedHeap::heap();
156 int next = level() + 1;
157 if (next < gch->_n_gens) {
158 return gch->_gens[next];
159 } else {
160 return NULL;
161 }
162 }
163
164 size_t Generation::max_contiguous_available() const {
165 // The largest number of contiguous free words in this or any higher generation.
166 size_t max = 0;
167 for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
168 size_t avail = gen->contiguous_available();
169 if (avail > max) {
170 max = avail;
171 }
172 }
173 return max;
174 }
175
176 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
177 size_t available = max_contiguous_available();
178 bool res = (available >= max_promotion_in_bytes);
|
1 /*
2 * Copyright (c) 1997, 2015, 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 *
138 const void* _p;
139 Space* sp;
140 virtual void do_space(Space* s) {
141 if (sp == NULL) {
142 if (s->is_in(_p)) sp = s;
143 }
144 }
145 GenerationIsInClosure(const void* p) : _p(p), sp(NULL) {}
146 };
147
148 bool Generation::is_in(const void* p) const {
149 GenerationIsInClosure blk(p);
150 ((Generation*)this)->space_iterate(&blk);
151 return blk.sp != NULL;
152 }
153
154 Generation* Generation::next_gen() const {
155 GenCollectedHeap* gch = GenCollectedHeap::heap();
156 int next = level() + 1;
157 if (next < gch->_n_gens) {
158 return gch->get_gen(next);
159 } else {
160 return NULL;
161 }
162 }
163
164 size_t Generation::max_contiguous_available() const {
165 // The largest number of contiguous free words in this or any higher generation.
166 size_t max = 0;
167 for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
168 size_t avail = gen->contiguous_available();
169 if (avail > max) {
170 max = avail;
171 }
172 }
173 return max;
174 }
175
176 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
177 size_t available = max_contiguous_available();
178 bool res = (available >= max_promotion_in_bytes);
|