annotate src/share/vm/gc_implementation/concurrentMarkSweep/promotionInfo.hpp @ 1521:a8127dc669ba

6951188: CMS: move PromotionInfo into its own file Summary: Moved PromotionInfo and friends into new files promotionInfo.{h,c}pp from their previous compactibleFreeListSpace.{h,c}pp home. Reviewed-by: apetrusenko
author ysr
date Mon, 10 May 2010 12:31:52 -0700
parents
children a00b51b2dda4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1521
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
1 /*
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
4 *
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
8 *
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
13 * accompanied this code).
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
14 *
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
18 *
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
21 * have any questions.
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
22 *
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
23 */
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
24
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
25 // Forward declarations
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
26 class CompactibleFreeListSpace;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
27
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
28 class PromotedObject VALUE_OBJ_CLASS_SPEC {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
29 private:
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
30 enum {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
31 promoted_mask = right_n_bits(2), // i.e. 0x3
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
32 displaced_mark = nth_bit(2), // i.e. 0x4
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
33 next_mask = ~(right_n_bits(3)) // i.e. ~(0x7)
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
34 };
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
35 intptr_t _next;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
36 public:
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
37 inline PromotedObject* next() const {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
38 return (PromotedObject*)(_next & next_mask);
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
39 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
40 inline void setNext(PromotedObject* x) {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
41 assert(((intptr_t)x & ~next_mask) == 0,
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
42 "Conflict in bit usage, "
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
43 " or insufficient alignment of objects");
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
44 _next |= (intptr_t)x;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
45 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
46 inline void setPromotedMark() {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
47 _next |= promoted_mask;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
48 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
49 inline bool hasPromotedMark() const {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
50 return (_next & promoted_mask) == promoted_mask;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
51 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
52 inline void setDisplacedMark() {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
53 _next |= displaced_mark;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
54 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
55 inline bool hasDisplacedMark() const {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
56 return (_next & displaced_mark) != 0;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
57 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
58 inline void clearNext() { _next = 0; }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
59 debug_only(void *next_addr() { return (void *) &_next; })
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
60 };
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
61
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
62 class SpoolBlock: public FreeChunk {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
63 friend class PromotionInfo;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
64 protected:
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
65 SpoolBlock* nextSpoolBlock;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
66 size_t bufferSize; // number of usable words in this block
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
67 markOop* displacedHdr; // the displaced headers start here
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
68
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
69 // Note about bufferSize: it denotes the number of entries available plus 1;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
70 // legal indices range from 1 through BufferSize - 1. See the verification
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
71 // code verify() that counts the number of displaced headers spooled.
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
72 size_t computeBufferSize() {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
73 return (size() * sizeof(HeapWord) - sizeof(*this)) / sizeof(markOop);
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
74 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
75
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
76 public:
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
77 void init() {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
78 bufferSize = computeBufferSize();
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
79 displacedHdr = (markOop*)&displacedHdr;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
80 nextSpoolBlock = NULL;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
81 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
82
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
83 void print_on(outputStream* st) const;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
84 void print() const { print_on(gclog_or_tty); }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
85 };
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
86
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
87 class PromotionInfo VALUE_OBJ_CLASS_SPEC {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
88 bool _tracking; // set if tracking
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
89 CompactibleFreeListSpace* _space; // the space to which this belongs
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
90 PromotedObject* _promoHead; // head of list of promoted objects
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
91 PromotedObject* _promoTail; // tail of list of promoted objects
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
92 SpoolBlock* _spoolHead; // first spooling block
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
93 SpoolBlock* _spoolTail; // last non-full spooling block or null
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
94 SpoolBlock* _splice_point; // when _spoolTail is null, holds list tail
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
95 SpoolBlock* _spareSpool; // free spool buffer
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
96 size_t _firstIndex; // first active index in
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
97 // first spooling block (_spoolHead)
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
98 size_t _nextIndex; // last active index + 1 in last
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
99 // spooling block (_spoolTail)
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
100 private:
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
101 // ensure that spooling space exists; return true if there is spooling space
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
102 bool ensure_spooling_space_work();
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
103
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
104 public:
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
105 PromotionInfo() :
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
106 _tracking(0), _space(NULL),
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
107 _promoHead(NULL), _promoTail(NULL),
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
108 _spoolHead(NULL), _spoolTail(NULL),
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
109 _spareSpool(NULL), _firstIndex(1),
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
110 _nextIndex(1) {}
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
111
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
112 bool noPromotions() const {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
113 assert(_promoHead != NULL || _promoTail == NULL, "list inconsistency");
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
114 return _promoHead == NULL;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
115 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
116 void startTrackingPromotions();
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
117 void stopTrackingPromotions(uint worker_id = 0);
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
118 bool tracking() const { return _tracking; }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
119 void track(PromotedObject* trackOop); // keep track of a promoted oop
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
120 // The following variant must be used when trackOop is not fully
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
121 // initialized and has a NULL klass:
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
122 void track(PromotedObject* trackOop, klassOop klassOfOop); // keep track of a promoted oop
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
123 void setSpace(CompactibleFreeListSpace* sp) { _space = sp; }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
124 CompactibleFreeListSpace* space() const { return _space; }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
125 markOop nextDisplacedHeader(); // get next header & forward spool pointer
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
126 void saveDisplacedHeader(markOop hdr);
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
127 // save header and forward spool
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
128
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
129 inline size_t refillSize() const;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
130
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
131 SpoolBlock* getSpoolBlock(); // return a free spooling block
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
132 inline bool has_spooling_space() {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
133 return _spoolTail != NULL && _spoolTail->bufferSize > _nextIndex;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
134 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
135 // ensure that spooling space exists
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
136 bool ensure_spooling_space() {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
137 return has_spooling_space() || ensure_spooling_space_work();
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
138 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
139 #define PROMOTED_OOPS_ITERATE_DECL(OopClosureType, nv_suffix) \
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
140 void promoted_oops_iterate##nv_suffix(OopClosureType* cl);
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
141 ALL_SINCE_SAVE_MARKS_CLOSURES(PROMOTED_OOPS_ITERATE_DECL)
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
142 #undef PROMOTED_OOPS_ITERATE_DECL
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
143 void promoted_oops_iterate(OopsInGenClosure* cl) {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
144 promoted_oops_iterate_v(cl);
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
145 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
146 void verify() const;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
147 void reset() {
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
148 _promoHead = NULL;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
149 _promoTail = NULL;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
150 _spoolHead = NULL;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
151 _spoolTail = NULL;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
152 _spareSpool = NULL;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
153 _firstIndex = 0;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
154 _nextIndex = 0;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
155
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
156 }
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
157
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
158 void print_on(outputStream* st) const;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
159 void print_statistics(uint worker_id) const;
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
160 };
a8127dc669ba 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
161