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 *
23 */
24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
27
28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
29 #include "gc_interface/collectedHeap.hpp"
30 #include "memory/allocation.hpp"
31
32 //
33 // PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
34 // much like a MutableSpace. We couldn't embed a MutableSpace, though, as
35 // it has a considerable number of asserts and invariants that are violated.
36 //
37
38 class ObjectStartArray;
39
40 class PSPromotionLAB : public CHeapObj<mtGC> {
41 protected:
42 static size_t filler_header_size;
43
44 enum LabState {
45 needs_flush,
46 flushed,
47 zero_size
48 };
49
117 // Cannot test for this now that we're doing promotion failures
118 // assert(_state != flushed, "Sanity");
119 assert(_start_array != NULL, "Sanity");
120 HeapWord* obj = top();
121 HeapWord* new_top = obj + size;
122 // The 'new_top>obj' check is needed to detect overflow of obj+size.
123 if (new_top > obj && new_top <= end()) {
124 set_top(new_top);
125 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
126 "checking alignment");
127 _start_array->allocate_block(obj);
128 return obj;
129 }
130
131 return NULL;
132 }
133
134 debug_only(virtual bool lab_is_valid(MemRegion lab));
135 };
136
137 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
|
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 *
23 */
24
25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP
26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP
27
28 #include "gc/parallel/objectStartArray.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "memory/allocation.hpp"
31
32 //
33 // PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
34 // much like a MutableSpace. We couldn't embed a MutableSpace, though, as
35 // it has a considerable number of asserts and invariants that are violated.
36 //
37
38 class ObjectStartArray;
39
40 class PSPromotionLAB : public CHeapObj<mtGC> {
41 protected:
42 static size_t filler_header_size;
43
44 enum LabState {
45 needs_flush,
46 flushed,
47 zero_size
48 };
49
117 // Cannot test for this now that we're doing promotion failures
118 // assert(_state != flushed, "Sanity");
119 assert(_start_array != NULL, "Sanity");
120 HeapWord* obj = top();
121 HeapWord* new_top = obj + size;
122 // The 'new_top>obj' check is needed to detect overflow of obj+size.
123 if (new_top > obj && new_top <= end()) {
124 set_top(new_top);
125 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
126 "checking alignment");
127 _start_array->allocate_block(obj);
128 return obj;
129 }
130
131 return NULL;
132 }
133
134 debug_only(virtual bool lab_is_valid(MemRegion lab));
135 };
136
137 #endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_HPP
|