annotate src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children c63b928b212b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // much like a MutableSpace. We couldn't embed a MutableSpace, though, as
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // it has a considerable number of asserts and invariants that are violated.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class ObjectStartArray;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class PSPromotionLAB : public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 protected:
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
41 static size_t filler_header_size;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 enum LabState {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 needs_flush,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 flushed,
a61af66fc99e Initial load
duke
parents:
diff changeset
46 zero_size
a61af66fc99e Initial load
duke
parents:
diff changeset
47 };
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 HeapWord* _top;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 HeapWord* _bottom;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 HeapWord* _end;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 LabState _state;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void set_top(HeapWord* value) { _top = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 void set_bottom(HeapWord* value) { _bottom = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 void set_end(HeapWord* value) { _end = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // The shared initialize code invokes this.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 debug_only(virtual bool lab_is_valid(MemRegion lab) { return false; });
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 PSPromotionLAB() : _top(NULL), _bottom(NULL), _end(NULL) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Filling and flushing.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void initialize(MemRegion lab);
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 virtual void flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
70 HeapWord* bottom() const { return _bottom; }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 HeapWord* end() const { return _end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 HeapWord* top() const { return _top; }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 bool is_flushed() { return _state == flushed; }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 bool unallocate_object(oop obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Returns a subregion containing all objects in this space.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 MemRegion used_region() { return MemRegion(bottom(), top()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Boolean querries.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 bool is_empty() const { return used() == 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 bool not_empty() const { return used() > 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 bool contains(const void* p) const { return _bottom <= p && p < _end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Size computations. Sizes are in bytes.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 size_t capacity() const { return byte_size(bottom(), end()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 size_t used() const { return byte_size(bottom(), top()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 size_t free() const { return byte_size(top(), end()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 };
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 class PSYoungPromotionLAB : public PSPromotionLAB {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 PSYoungPromotionLAB() { }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Not MT safe
a61af66fc99e Initial load
duke
parents:
diff changeset
97 HeapWord* allocate(size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Can't assert this, when young fills, we keep the LAB around, but flushed.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // assert(_state != flushed, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
100 HeapWord* obj = top();
a61af66fc99e Initial load
duke
parents:
diff changeset
101 HeapWord* new_top = obj + size;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // The 'new_top>obj' check is needed to detect overflow of obj+size.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (new_top > obj && new_top <= end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 set_top(new_top);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
a61af66fc99e Initial load
duke
parents:
diff changeset
106 "checking alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 debug_only(virtual bool lab_is_valid(MemRegion lab));
a61af66fc99e Initial load
duke
parents:
diff changeset
114 };
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 class PSOldPromotionLAB : public PSPromotionLAB {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
118 ObjectStartArray* _start_array;
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 PSOldPromotionLAB() : _start_array(NULL) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 PSOldPromotionLAB(ObjectStartArray* start_array) : _start_array(start_array) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void set_start_array(ObjectStartArray* start_array) { _start_array = start_array; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Not MT safe
a61af66fc99e Initial load
duke
parents:
diff changeset
129 HeapWord* allocate(size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Cannot test for this now that we're doing promotion failures
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // assert(_state != flushed, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 assert(_start_array != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
133 HeapWord* obj = top();
a61af66fc99e Initial load
duke
parents:
diff changeset
134 HeapWord* new_top = obj + size;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // The 'new_top>obj' check is needed to detect overflow of obj+size.
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (new_top > obj && new_top <= end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 set_top(new_top);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
a61af66fc99e Initial load
duke
parents:
diff changeset
139 "checking alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 _start_array->allocate_block(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 debug_only(virtual bool lab_is_valid(MemRegion lab));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
149
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
150 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP