1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp Mon Dec 01 15:24:56 2014 +0100 1.3 @@ -0,0 +1,116 @@ 1.4 +/* 1.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP 1.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP 1.30 + 1.31 +#include "memory/allocation.hpp" 1.32 +#include "memory/sharedHeap.hpp" 1.33 +#include "runtime/mutex.hpp" 1.34 + 1.35 +class CLDClosure; 1.36 +class CodeBlobClosure; 1.37 +class G1CollectedHeap; 1.38 +class G1ParPushHeapRSClosure; 1.39 +class Monitor; 1.40 +class OopClosure; 1.41 +class SubTasksDone; 1.42 + 1.43 +// Scoped object to assist in applying oop, CLD and code blob closures to 1.44 +// root locations. Handles claiming of different root scanning tasks 1.45 +// and takes care of global state for root scanning via a StrongRootsScope. 1.46 +// In the parallel case there is a shared G1RootProcessor object where all 1.47 +// worker thread call the process_roots methods. 1.48 +class G1RootProcessor : public StackObj { 1.49 + G1CollectedHeap* _g1h; 1.50 + SubTasksDone* _process_strong_tasks; 1.51 + SharedHeap::StrongRootsScope _srs; 1.52 + 1.53 + // Used to implement the Thread work barrier. 1.54 + Monitor _lock; 1.55 + volatile jint _n_workers_discovered_strong_classes; 1.56 + 1.57 + enum G1H_process_roots_tasks { 1.58 + G1RP_PS_Universe_oops_do, 1.59 + G1RP_PS_JNIHandles_oops_do, 1.60 + G1RP_PS_ObjectSynchronizer_oops_do, 1.61 + G1RP_PS_FlatProfiler_oops_do, 1.62 + G1RP_PS_Management_oops_do, 1.63 + G1RP_PS_SystemDictionary_oops_do, 1.64 + G1RP_PS_ClassLoaderDataGraph_oops_do, 1.65 + G1RP_PS_jvmti_oops_do, 1.66 + G1RP_PS_CodeCache_oops_do, 1.67 + G1RP_PS_filter_satb_buffers, 1.68 + G1RP_PS_refProcessor_oops_do, 1.69 + // Leave this one last. 1.70 + G1RP_PS_NumElements 1.71 + }; 1.72 + 1.73 + void worker_has_discovered_all_strong_classes(); 1.74 + void wait_until_all_strong_classes_discovered(); 1.75 + 1.76 + void process_java_roots(OopClosure* scan_non_heap_roots, 1.77 + CLDClosure* thread_stack_clds, 1.78 + CLDClosure* scan_strong_clds, 1.79 + CLDClosure* scan_weak_clds, 1.80 + CodeBlobClosure* scan_strong_code); 1.81 + 1.82 + void process_vm_roots(OopClosure* scan_non_heap_roots, 1.83 + OopClosure* scan_non_heap_weak_roots); 1.84 + 1.85 +public: 1.86 + G1RootProcessor(G1CollectedHeap* g1h); 1.87 + 1.88 + // Apply closures to the strongly and weakly reachable roots in the system 1.89 + // in a single pass. 1.90 + // Record and report timing measurements for sub phases using the worker_i 1.91 + void evacuate_roots(OopClosure* scan_non_heap_roots, 1.92 + OopClosure* scan_non_heap_weak_roots, 1.93 + CLDClosure* scan_strong_clds, 1.94 + CLDClosure* scan_weak_clds, 1.95 + bool trace_metadata, 1.96 + uint worker_i); 1.97 + 1.98 + // Apply oops, clds and blobs to all strongly reachable roots in the system 1.99 + void process_strong_roots(OopClosure* oops, 1.100 + CLDClosure* clds, 1.101 + CodeBlobClosure* blobs); 1.102 + 1.103 + // Apply oops, clds and blobs to strongly and weakly reachable roots in the system 1.104 + void process_all_roots(OopClosure* oops, 1.105 + CLDClosure* clds, 1.106 + CodeBlobClosure* blobs); 1.107 + 1.108 + // Apply scan_rs to all locations in the union of the remembered sets for all 1.109 + // regions in the collection set 1.110 + // (having done "set_region" to indicate the region in which the root resides), 1.111 + void scan_remembered_sets(G1ParPushHeapRSClosure* scan_rs, 1.112 + OopClosure* scan_non_heap_weak_roots, 1.113 + uint worker_i); 1.114 + 1.115 + // Inform the root processor about the number of worker threads 1.116 + void set_num_workers(int active_workers); 1.117 +}; 1.118 + 1.119 +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP