< prev index next >

src/hotspot/share/gc/cms/promotionInfo.cpp

Print this page
rev 49290 : [mq]: JDK-8199735.01.patch
   1 /*
   2  * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
   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  *
  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  *


  67 // To aid verification and debugging, in the non-product builds
  68 // we actually forward _promoHead each time we process a promoted oop.
  69 // Note that this is not necessary in general (i.e. when we don't need to
  70 // call PromotionInfo::verify()) because oop_iterate can only add to the
  71 // end of _promoTail, and never needs to look at _promoHead.
  72 
  73 #define PROMOTED_OOPS_ITERATE_DEFN(OopClosureType, nv_suffix)               \
  74                                                                             \
  75 void PromotionInfo::promoted_oops_iterate##nv_suffix(OopClosureType* cl) {  \
  76   NOT_PRODUCT(verify());                                                    \
  77   PromotedObject *curObj, *nextObj;                                         \
  78   for (curObj = _promoHead; curObj != NULL; curObj = nextObj) {             \
  79     if ((nextObj = curObj->next()) == NULL) {                               \
  80       /* protect ourselves against additions due to closure application     \
  81          below by resetting the list.  */                                   \
  82       assert(_promoTail == curObj, "Should have been the tail");            \
  83       _promoHead = _promoTail = NULL;                                       \
  84     }                                                                       \
  85     if (curObj->hasDisplacedMark()) {                                       \
  86       /* restore displaced header */                                        \
  87       oop(curObj)->set_mark(nextDisplacedHeader());                         \
  88     } else {                                                                \
  89       /* restore prototypical header */                                     \
  90       oop(curObj)->init_mark();                                             \
  91     }                                                                       \
  92     /* The "promoted_mark" should now not be set */                         \
  93     assert(!curObj->hasPromotedMark(),                                      \
  94            "Should have been cleared by restoring displaced mark-word");    \
  95     NOT_PRODUCT(_promoHead = nextObj);                                      \
  96     if (cl != NULL) oop(curObj)->oop_iterate(cl);                           \
  97     if (nextObj == NULL) { /* start at head of list reset above */          \
  98       nextObj = _promoHead;                                                 \
  99     }                                                                       \
 100   }                                                                         \
 101   assert(noPromotions(), "post-condition violation");                       \
 102   assert(_promoHead == NULL && _promoTail == NULL, "emptied promoted list");\
 103   assert(_spoolHead == _spoolTail, "emptied spooling buffers");             \
 104   assert(_firstIndex == _nextIndex, "empty buffer");                        \
 105 }
 106 
 107 // This should have been ALL_SINCE_...() just like the others,
 108 // but, because the body of the method above is somehwat longer,
 109 // the MSVC compiler cannot cope; as a workaround, we split the
 110 // macro into its 3 constituent parts below (see original macro


 129     _spoolHead->nextSpoolBlock = _spareSpool;
 130     _spareSpool = _spoolHead;
 131     _spoolHead = tmp;
 132     _firstIndex = 1;
 133     NOT_PRODUCT(
 134       if (_spoolHead == NULL) {  // all buffers fully consumed
 135         assert(_spoolTail == NULL && _nextIndex == 1,
 136                "spool buffers processing inconsistency");
 137       }
 138     )
 139   }
 140   return hdr;
 141 }
 142 
 143 void PromotionInfo::track(PromotedObject* trackOop) {
 144   track(trackOop, oop(trackOop)->klass());
 145 }
 146 
 147 void PromotionInfo::track(PromotedObject* trackOop, Klass* klassOfOop) {
 148   // make a copy of header as it may need to be spooled
 149   markOop mark = oop(trackOop)->mark();
 150   trackOop->clear_next();
 151   if (mark->must_be_preserved_for_cms_scavenge(klassOfOop)) {
 152     // save non-prototypical header, and mark oop
 153     saveDisplacedHeader(mark);
 154     trackOop->setDisplacedMark();
 155   } else {
 156     // we'd like to assert something like the following:
 157     // assert(mark == markOopDesc::prototype(), "consistency check");
 158     // ... but the above won't work because the age bits have not (yet) been
 159     // cleared. The remainder of the check would be identical to the
 160     // condition checked in must_be_preserved() above, so we don't really
 161     // have anything useful to check here!
 162   }
 163   if (_promoTail != NULL) {
 164     assert(_promoHead != NULL, "List consistency");
 165     _promoTail->setNext(trackOop);
 166     _promoTail = trackOop;
 167   } else {
 168     assert(_promoHead == NULL, "List consistency");
 169     _promoHead = _promoTail = trackOop;


 269 
 270 // When _spoolTail is not NULL, then the slot <_spoolTail, _nextIndex>
 271 // points to the next slot available for filling.
 272 // The set of slots holding displaced headers are then all those in the
 273 // right-open interval denoted by:
 274 //
 275 //    [ <_spoolHead, _firstIndex>, <_spoolTail, _nextIndex> )
 276 //
 277 // When _spoolTail is NULL, then the set of slots with displaced headers
 278 // is all those starting at the slot <_spoolHead, _firstIndex> and
 279 // going up to the last slot of last block in the linked list.
 280 // In this latter case, _splice_point points to the tail block of
 281 // this linked list of blocks holding displaced headers.
 282 void PromotionInfo::verify() const {
 283   // Verify the following:
 284   // 1. the number of displaced headers matches the number of promoted
 285   //    objects that have displaced headers
 286   // 2. each promoted object lies in this space
 287   debug_only(
 288     PromotedObject* junk = NULL;
 289     assert(junk->next_addr() == (void*)(oop(junk)->mark_addr()),
 290            "Offset of PromotedObject::_next is expected to align with "
 291            "  the OopDesc::_mark within OopDesc");
 292   )
 293   // FIXME: guarantee????
 294   guarantee(_spoolHead == NULL || _spoolTail != NULL ||
 295             _splice_point != NULL, "list consistency");
 296   guarantee(_promoHead == NULL || _promoTail != NULL, "list consistency");
 297   // count the number of objects with displaced headers
 298   size_t numObjsWithDisplacedHdrs = 0;
 299   for (PromotedObject* curObj = _promoHead; curObj != NULL; curObj = curObj->next()) {
 300     guarantee(space()->is_in_reserved((HeapWord*)curObj), "Containment");
 301     // the last promoted object may fail the mark() != NULL test of is_oop().
 302     guarantee(curObj->next() == NULL || oopDesc::is_oop(oop(curObj)), "must be an oop");
 303     if (curObj->hasDisplacedMark()) {
 304       numObjsWithDisplacedHdrs++;
 305     }
 306   }
 307   // Count the number of displaced headers
 308   size_t numDisplacedHdrs = 0;
 309   for (SpoolBlock* curSpool = _spoolHead;


   1 /*
   2  * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
   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  *
  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  *


  67 // To aid verification and debugging, in the non-product builds
  68 // we actually forward _promoHead each time we process a promoted oop.
  69 // Note that this is not necessary in general (i.e. when we don't need to
  70 // call PromotionInfo::verify()) because oop_iterate can only add to the
  71 // end of _promoTail, and never needs to look at _promoHead.
  72 
  73 #define PROMOTED_OOPS_ITERATE_DEFN(OopClosureType, nv_suffix)               \
  74                                                                             \
  75 void PromotionInfo::promoted_oops_iterate##nv_suffix(OopClosureType* cl) {  \
  76   NOT_PRODUCT(verify());                                                    \
  77   PromotedObject *curObj, *nextObj;                                         \
  78   for (curObj = _promoHead; curObj != NULL; curObj = nextObj) {             \
  79     if ((nextObj = curObj->next()) == NULL) {                               \
  80       /* protect ourselves against additions due to closure application     \
  81          below by resetting the list.  */                                   \
  82       assert(_promoTail == curObj, "Should have been the tail");            \
  83       _promoHead = _promoTail = NULL;                                       \
  84     }                                                                       \
  85     if (curObj->hasDisplacedMark()) {                                       \
  86       /* restore displaced header */                                        \
  87       oop(curObj)->set_mark_raw(nextDisplacedHeader());                     \
  88     } else {                                                                \
  89       /* restore prototypical header */                                     \
  90       oop(curObj)->init_mark_raw();                                         \
  91     }                                                                       \
  92     /* The "promoted_mark" should now not be set */                         \
  93     assert(!curObj->hasPromotedMark(),                                      \
  94            "Should have been cleared by restoring displaced mark-word");    \
  95     NOT_PRODUCT(_promoHead = nextObj);                                      \
  96     if (cl != NULL) oop(curObj)->oop_iterate(cl);                           \
  97     if (nextObj == NULL) { /* start at head of list reset above */          \
  98       nextObj = _promoHead;                                                 \
  99     }                                                                       \
 100   }                                                                         \
 101   assert(noPromotions(), "post-condition violation");                       \
 102   assert(_promoHead == NULL && _promoTail == NULL, "emptied promoted list");\
 103   assert(_spoolHead == _spoolTail, "emptied spooling buffers");             \
 104   assert(_firstIndex == _nextIndex, "empty buffer");                        \
 105 }
 106 
 107 // This should have been ALL_SINCE_...() just like the others,
 108 // but, because the body of the method above is somehwat longer,
 109 // the MSVC compiler cannot cope; as a workaround, we split the
 110 // macro into its 3 constituent parts below (see original macro


 129     _spoolHead->nextSpoolBlock = _spareSpool;
 130     _spareSpool = _spoolHead;
 131     _spoolHead = tmp;
 132     _firstIndex = 1;
 133     NOT_PRODUCT(
 134       if (_spoolHead == NULL) {  // all buffers fully consumed
 135         assert(_spoolTail == NULL && _nextIndex == 1,
 136                "spool buffers processing inconsistency");
 137       }
 138     )
 139   }
 140   return hdr;
 141 }
 142 
 143 void PromotionInfo::track(PromotedObject* trackOop) {
 144   track(trackOop, oop(trackOop)->klass());
 145 }
 146 
 147 void PromotionInfo::track(PromotedObject* trackOop, Klass* klassOfOop) {
 148   // make a copy of header as it may need to be spooled
 149   markOop mark = oop(trackOop)->mark_raw();
 150   trackOop->clear_next();
 151   if (mark->must_be_preserved_for_cms_scavenge(klassOfOop)) {
 152     // save non-prototypical header, and mark oop
 153     saveDisplacedHeader(mark);
 154     trackOop->setDisplacedMark();
 155   } else {
 156     // we'd like to assert something like the following:
 157     // assert(mark == markOopDesc::prototype(), "consistency check");
 158     // ... but the above won't work because the age bits have not (yet) been
 159     // cleared. The remainder of the check would be identical to the
 160     // condition checked in must_be_preserved() above, so we don't really
 161     // have anything useful to check here!
 162   }
 163   if (_promoTail != NULL) {
 164     assert(_promoHead != NULL, "List consistency");
 165     _promoTail->setNext(trackOop);
 166     _promoTail = trackOop;
 167   } else {
 168     assert(_promoHead == NULL, "List consistency");
 169     _promoHead = _promoTail = trackOop;


 269 
 270 // When _spoolTail is not NULL, then the slot <_spoolTail, _nextIndex>
 271 // points to the next slot available for filling.
 272 // The set of slots holding displaced headers are then all those in the
 273 // right-open interval denoted by:
 274 //
 275 //    [ <_spoolHead, _firstIndex>, <_spoolTail, _nextIndex> )
 276 //
 277 // When _spoolTail is NULL, then the set of slots with displaced headers
 278 // is all those starting at the slot <_spoolHead, _firstIndex> and
 279 // going up to the last slot of last block in the linked list.
 280 // In this latter case, _splice_point points to the tail block of
 281 // this linked list of blocks holding displaced headers.
 282 void PromotionInfo::verify() const {
 283   // Verify the following:
 284   // 1. the number of displaced headers matches the number of promoted
 285   //    objects that have displaced headers
 286   // 2. each promoted object lies in this space
 287   debug_only(
 288     PromotedObject* junk = NULL;
 289     assert(junk->next_addr() == (void*)(oop(junk)->mark_addr_raw()),
 290            "Offset of PromotedObject::_next is expected to align with "
 291            "  the OopDesc::_mark within OopDesc");
 292   )
 293   // FIXME: guarantee????
 294   guarantee(_spoolHead == NULL || _spoolTail != NULL ||
 295             _splice_point != NULL, "list consistency");
 296   guarantee(_promoHead == NULL || _promoTail != NULL, "list consistency");
 297   // count the number of objects with displaced headers
 298   size_t numObjsWithDisplacedHdrs = 0;
 299   for (PromotedObject* curObj = _promoHead; curObj != NULL; curObj = curObj->next()) {
 300     guarantee(space()->is_in_reserved((HeapWord*)curObj), "Containment");
 301     // the last promoted object may fail the mark() != NULL test of is_oop().
 302     guarantee(curObj->next() == NULL || oopDesc::is_oop(oop(curObj)), "must be an oop");
 303     if (curObj->hasDisplacedMark()) {
 304       numObjsWithDisplacedHdrs++;
 305     }
 306   }
 307   // Count the number of displaced headers
 308   size_t numDisplacedHdrs = 0;
 309   for (SpoolBlock* curSpool = _spoolHead;


< prev index next >