/* * Copyright (c) 2015, 2020, 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_GC_Z_ZROOTSITERATOR_HPP #define SHARE_GC_Z_ZROOTSITERATOR_HPP #include "gc/shared/oopStorageParState.hpp" #include "gc/shared/oopStorageSetParState.hpp" #include "gc/shared/suspendibleThreadSet.hpp" #include "memory/allocation.hpp" #include "memory/iterator.hpp" #include "runtime/thread.hpp" #include "runtime/threadSMR.hpp" #include "utilities/globalDefinitions.hpp" class ZRootsIteratorClosure; typedef OopStorage::ParState ZOopStorageIterator; typedef OopStorageSetStrongParState ZOopStorageSetIterator; template class ZSerialOopsDo { private: T* const _iter; volatile bool _claimed; public: ZSerialOopsDo(T* iter); void oops_do(ZRootsIteratorClosure* cl); }; template class ZParallelOopsDo { private: T* const _iter; volatile bool _completed; public: ZParallelOopsDo(T* iter); void oops_do(ZRootsIteratorClosure* cl); }; template class ZSerialWeakOopsDo { private: T* const _iter; volatile bool _claimed; public: ZSerialWeakOopsDo(T* iter); void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl); }; template class ZParallelWeakOopsDo { private: T* const _iter; volatile bool _completed; public: ZParallelWeakOopsDo(T* iter); void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl); }; class ZRootsIteratorClosure : public OopClosure { public: virtual void do_thread(Thread* thread) {} virtual bool should_disarm_nmethods() const { return false; } }; class ZJavaThreadsIterator { private: ThreadsListHandle _threads; volatile uint _claimed; uint claim(); public: ZJavaThreadsIterator(); void threads_do(ThreadClosure* cl); }; class ZRootsIterator { private: const bool _visit_jvmti_weak_export; ZJavaThreadsIterator _java_threads_iter; void do_universe(ZRootsIteratorClosure* cl); void do_object_synchronizer(ZRootsIteratorClosure* cl); void do_management(ZRootsIteratorClosure* cl); void do_jvmti_export(ZRootsIteratorClosure* cl); void do_jvmti_weak_export(ZRootsIteratorClosure* cl); void do_vm_thread(ZRootsIteratorClosure* cl); void do_java_threads(ZRootsIteratorClosure* cl); void do_code_cache(ZRootsIteratorClosure* cl); ZSerialOopsDo _universe; ZSerialOopsDo _object_synchronizer; ZSerialOopsDo _management; ZSerialOopsDo _jvmti_export; ZSerialOopsDo _jvmti_weak_export; ZSerialOopsDo _vm_thread; ZParallelOopsDo _java_threads; ZParallelOopsDo _code_cache; public: ZRootsIterator(bool visit_jvmti_weak_export = false); ~ZRootsIterator(); void oops_do(ZRootsIteratorClosure* cl); }; class ZConcurrentRootsIterator { private: ZOopStorageSetIterator _oop_storage_set_iter; const int _cld_claim; void do_oop_storage_set(ZRootsIteratorClosure* cl); void do_class_loader_data_graph(ZRootsIteratorClosure* cl); ZParallelOopsDo _oop_storage_set; ZParallelOopsDo _class_loader_data_graph; public: ZConcurrentRootsIterator(int cld_claim); ~ZConcurrentRootsIterator(); void oops_do(ZRootsIteratorClosure* cl); }; class ZConcurrentRootsIteratorClaimStrong : public ZConcurrentRootsIterator { public: ZConcurrentRootsIteratorClaimStrong() : ZConcurrentRootsIterator(ClassLoaderData::_claim_strong) {} }; class ZConcurrentRootsIteratorClaimOther : public ZConcurrentRootsIterator { public: ZConcurrentRootsIteratorClaimOther() : ZConcurrentRootsIterator(ClassLoaderData::_claim_other) {} }; class ZConcurrentRootsIteratorClaimNone : public ZConcurrentRootsIterator { public: ZConcurrentRootsIteratorClaimNone() : ZConcurrentRootsIterator(ClassLoaderData::_claim_none) {} }; class ZWeakRootsIterator { private: void do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl); void do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl); ZSerialWeakOopsDo _jvmti_weak_export; ZSerialWeakOopsDo _jfr_weak; public: ZWeakRootsIterator(); ~ZWeakRootsIterator(); void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl); void oops_do(ZRootsIteratorClosure* cl); }; class ZConcurrentWeakRootsIterator { private: ZOopStorageIterator _vm_weak_handles_iter; ZOopStorageIterator _jni_weak_handles_iter; ZOopStorageIterator _string_table_iter; ZOopStorageIterator _resolved_method_table_iter; void do_vm_weak_handles(ZRootsIteratorClosure* cl); void do_jni_weak_handles(ZRootsIteratorClosure* cl); void do_string_table(ZRootsIteratorClosure* cl); void do_resolved_method_table(ZRootsIteratorClosure* cl); ZParallelOopsDo _vm_weak_handles; ZParallelOopsDo _jni_weak_handles; ZParallelOopsDo _string_table; ZParallelOopsDo _resolved_method_table; public: ZConcurrentWeakRootsIterator(); ~ZConcurrentWeakRootsIterator(); void oops_do(ZRootsIteratorClosure* cl); }; #endif // SHARE_GC_Z_ZROOTSITERATOR_HPP