1 /* 2 * Copyright (c) 1997, 2014, 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 * 23 */ 24 25 #ifndef SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP 26 #define SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP 27 28 #include "oops/instanceKlass.hpp" 29 #include "classfile/javaClasses.hpp" 30 #include "classfile/systemDictionary.hpp" 31 32 #ifdef ASSERT 33 template <class T> inline void InstanceKlass::assert_is_in(T *p) { 34 T heap_oop = oopDesc::load_heap_oop(p); 35 if (!oopDesc::is_null(heap_oop)) { 36 oop o = oopDesc::decode_heap_oop_not_null(heap_oop); 37 assert(Universe::heap()->is_in(o), "should be in heap"); 38 } 39 } 40 template <class T> inline void InstanceKlass::assert_is_in_closed_subset(T *p) { 41 T heap_oop = oopDesc::load_heap_oop(p); 42 if (!oopDesc::is_null(heap_oop)) { 43 oop o = oopDesc::decode_heap_oop_not_null(heap_oop); 44 assert(Universe::heap()->is_in_closed_subset(o), 45 err_msg("should be in closed *p " INTPTR_FORMAT " " INTPTR_FORMAT, (address)p, (address)o)); 46 } 47 } 48 template <class T> inline void InstanceKlass::assert_is_in_reserved(T *p) { 49 T heap_oop = oopDesc::load_heap_oop(p); 50 if (!oopDesc::is_null(heap_oop)) { 51 oop o = oopDesc::decode_heap_oop_not_null(heap_oop); 52 assert(Universe::heap()->is_in_reserved(o), "should be in reserved"); 53 } 54 } 55 template <class T> inline void InstanceKlass::assert_nothing(T *p) {} 56 57 #else 58 template <class T> inline void InstanceKlass::assert_is_in(T *p) {} 59 template <class T> inline void InstanceKlass::assert_is_in_closed_subset(T *p) {} 60 template <class T> inline void InstanceKlass::assert_is_in_reserved(T *p) {} 61 template <class T> inline void InstanceKlass::assert_nothing(T *p) {} 62 #endif // ASSERT 63 64 65 template<class OopType, class OopClosureType> 66 void InstanceKlass::oop_iterate_and_dispatch_helper(oop obj, OopClosureType *closure, OopType *start, int count) { 67 OopType *current = start; 68 OopType* const end = current + count; 69 while (current < end) { 70 assert_is_in_closed_subset(current); 71 OopClosureDispatcher::do_oop<OopClosureType, OopType>(closure, current); 72 current++; 73 } 74 } 75 76 template <class OopClosureType> 77 int InstanceKlass::oop_iterate_and_dispatch(oop obj, OopClosureType *closure) { 78 SpecializationStats::record_iterate_call_nv(SpecializationStats::ik); 79 80 // Don't do metadata, let subclasses as only subclasses use this method. 81 82 OopMapBlock* map = start_of_nonstatic_oop_maps(); 83 OopMapBlock* const end_map = map + nonstatic_oop_map_count(); 84 if (UseCompressedOops) { 85 while (map < end_map) { 86 oop_iterate_and_dispatch_helper<narrowOop, OopClosureType>(obj, closure, (narrowOop*)obj->obj_field_addr<narrowOop>(map->offset()), map->count()); 87 ++map; 88 } 89 } else { 90 while (map < end_map) { 91 oop_iterate_and_dispatch_helper<oop, OopClosureType>(obj, closure, (oop*)obj->obj_field_addr<oop>(map->offset()), map->count()); 92 ++map; 93 } 94 } 95 96 return size_helper(); 97 } 98 99 #endif // SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP 100