/* * 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_INSTANCEMIRRORKLASS_INLINE_HPP #define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP #include "utilities/templateIdioms.hpp" #include "oops/instanceMirrorKlass.hpp" #include "oops/instanceKlass.inline.hpp" inline void InstanceMirrorKlass::init_offset_of_static_fields() { // Cache the offset of the static fields in the Class instance assert(_offset_of_static_fields == 0, "once"); _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize; } // Make sure metadata only gets dispatched for ExtendedOopClosure using SFINAE template inline typename enable_if::value, void>::type InstanceMirrorKlass::do_metadata_if_applicable(oop obj, OopClosureType *cl) { if (OopClosureDispatcher::do_metadata(cl)) { OopClosureDispatcher::do_klass(cl, obj->klass()); } } // Some dispatch functions for auto dispatching template inline void InstanceMirrorKlass::oop_iterate_and_dispatch_helper(oop obj, OopClosureType *closure) { OopType *current = (OopType*)start_of_static_fields(obj); OopType* const end = current + java_lang_Class::static_oop_field_count(obj); while (current < end) { assert_is_in_closed_subset(current); OopClosureDispatcher::do_oop(closure, current); current++; } } // Auto specailization template inline int InstanceMirrorKlass::oop_iterate_and_dispatch(oop obj, OopClosureType *cl) { SpecializationStats::record_iterate_call_nv(SpecializationStats::irk); InstanceKlass::oop_iterate_and_dispatch(obj, cl); do_metadata_if_applicable(obj, cl); if (UseCompressedOops) { oop_iterate_and_dispatch_helper(obj, cl); return oop_size(obj); } else { oop_iterate_and_dispatch_helper(obj, cl); return oop_size(obj); } } #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP