< 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);

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

  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);

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