< prev index next >

src/hotspot/share/gc/z/zHeapIterator.cpp

Print this page


   1 /*
   2  * Copyright (c) 2017, 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  */


 106 #ifdef ASSERT
 107   virtual bool should_verify_oops() {
 108     return false;
 109   }
 110 #endif
 111 };
 112 
 113 ZHeapIterator::ZHeapIterator(bool visit_referents) :
 114     _visit_stack(),
 115     _visit_map(),
 116     _visit_referents(visit_referents) {}
 117 
 118 ZHeapIterator::~ZHeapIterator() {
 119   ZVisitMapIterator iter(&_visit_map);
 120   for (ZHeapIteratorBitMap* map; iter.next(&map);) {
 121     delete map;
 122   }
 123 }
 124 
 125 static size_t object_index_max() {
 126   return ZPageSizeMin >> ZObjectAlignmentSmallShift;
 127 }
 128 
 129 static size_t object_index(oop obj) {
 130   const uintptr_t addr = ZOop::to_address(obj);
 131   const uintptr_t offset = ZAddress::offset(addr);
 132   const uintptr_t mask = (1 << ZPageSizeMinShift) - 1;
 133   return (offset & mask) >> ZObjectAlignmentSmallShift;
 134 }
 135 
 136 ZHeapIteratorBitMap* ZHeapIterator::object_map(oop obj) {
 137   const uintptr_t addr = ZOop::to_address(obj);
 138   ZHeapIteratorBitMap* map = _visit_map.get(addr);
 139   if (map == NULL) {
 140     map = new ZHeapIteratorBitMap(object_index_max());
 141     _visit_map.put(addr, map);
 142   }
 143 
 144   return map;
 145 }
 146 
 147 void ZHeapIterator::push(oop obj) {
 148   if (obj == NULL) {
 149     // Ignore
 150     return;
 151   }
 152 


   1 /*
   2  * Copyright (c) 2017, 2019, 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  */


 106 #ifdef ASSERT
 107   virtual bool should_verify_oops() {
 108     return false;
 109   }
 110 #endif
 111 };
 112 
 113 ZHeapIterator::ZHeapIterator(bool visit_referents) :
 114     _visit_stack(),
 115     _visit_map(),
 116     _visit_referents(visit_referents) {}
 117 
 118 ZHeapIterator::~ZHeapIterator() {
 119   ZVisitMapIterator iter(&_visit_map);
 120   for (ZHeapIteratorBitMap* map; iter.next(&map);) {
 121     delete map;
 122   }
 123 }
 124 
 125 static size_t object_index_max() {
 126   return ZGranuleSize >> ZObjectAlignmentSmallShift;
 127 }
 128 
 129 static size_t object_index(oop obj) {
 130   const uintptr_t addr = ZOop::to_address(obj);
 131   const uintptr_t offset = ZAddress::offset(addr);
 132   const uintptr_t mask = ZGranuleSize - 1;
 133   return (offset & mask) >> ZObjectAlignmentSmallShift;
 134 }
 135 
 136 ZHeapIteratorBitMap* ZHeapIterator::object_map(oop obj) {
 137   const uintptr_t addr = ZOop::to_address(obj);
 138   ZHeapIteratorBitMap* map = _visit_map.get(addr);
 139   if (map == NULL) {
 140     map = new ZHeapIteratorBitMap(object_index_max());
 141     _visit_map.put(addr, map);
 142   }
 143 
 144   return map;
 145 }
 146 
 147 void ZHeapIterator::push(oop obj) {
 148   if (obj == NULL) {
 149     // Ignore
 150     return;
 151   }
 152 


< prev index next >