src/share/vm/gc_implementation/concurrentMarkSweep/promotionInfo.hpp

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1901
a00b51b2dda4
child 2314
f95d63e2154a
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

ysr@1876 1 /*
trims@1907 2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
ysr@1876 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@1876 4 *
ysr@1876 5 * This code is free software; you can redistribute it and/or modify it
ysr@1876 6 * under the terms of the GNU General Public License version 2 only, as
ysr@1876 7 * published by the Free Software Foundation.
ysr@1876 8 *
ysr@1876 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@1876 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@1876 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@1876 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@1876 13 * accompanied this code).
ysr@1876 14 *
ysr@1876 15 * You should have received a copy of the GNU General Public License version
ysr@1876 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@1876 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@1876 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@1876 22 *
ysr@1876 23 */
ysr@1876 24
ysr@1876 25 // Forward declarations
ysr@1876 26 class CompactibleFreeListSpace;
ysr@1876 27
ysr@1876 28 class PromotedObject VALUE_OBJ_CLASS_SPEC {
ysr@1876 29 private:
ysr@1876 30 enum {
ysr@1876 31 promoted_mask = right_n_bits(2), // i.e. 0x3
ysr@1876 32 displaced_mark = nth_bit(2), // i.e. 0x4
ysr@1876 33 next_mask = ~(right_n_bits(3)) // i.e. ~(0x7)
ysr@1876 34 };
ysr@1901 35
ysr@1901 36 // Below, we want _narrow_next in the "higher" 32 bit slot,
ysr@1901 37 // whose position will depend on endian-ness of the platform.
ysr@1901 38 // This is so that there is no interference with the
ysr@1901 39 // cms_free_bit occupying bit position 7 (lsb == 0)
ysr@1901 40 // when we are using compressed oops; see FreeChunk::isFree().
ysr@1901 41 // We cannot move the cms_free_bit down because currently
ysr@1901 42 // biased locking code assumes that age bits are contiguous
ysr@1901 43 // with the lock bits. Even if that assumption were relaxed,
ysr@1901 44 // the least position we could move this bit to would be
ysr@1901 45 // to bit position 3, which would require 16 byte alignment.
ysr@1901 46 typedef struct {
ysr@1901 47 #ifdef VM_LITTLE_ENDIAN
ysr@1901 48 LP64_ONLY(narrowOop _pad;)
ysr@1901 49 narrowOop _narrow_next;
ysr@1901 50 #else
ysr@1901 51 narrowOop _narrow_next;
ysr@1901 52 LP64_ONLY(narrowOop _pad;)
ysr@1901 53 #endif
ysr@1901 54 } Data;
ysr@1901 55
ysr@1901 56 union {
ysr@1901 57 intptr_t _next;
ysr@1901 58 Data _data;
ysr@1901 59 };
ysr@1876 60 public:
ysr@1876 61 inline PromotedObject* next() const {
ysr@1901 62 assert(!((FreeChunk*)this)->isFree(), "Error");
ysr@1901 63 PromotedObject* res;
ysr@1901 64 if (UseCompressedOops) {
ysr@1901 65 // The next pointer is a compressed oop stored in the top 32 bits
ysr@1901 66 res = (PromotedObject*)oopDesc::decode_heap_oop(_data._narrow_next);
ysr@1901 67 } else {
ysr@1901 68 res = (PromotedObject*)(_next & next_mask);
ysr@1901 69 }
ysr@1901 70 assert(oop(res)->is_oop_or_null(true /* ignore mark word */), "Not an oop?");
ysr@1901 71 return res;
ysr@1876 72 }
ysr@1876 73 inline void setNext(PromotedObject* x) {
ysr@1901 74 assert(((intptr_t)x & ~next_mask) == 0, "Conflict in bit usage, "
ysr@1901 75 "or insufficient alignment of objects");
ysr@1901 76 if (UseCompressedOops) {
ysr@1901 77 assert(_data._narrow_next == 0, "Overwrite?");
ysr@1901 78 _data._narrow_next = oopDesc::encode_heap_oop(oop(x));
ysr@1901 79 } else {
ysr@1901 80 _next |= (intptr_t)x;
ysr@1901 81 }
ysr@1901 82 assert(!((FreeChunk*)this)->isFree(), "Error");
ysr@1876 83 }
ysr@1876 84 inline void setPromotedMark() {
ysr@1876 85 _next |= promoted_mask;
ysr@1901 86 assert(!((FreeChunk*)this)->isFree(), "Error");
ysr@1876 87 }
ysr@1876 88 inline bool hasPromotedMark() const {
ysr@1901 89 assert(!((FreeChunk*)this)->isFree(), "Error");
ysr@1876 90 return (_next & promoted_mask) == promoted_mask;
ysr@1876 91 }
ysr@1876 92 inline void setDisplacedMark() {
ysr@1876 93 _next |= displaced_mark;
ysr@1901 94 assert(!((FreeChunk*)this)->isFree(), "Error");
ysr@1876 95 }
ysr@1876 96 inline bool hasDisplacedMark() const {
ysr@1901 97 assert(!((FreeChunk*)this)->isFree(), "Error");
ysr@1876 98 return (_next & displaced_mark) != 0;
ysr@1876 99 }
ysr@1901 100 inline void clearNext() {
ysr@1901 101 _next = 0;
ysr@1901 102 assert(!((FreeChunk*)this)->isFree(), "Error");
ysr@1901 103 }
ysr@1876 104 debug_only(void *next_addr() { return (void *) &_next; })
ysr@1876 105 };
ysr@1876 106
ysr@1876 107 class SpoolBlock: public FreeChunk {
ysr@1876 108 friend class PromotionInfo;
ysr@1876 109 protected:
ysr@1876 110 SpoolBlock* nextSpoolBlock;
ysr@1876 111 size_t bufferSize; // number of usable words in this block
ysr@1876 112 markOop* displacedHdr; // the displaced headers start here
ysr@1876 113
ysr@1876 114 // Note about bufferSize: it denotes the number of entries available plus 1;
ysr@1876 115 // legal indices range from 1 through BufferSize - 1. See the verification
ysr@1876 116 // code verify() that counts the number of displaced headers spooled.
ysr@1876 117 size_t computeBufferSize() {
ysr@1876 118 return (size() * sizeof(HeapWord) - sizeof(*this)) / sizeof(markOop);
ysr@1876 119 }
ysr@1876 120
ysr@1876 121 public:
ysr@1876 122 void init() {
ysr@1876 123 bufferSize = computeBufferSize();
ysr@1876 124 displacedHdr = (markOop*)&displacedHdr;
ysr@1876 125 nextSpoolBlock = NULL;
ysr@1876 126 }
ysr@1876 127
ysr@1876 128 void print_on(outputStream* st) const;
ysr@1876 129 void print() const { print_on(gclog_or_tty); }
ysr@1876 130 };
ysr@1876 131
ysr@1876 132 class PromotionInfo VALUE_OBJ_CLASS_SPEC {
ysr@1876 133 bool _tracking; // set if tracking
ysr@1876 134 CompactibleFreeListSpace* _space; // the space to which this belongs
ysr@1876 135 PromotedObject* _promoHead; // head of list of promoted objects
ysr@1876 136 PromotedObject* _promoTail; // tail of list of promoted objects
ysr@1876 137 SpoolBlock* _spoolHead; // first spooling block
ysr@1876 138 SpoolBlock* _spoolTail; // last non-full spooling block or null
ysr@1876 139 SpoolBlock* _splice_point; // when _spoolTail is null, holds list tail
ysr@1876 140 SpoolBlock* _spareSpool; // free spool buffer
ysr@1876 141 size_t _firstIndex; // first active index in
ysr@1876 142 // first spooling block (_spoolHead)
ysr@1876 143 size_t _nextIndex; // last active index + 1 in last
ysr@1876 144 // spooling block (_spoolTail)
ysr@1876 145 private:
ysr@1876 146 // ensure that spooling space exists; return true if there is spooling space
ysr@1876 147 bool ensure_spooling_space_work();
ysr@1876 148
ysr@1876 149 public:
ysr@1876 150 PromotionInfo() :
ysr@1876 151 _tracking(0), _space(NULL),
ysr@1876 152 _promoHead(NULL), _promoTail(NULL),
ysr@1876 153 _spoolHead(NULL), _spoolTail(NULL),
ysr@1876 154 _spareSpool(NULL), _firstIndex(1),
ysr@1876 155 _nextIndex(1) {}
ysr@1876 156
ysr@1876 157 bool noPromotions() const {
ysr@1876 158 assert(_promoHead != NULL || _promoTail == NULL, "list inconsistency");
ysr@1876 159 return _promoHead == NULL;
ysr@1876 160 }
ysr@1876 161 void startTrackingPromotions();
ysr@1876 162 void stopTrackingPromotions(uint worker_id = 0);
ysr@1876 163 bool tracking() const { return _tracking; }
ysr@1876 164 void track(PromotedObject* trackOop); // keep track of a promoted oop
ysr@1876 165 // The following variant must be used when trackOop is not fully
ysr@1876 166 // initialized and has a NULL klass:
ysr@1876 167 void track(PromotedObject* trackOop, klassOop klassOfOop); // keep track of a promoted oop
ysr@1876 168 void setSpace(CompactibleFreeListSpace* sp) { _space = sp; }
ysr@1876 169 CompactibleFreeListSpace* space() const { return _space; }
ysr@1876 170 markOop nextDisplacedHeader(); // get next header & forward spool pointer
ysr@1876 171 void saveDisplacedHeader(markOop hdr);
ysr@1876 172 // save header and forward spool
ysr@1876 173
ysr@1876 174 inline size_t refillSize() const;
ysr@1876 175
ysr@1876 176 SpoolBlock* getSpoolBlock(); // return a free spooling block
ysr@1876 177 inline bool has_spooling_space() {
ysr@1876 178 return _spoolTail != NULL && _spoolTail->bufferSize > _nextIndex;
ysr@1876 179 }
ysr@1876 180 // ensure that spooling space exists
ysr@1876 181 bool ensure_spooling_space() {
ysr@1876 182 return has_spooling_space() || ensure_spooling_space_work();
ysr@1876 183 }
ysr@1876 184 #define PROMOTED_OOPS_ITERATE_DECL(OopClosureType, nv_suffix) \
ysr@1876 185 void promoted_oops_iterate##nv_suffix(OopClosureType* cl);
ysr@1876 186 ALL_SINCE_SAVE_MARKS_CLOSURES(PROMOTED_OOPS_ITERATE_DECL)
ysr@1876 187 #undef PROMOTED_OOPS_ITERATE_DECL
ysr@1876 188 void promoted_oops_iterate(OopsInGenClosure* cl) {
ysr@1876 189 promoted_oops_iterate_v(cl);
ysr@1876 190 }
ysr@1876 191 void verify() const;
ysr@1876 192 void reset() {
ysr@1876 193 _promoHead = NULL;
ysr@1876 194 _promoTail = NULL;
ysr@1876 195 _spoolHead = NULL;
ysr@1876 196 _spoolTail = NULL;
ysr@1876 197 _spareSpool = NULL;
ysr@1876 198 _firstIndex = 0;
ysr@1876 199 _nextIndex = 0;
ysr@1876 200
ysr@1876 201 }
ysr@1876 202
ysr@1876 203 void print_on(outputStream* st) const;
ysr@1876 204 void print_statistics(uint worker_id) const;
ysr@1876 205 };
ysr@1876 206

mercurial