/* * Copyright (c) 2011, 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_MEMORY_SPECIALIZED_OOP_CLOSURES_INLINE_HPP #define SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_INLINE_HPP #include "utilities/templateIdioms.hpp" #include "memory/specialized_oop_closures.hpp" template inline typename enable_if::value, void>::type OopClosureDispatcher::do_oop_internal_try_v(OopClosureType *cl, OopType *obj) { cl->do_oop(obj); } template inline typename enable_if::value, void>::type OopClosureDispatcher::do_oop_internal_try_v(OopClosureType *cl, OopType *obj) { cl->OopClosureType::do_oop(obj); } template inline typename enable_if::value, void>::type OopClosureDispatcher::do_oop_internal_try_nv(OopClosureType *cl, OopType *obj) { do_oop_internal_try_v(cl, obj); } template inline typename enable_if::value, void>::type OopClosureDispatcher::do_oop_internal_try_nv(OopClosureType *cl, OopType *obj) { // Backward-compatibility - if do_oop_nv is declared, use it cl->do_oop_nv(obj); } template inline void OopClosureDispatcher::do_oop_internal(OopClosureType *cl, OopType *obj) { do_oop_internal_try_nv(cl, obj); } #define OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_OOP_DEF(OopClosureType, OopType) \ template <> \ inline void \ OopClosureDispatcher::do_oop_internal(OopClosureType *cl, OopType *obj) { \ reinterpret_cast(cl)->do_oop(obj); \ } #define OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_OOP_ALL(OopClosureType) \ OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_OOP_DEF(OopClosureType, narrowOop) \ OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_OOP_DEF(OopClosureType, oop) UNSPECIALIZED_OOP_OOP_ITERATE_CLOSURES(OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_OOP_ALL) template inline typename enable_if::value, bool>::type OopClosureDispatcher::do_metadata_internal_try_v(OopClosureType *cl) { return cl->OopClosureType::do_metadata(); } template inline typename enable_if::value, bool>::type OopClosureDispatcher::do_metadata_internal_try_v(OopClosureType *cl) { return cl->do_metadata(); } // Use _nv call if declared for backward compatibility template inline typename enable_if::value, bool>::type OopClosureDispatcher::do_metadata_internal_try_nv(OopClosureType *cl) { return cl->OopClosureType::do_metadata_nv(); } // Non-virtualize virtual call if _nv is not declared template inline typename enable_if::value, bool>::type OopClosureDispatcher::do_metadata_internal_try_nv(OopClosureType *cl) { return do_metadata_internal_try_v(cl); } template inline bool OopClosureDispatcher::do_metadata_internal(OopClosureType *cl) { return do_metadata_internal_try_nv(cl); } #define OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_METADATA_DEF(OopClosureType) \ template <> \ inline bool \ OopClosureDispatcher::do_metadata_internal(OopClosureType *cl) { \ return reinterpret_cast(cl)->do_metadata(); \ } UNSPECIALIZED_DO_METADATA_CLOSURES(OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_METADATA_DEF) // call _nv for backward compatibility - it is expected to be called if it exists template inline typename enable_if::value, void>::type OopClosureDispatcher::do_klass_internal_try_v(OopClosureType *cl, Klass *klass) { cl->OopClosureType::do_klass(klass); } // non-virtualize the virtual call if _nv is not expected template inline typename enable_if::value, void>::type OopClosureDispatcher::do_klass_internal_try_v(OopClosureType *cl, Klass *klass) { cl->do_klass(klass); } // call _nv for backward compatibility - it is expected to be called if it exists template inline typename enable_if::value, void>::type OopClosureDispatcher::do_klass_internal_try_nv(OopClosureType *cl, Klass *klass) { cl->do_klass_nv(klass); } // non-virtualize the virtual call if _nv is not expected template inline typename enable_if::value, void>::type OopClosureDispatcher::do_klass_internal_try_nv(OopClosureType *cl, Klass *klass) { do_klass_internal_try_v(cl, klass); } template inline void OopClosureDispatcher::do_klass_internal(OopClosureType *cl, Klass *klass) { do_klass_internal_try_nv(cl, klass); } #define OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_KLASS_DEF(OopClosureType) \ template <> \ inline void \ OopClosureDispatcher::do_klass_internal(OopClosureType *cl, Klass *klass) { \ reinterpret_cast(cl)->do_klass(klass); \ } UNSPECIALIZED_DO_METADATA_CLOSURES(OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_KLASS_DEF) // non-virtualize the virtual call if the declared type also declared the member function // note that if a super class declared it, we can't safely remove virtual call template inline typename enable_if::value, void>::type OopClosureDispatcher::do_class_loader_data_internal_try_v(OopClosureType *cl, ClassLoaderData *cld) { cl->OopClosureType::do_class_loader_data(cld); } template inline typename enable_if::value, void>::type OopClosureDispatcher::do_class_loader_data_internal_try_v(OopClosureType *cl, ClassLoaderData *cld) { cl->do_class_loader_data(cld); } // call _nv for backward compatibility - it is expected to be called if it exists template inline typename enable_if::value, void>::type OopClosureDispatcher::do_class_loader_data_internal_try_nv(OopClosureType *cl, ClassLoaderData *cld) { cl->do_class_loader_data_nv(cld); } // non-virtualize the virtual call if _nv is not expected template inline typename enable_if::value, void>::type OopClosureDispatcher::do_class_loader_data_internal_try_nv(OopClosureType *cl, ClassLoaderData *cld) { do_class_loader_data_internal_try_v(cl, cld); } template inline void OopClosureDispatcher::do_class_loader_data_internal(OopClosureType *cl, ClassLoaderData *cld) { do_class_loader_data_internal_try_nv(cl, cld); } #define OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_CLD_DEF(OopClosureType) \ template <> \ inline void \ OopClosureDispatcher::do_class_loader_data_internal(OopClosureType *cl, ClassLoaderData *cld) { \ reinterpret_cast(cl)->do_class_loader_data(cld); \ } UNSPECIALIZED_DO_METADATA_CLOSURES(OOP_CLOSURE_DISPATCHER_UNSPECIALIZED_DO_CLD_DEF) // Make sure we only dispatch to OopClosure subtypes, otherwise compiler error template inline typename enable_if::value, void>::type OopClosureDispatcher::do_oop(OopClosureType *cl, OopType *obj) { do_oop_internal(cl, obj); } // Only do metadata stuff on ExtendedOopClosure, otherwise compiler error template inline typename enable_if::value, bool>::type OopClosureDispatcher::do_metadata(OopClosureType *cl) { return do_metadata_internal(cl); } template inline typename enable_if::value, void>::type OopClosureDispatcher::do_klass(OopClosureType *cl, Klass *klass) { do_klass_internal(cl, klass); } template inline typename enable_if::value, void>::type OopClosureDispatcher::do_class_loader_data(OopClosureType *cl, ClassLoaderData *cld) { do_class_loader_data_internal(cl, cld); } #endif // SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_INLINE_HPP