/* * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #ifndef SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP #define SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP #include "oops/instanceKlass.hpp" #include "classfile/javaClasses.hpp" #include "classfile/systemDictionary.hpp" #ifdef ASSERT template inline void InstanceKlass::assert_is_in(T *p) { T heap_oop = oopDesc::load_heap_oop(p); if (!oopDesc::is_null(heap_oop)) { oop o = oopDesc::decode_heap_oop_not_null(heap_oop); assert(Universe::heap()->is_in(o), "should be in heap"); } } template inline void InstanceKlass::assert_is_in_closed_subset(T *p) { T heap_oop = oopDesc::load_heap_oop(p); if (!oopDesc::is_null(heap_oop)) { oop o = oopDesc::decode_heap_oop_not_null(heap_oop); assert(Universe::heap()->is_in_closed_subset(o), err_msg("should be in closed *p " INTPTR_FORMAT " " INTPTR_FORMAT, (address)p, (address)o)); } } template inline void InstanceKlass::assert_is_in_reserved(T *p) { T heap_oop = oopDesc::load_heap_oop(p); if (!oopDesc::is_null(heap_oop)) { oop o = oopDesc::decode_heap_oop_not_null(heap_oop); assert(Universe::heap()->is_in_reserved(o), "should be in reserved"); } } template inline void InstanceKlass::assert_nothing(T *p) {} #else template inline void InstanceKlass::assert_is_in(T *p) {} template inline void InstanceKlass::assert_is_in_closed_subset(T *p) {} template inline void InstanceKlass::assert_is_in_reserved(T *p) {} template inline void InstanceKlass::assert_nothing(T *p) {} #endif // ASSERT template void InstanceKlass::oop_iterate_and_dispatch_helper(oop obj, OopClosureType *closure, OopType *start, int count) { OopType *current = start; OopType* const end = current + count; while (current < end) { assert_is_in_closed_subset(current); OopClosureDispatcher::do_oop(closure, current); current++; } } template int InstanceKlass::oop_iterate_and_dispatch(oop obj, OopClosureType *closure) { SpecializationStats::record_iterate_call_nv(SpecializationStats::ik); // Don't do metadata, let subclasses as only subclasses use this method. OopMapBlock* map = start_of_nonstatic_oop_maps(); OopMapBlock* const end_map = map + nonstatic_oop_map_count(); if (UseCompressedOops) { while (map < end_map) { oop_iterate_and_dispatch_helper(obj, closure, (narrowOop*)obj->obj_field_addr(map->offset()), map->count()); ++map; } } else { while (map < end_map) { oop_iterate_and_dispatch_helper(obj, closure, (oop*)obj->obj_field_addr(map->offset()), map->count()); ++map; } } return size_helper(); } #endif // SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP