author | coleenp |
Tue, 22 Dec 2015 11:11:29 -0500 | |
changeset 35214 | d86005e0b4c2 |
parent 35061 | be6025ebffea |
child 35862 | 411842d0c882 |
permissions | -rw-r--r-- |
5434 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. |
5434 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5541
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5541
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5541
diff
changeset
|
21 |
* questions. |
5434 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_CMS_PROMOTIONINFO_HPP |
26 |
#define SHARE_VM_GC_CMS_PROMOTIONINFO_HPP |
|
7397 | 27 |
|
30764 | 28 |
#include "gc/cms/freeChunk.hpp" |
7397 | 29 |
#include "memory/allocation.hpp" |
30 |
||
5434 | 31 |
// Forward declarations |
32 |
class CompactibleFreeListSpace; |
|
33 |
||
34 |
class PromotedObject VALUE_OBJ_CLASS_SPEC { |
|
35 |
private: |
|
36 |
enum { |
|
37 |
promoted_mask = right_n_bits(2), // i.e. 0x3 |
|
38 |
displaced_mark = nth_bit(2), // i.e. 0x4 |
|
39 |
next_mask = ~(right_n_bits(3)) // i.e. ~(0x7) |
|
40 |
}; |
|
5541
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
41 |
|
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
42 |
// Below, we want _narrow_next in the "higher" 32 bit slot, |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
43 |
// whose position will depend on endian-ness of the platform. |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
44 |
// This is so that there is no interference with the |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
45 |
// cms_free_bit occupying bit position 7 (lsb == 0) |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
46 |
// when we are using compressed oops; see FreeChunk::is_free(). |
5541
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
47 |
// We cannot move the cms_free_bit down because currently |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
48 |
// biased locking code assumes that age bits are contiguous |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
49 |
// with the lock bits. Even if that assumption were relaxed, |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
50 |
// the least position we could move this bit to would be |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
51 |
// to bit position 3, which would require 16 byte alignment. |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
52 |
typedef struct { |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
53 |
#ifdef VM_LITTLE_ENDIAN |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
54 |
LP64_ONLY(narrowOop _pad;) |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
55 |
narrowOop _narrow_next; |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
56 |
#else |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
57 |
narrowOop _narrow_next; |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
58 |
LP64_ONLY(narrowOop _pad;) |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
59 |
#endif |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
60 |
} Data; |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
61 |
|
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
62 |
union { |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
63 |
intptr_t _next; |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
64 |
Data _data; |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
65 |
}; |
5434 | 66 |
public: |
67 |
inline PromotedObject* next() const { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
68 |
assert(!((FreeChunk*)this)->is_free(), "Error"); |
5541
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
69 |
PromotedObject* res; |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
70 |
if (UseCompressedOops) { |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
71 |
// The next pointer is a compressed oop stored in the top 32 bits |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
72 |
res = (PromotedObject*)oopDesc::decode_heap_oop(_data._narrow_next); |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
73 |
} else { |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
74 |
res = (PromotedObject*)(_next & next_mask); |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
75 |
} |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
76 |
assert(oop(res)->is_oop_or_null(true /* ignore mark word */), "Expected an oop or NULL at " PTR_FORMAT, p2i(oop(res))); |
5541
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
77 |
return res; |
5434 | 78 |
} |
79 |
inline void setNext(PromotedObject* x) { |
|
5541
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
80 |
assert(((intptr_t)x & ~next_mask) == 0, "Conflict in bit usage, " |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
81 |
"or insufficient alignment of objects"); |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
82 |
if (UseCompressedOops) { |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
83 |
assert(_data._narrow_next == 0, "Overwrite?"); |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
84 |
_data._narrow_next = oopDesc::encode_heap_oop(oop(x)); |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
85 |
} else { |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
86 |
_next |= (intptr_t)x; |
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
87 |
} |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
88 |
assert(!((FreeChunk*)this)->is_free(), "Error"); |
5434 | 89 |
} |
90 |
inline void setPromotedMark() { |
|
91 |
_next |= promoted_mask; |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
92 |
assert(!((FreeChunk*)this)->is_free(), "Error"); |
5434 | 93 |
} |
94 |
inline bool hasPromotedMark() const { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
95 |
assert(!((FreeChunk*)this)->is_free(), "Error"); |
5434 | 96 |
return (_next & promoted_mask) == promoted_mask; |
97 |
} |
|
98 |
inline void setDisplacedMark() { |
|
99 |
_next |= displaced_mark; |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
100 |
assert(!((FreeChunk*)this)->is_free(), "Error"); |
5434 | 101 |
} |
102 |
inline bool hasDisplacedMark() const { |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
103 |
assert(!((FreeChunk*)this)->is_free(), "Error"); |
5434 | 104 |
return (_next & displaced_mark) != 0; |
105 |
} |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
106 |
inline void clear_next() { |
5541
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
107 |
_next = 0; |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
7397
diff
changeset
|
108 |
assert(!((FreeChunk*)this)->is_free(), "Error"); |
5541
19c39d42a747
6948539: CMS+UseCompressedOops: placement of cms_free bit interferes with promoted object link
ysr
parents:
5434
diff
changeset
|
109 |
} |
5434 | 110 |
debug_only(void *next_addr() { return (void *) &_next; }) |
111 |
}; |
|
112 |
||
113 |
class SpoolBlock: public FreeChunk { |
|
114 |
friend class PromotionInfo; |
|
115 |
protected: |
|
116 |
SpoolBlock* nextSpoolBlock; |
|
117 |
size_t bufferSize; // number of usable words in this block |
|
118 |
markOop* displacedHdr; // the displaced headers start here |
|
119 |
||
120 |
// Note about bufferSize: it denotes the number of entries available plus 1; |
|
121 |
// legal indices range from 1 through BufferSize - 1. See the verification |
|
122 |
// code verify() that counts the number of displaced headers spooled. |
|
123 |
size_t computeBufferSize() { |
|
124 |
return (size() * sizeof(HeapWord) - sizeof(*this)) / sizeof(markOop); |
|
125 |
} |
|
126 |
||
127 |
public: |
|
128 |
void init() { |
|
129 |
bufferSize = computeBufferSize(); |
|
130 |
displacedHdr = (markOop*)&displacedHdr; |
|
131 |
nextSpoolBlock = NULL; |
|
132 |
} |
|
133 |
||
134 |
void print_on(outputStream* st) const; |
|
35061 | 135 |
void print() const { print_on(tty); } |
5434 | 136 |
}; |
137 |
||
138 |
class PromotionInfo VALUE_OBJ_CLASS_SPEC { |
|
139 |
bool _tracking; // set if tracking |
|
140 |
CompactibleFreeListSpace* _space; // the space to which this belongs |
|
141 |
PromotedObject* _promoHead; // head of list of promoted objects |
|
142 |
PromotedObject* _promoTail; // tail of list of promoted objects |
|
143 |
SpoolBlock* _spoolHead; // first spooling block |
|
144 |
SpoolBlock* _spoolTail; // last non-full spooling block or null |
|
145 |
SpoolBlock* _splice_point; // when _spoolTail is null, holds list tail |
|
146 |
SpoolBlock* _spareSpool; // free spool buffer |
|
147 |
size_t _firstIndex; // first active index in |
|
148 |
// first spooling block (_spoolHead) |
|
149 |
size_t _nextIndex; // last active index + 1 in last |
|
150 |
// spooling block (_spoolTail) |
|
151 |
private: |
|
152 |
// ensure that spooling space exists; return true if there is spooling space |
|
153 |
bool ensure_spooling_space_work(); |
|
154 |
||
155 |
public: |
|
156 |
PromotionInfo() : |
|
157 |
_tracking(0), _space(NULL), |
|
158 |
_promoHead(NULL), _promoTail(NULL), |
|
159 |
_spoolHead(NULL), _spoolTail(NULL), |
|
160 |
_spareSpool(NULL), _firstIndex(1), |
|
161 |
_nextIndex(1) {} |
|
162 |
||
163 |
bool noPromotions() const { |
|
164 |
assert(_promoHead != NULL || _promoTail == NULL, "list inconsistency"); |
|
165 |
return _promoHead == NULL; |
|
166 |
} |
|
167 |
void startTrackingPromotions(); |
|
168 |
void stopTrackingPromotions(uint worker_id = 0); |
|
169 |
bool tracking() const { return _tracking; } |
|
170 |
void track(PromotedObject* trackOop); // keep track of a promoted oop |
|
171 |
// The following variant must be used when trackOop is not fully |
|
172 |
// initialized and has a NULL klass: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12509
diff
changeset
|
173 |
void track(PromotedObject* trackOop, Klass* klassOfOop); // keep track of a promoted oop |
5434 | 174 |
void setSpace(CompactibleFreeListSpace* sp) { _space = sp; } |
175 |
CompactibleFreeListSpace* space() const { return _space; } |
|
176 |
markOop nextDisplacedHeader(); // get next header & forward spool pointer |
|
177 |
void saveDisplacedHeader(markOop hdr); |
|
178 |
// save header and forward spool |
|
179 |
||
180 |
inline size_t refillSize() const; |
|
181 |
||
182 |
SpoolBlock* getSpoolBlock(); // return a free spooling block |
|
183 |
inline bool has_spooling_space() { |
|
184 |
return _spoolTail != NULL && _spoolTail->bufferSize > _nextIndex; |
|
185 |
} |
|
186 |
// ensure that spooling space exists |
|
187 |
bool ensure_spooling_space() { |
|
188 |
return has_spooling_space() || ensure_spooling_space_work(); |
|
189 |
} |
|
190 |
#define PROMOTED_OOPS_ITERATE_DECL(OopClosureType, nv_suffix) \ |
|
191 |
void promoted_oops_iterate##nv_suffix(OopClosureType* cl); |
|
192 |
ALL_SINCE_SAVE_MARKS_CLOSURES(PROMOTED_OOPS_ITERATE_DECL) |
|
193 |
#undef PROMOTED_OOPS_ITERATE_DECL |
|
194 |
void promoted_oops_iterate(OopsInGenClosure* cl) { |
|
195 |
promoted_oops_iterate_v(cl); |
|
196 |
} |
|
197 |
void verify() const; |
|
198 |
void reset() { |
|
199 |
_promoHead = NULL; |
|
200 |
_promoTail = NULL; |
|
201 |
_spoolHead = NULL; |
|
202 |
_spoolTail = NULL; |
|
203 |
_spareSpool = NULL; |
|
204 |
_firstIndex = 0; |
|
205 |
_nextIndex = 0; |
|
206 |
||
207 |
} |
|
208 |
||
209 |
void print_on(outputStream* st) const; |
|
210 |
}; |
|
211 |
||
7397 | 212 |
|
30764 | 213 |
#endif // SHARE_VM_GC_CMS_PROMOTIONINFO_HPP |