< prev index next >

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

Print this page




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/cms/compactibleFreeListSpace.hpp"
  27 #include "gc/cms/promotionInfo.hpp"
  28 #include "gc/shared/genOopClosures.hpp"

  29 #include "oops/markOop.inline.hpp"
  30 #include "oops/oop.inline.hpp"
  31 
  32 /////////////////////////////////////////////////////////////////////////
  33 //// PromotionInfo
  34 /////////////////////////////////////////////////////////////////////////
  35 
  36 
  37 PromotedObject* PromotedObject::next() const {
  38   assert(!((FreeChunk*)this)->is_free(), "Error");
  39   PromotedObject* res;
  40   if (UseCompressedOops) {
  41     // The next pointer is a compressed oop stored in the top 32 bits
  42     res = (PromotedObject*)oopDesc::decode_heap_oop(_data._narrow_next);
  43   } else {
  44     res = (PromotedObject*)(_next & next_mask);
  45   }
  46   assert(oopDesc::is_oop_or_null(oop(res), true /* ignore mark word */), "Expected an oop or NULL at " PTR_FORMAT, p2i(oop(res)));
  47   return res;
  48 }
  49 
  50 inline void PromotedObject::setNext(PromotedObject* x) {
  51   assert(((intptr_t)x & ~next_mask) == 0, "Conflict in bit usage, "
  52          "or insufficient alignment of objects");
  53   if (UseCompressedOops) {
  54     assert(_data._narrow_next == 0, "Overwrite?");
  55     _data._narrow_next = oopDesc::encode_heap_oop(oop(x));
  56   } else {
  57     _next |= (intptr_t)x;
  58   }
  59   assert(!((FreeChunk*)this)->is_free(), "Error");
  60 }
  61 
  62 //////////////////////////////////////////////////////////////////////////////
  63 // We go over the list of promoted objects, removing each from the list,
  64 // and applying the closure (this may, in turn, add more elements to
  65 // the tail of the promoted list, and these newly added objects will
  66 // also be processed) until the list is empty.
  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) {  \




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/cms/compactibleFreeListSpace.hpp"
  27 #include "gc/cms/promotionInfo.hpp"
  28 #include "gc/shared/genOopClosures.hpp"
  29 #include "oops/compressedOops.inline.hpp"
  30 #include "oops/markOop.inline.hpp"
  31 #include "oops/oop.hpp"
  32 
  33 /////////////////////////////////////////////////////////////////////////
  34 //// PromotionInfo
  35 /////////////////////////////////////////////////////////////////////////
  36 
  37 
  38 PromotedObject* PromotedObject::next() const {
  39   assert(!((FreeChunk*)this)->is_free(), "Error");
  40   PromotedObject* res;
  41   if (UseCompressedOops) {
  42     // The next pointer is a compressed oop stored in the top 32 bits
  43     res = (PromotedObject*)CompressedOops::decode(_data._narrow_next);
  44   } else {
  45     res = (PromotedObject*)(_next & next_mask);
  46   }
  47   assert(oopDesc::is_oop_or_null(oop(res), true /* ignore mark word */), "Expected an oop or NULL at " PTR_FORMAT, p2i(oop(res)));
  48   return res;
  49 }
  50 
  51 inline void PromotedObject::setNext(PromotedObject* x) {
  52   assert(((intptr_t)x & ~next_mask) == 0, "Conflict in bit usage, "
  53          "or insufficient alignment of objects");
  54   if (UseCompressedOops) {
  55     assert(_data._narrow_next == 0, "Overwrite?");
  56     _data._narrow_next = CompressedOops::encode(oop(x));
  57   } else {
  58     _next |= (intptr_t)x;
  59   }
  60   assert(!((FreeChunk*)this)->is_free(), "Error");
  61 }
  62 
  63 //////////////////////////////////////////////////////////////////////////////
  64 // We go over the list of promoted objects, removing each from the list,
  65 // and applying the closure (this may, in turn, add more elements to
  66 // the tail of the promoted list, and these newly added objects will
  67 // also be processed) until the list is empty.
  68 // To aid verification and debugging, in the non-product builds
  69 // we actually forward _promoHead each time we process a promoted oop.
  70 // Note that this is not necessary in general (i.e. when we don't need to
  71 // call PromotionInfo::verify()) because oop_iterate can only add to the
  72 // end of _promoTail, and never needs to look at _promoHead.
  73 
  74 #define PROMOTED_OOPS_ITERATE_DEFN(OopClosureType, nv_suffix)               \
  75                                                                             \
  76 void PromotionInfo::promoted_oops_iterate##nv_suffix(OopClosureType* cl) {  \


< prev index next >