< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp

Print this page

  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  *
 23  */
 24 
 25 
 26 #include "gc/shenandoah/shenandoahAsserts.hpp"
 27 #include "gc/shenandoah/shenandoahForwarding.hpp"
 28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 29 #include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"
 30 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
 31 #include "gc/shenandoah/shenandoahUtils.hpp"
 32 #include "memory/resourceArea.hpp"
 33 #include "oops/oop.inline.hpp"
 34 #include "runtime/os.hpp"
 35 #include "utilities/vmError.hpp"
 36 
 37 void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
 38   // Be extra safe. Only access data that is guaranteed to be safe:
 39   // should be in heap, in known committed region, within that region.
 40 
 41   ShenandoahHeap* heap = ShenandoahHeap::heap();
 42   if (!heap->is_in_reserved(loc)) return;
 43 
 44   ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
 45   if (r != nullptr && r->is_committed()) {
 46     address start = MAX2((address) r->bottom(), (address) loc - 32);
 47     address end   = MIN2((address) r->end(),    (address) loc + 128);

556     }
557   }
558 
559   ShenandoahMessageBuffer msg("Must be either control thread, or vm thread");
560   if (at_safepoint) {
561     msg.append(" at a safepoint");
562   }
563   report_vm_error(file, line, msg.buffer());
564 }
565 
566 bool ShenandoahAsserts::extract_klass_safely(oop obj, narrowKlass& nk, const Klass*& k) {
567   nk = 0;
568   k = nullptr;
569 
570   if (!os::is_readable_pointer(obj)) {
571     return false;
572   }
573 
574   if (UseCompactObjectHeaders) { // look in forwardee
575     markWord mark = obj->mark();
576     if (mark.is_marked()) {
577       oop fwd = cast_to_oop(mark.clear_lock_bits().to_pointer());
578       if (!os::is_readable_pointer(fwd)) {
579         return false;
580       }
581       mark = fwd->mark();
582     }
583     nk = mark.narrow_klass();
584   } else {
585     nk = obj->narrow_klass();
586   }
587   if (!CompressedKlassPointers::is_valid_narrow_klass_id(nk)) {
588     return false;
589   }
590   k = CompressedKlassPointers::decode_not_null_without_asserts(nk);
591 
592   return k != nullptr;
593 }

  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  *
 23  */
 24 
 25 
 26 #include "gc/shenandoah/shenandoahAsserts.hpp"
 27 #include "gc/shenandoah/shenandoahForwarding.inline.hpp"
 28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 29 #include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"
 30 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
 31 #include "gc/shenandoah/shenandoahUtils.hpp"
 32 #include "memory/resourceArea.hpp"
 33 #include "oops/oop.inline.hpp"
 34 #include "runtime/os.hpp"
 35 #include "utilities/vmError.hpp"
 36 
 37 void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
 38   // Be extra safe. Only access data that is guaranteed to be safe:
 39   // should be in heap, in known committed region, within that region.
 40 
 41   ShenandoahHeap* heap = ShenandoahHeap::heap();
 42   if (!heap->is_in_reserved(loc)) return;
 43 
 44   ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
 45   if (r != nullptr && r->is_committed()) {
 46     address start = MAX2((address) r->bottom(), (address) loc - 32);
 47     address end   = MIN2((address) r->end(),    (address) loc + 128);

556     }
557   }
558 
559   ShenandoahMessageBuffer msg("Must be either control thread, or vm thread");
560   if (at_safepoint) {
561     msg.append(" at a safepoint");
562   }
563   report_vm_error(file, line, msg.buffer());
564 }
565 
566 bool ShenandoahAsserts::extract_klass_safely(oop obj, narrowKlass& nk, const Klass*& k) {
567   nk = 0;
568   k = nullptr;
569 
570   if (!os::is_readable_pointer(obj)) {
571     return false;
572   }
573 
574   if (UseCompactObjectHeaders) { // look in forwardee
575     markWord mark = obj->mark();
576     if (ShenandoahForwarding::has_forwardee(mark)) {
577       oop fwd = cast_to_oop(mark.clear_lock_bits().to_pointer());
578       if (!os::is_readable_pointer(fwd)) {
579         return false;
580       }
581       mark = fwd->mark();
582     }
583     nk = mark.narrow_klass();
584   } else {
585     nk = obj->narrow_klass();
586   }
587   if (!CompressedKlassPointers::is_valid_narrow_klass_id(nk)) {
588     return false;
589   }
590   k = CompressedKlassPointers::decode_not_null_without_asserts(nk);
591 
592   return k != nullptr;
593 }
< prev index next >