src/share/vm/gc_implementation/g1/g1RootProcessor.hpp

Fri, 20 Jul 2018 03:07:49 -0400

author
fmatte
date
Fri, 20 Jul 2018 03:07:49 -0400
changeset 9358
6a4a6c499e89
parent 8070
c0205eddb317
permissions
-rw-r--r--

8114823: G1 doesn't honor request to disable class unloading
Reviewed-by: tschatzl

     1 /*
     2  * Copyright (c) 2015, 2018, 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  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP
    28 #include "memory/allocation.hpp"
    29 #include "memory/sharedHeap.hpp"
    30 #include "runtime/mutex.hpp"
    32 class CLDClosure;
    33 class CodeBlobClosure;
    34 class G1CollectedHeap;
    35 class G1GCPhaseTimes;
    36 class G1ParPushHeapRSClosure;
    37 class G1RootClosures;
    38 class Monitor;
    39 class OopClosure;
    40 class SubTasksDone;
    42 // Scoped object to assist in applying oop, CLD and code blob closures to
    43 // root locations. Handles claiming of different root scanning tasks
    44 // and takes care of global state for root scanning via a StrongRootsScope.
    45 // In the parallel case there is a shared G1RootProcessor object where all
    46 // worker thread call the process_roots methods.
    47 class G1RootProcessor : public StackObj {
    48   G1CollectedHeap* _g1h;
    49   SubTasksDone _process_strong_tasks;
    50   SharedHeap::StrongRootsScope _srs;
    52   // Used to implement the Thread work barrier.
    53   Monitor _lock;
    54   volatile jint _n_workers_discovered_strong_classes;
    56   enum G1H_process_roots_tasks {
    57     G1RP_PS_Universe_oops_do,
    58     G1RP_PS_JNIHandles_oops_do,
    59     G1RP_PS_ObjectSynchronizer_oops_do,
    60     G1RP_PS_FlatProfiler_oops_do,
    61     G1RP_PS_Management_oops_do,
    62     G1RP_PS_SystemDictionary_oops_do,
    63     G1RP_PS_ClassLoaderDataGraph_oops_do,
    64     G1RP_PS_jvmti_oops_do,
    65     G1RP_PS_CodeCache_oops_do,
    66     G1RP_PS_filter_satb_buffers,
    67     G1RP_PS_refProcessor_oops_do,
    68     // Leave this one last.
    69     G1RP_PS_NumElements
    70   };
    72   void worker_has_discovered_all_strong_classes();
    73   void wait_until_all_strong_classes_discovered();
    75   void process_all_roots(OopClosure* oops,
    76                          CLDClosure* clds,
    77                          CodeBlobClosure* blobs,
    78                          bool process_string_table);
    80   void process_java_roots(OopClosure* scan_non_heap_roots,
    81                           CLDClosure* thread_stack_clds,
    82                           CLDClosure* scan_strong_clds,
    83                           CLDClosure* scan_weak_clds,
    84                           CodeBlobClosure* scan_strong_code,
    85                           G1GCPhaseTimes* phase_times,
    86                           uint worker_i);
    88   void process_vm_roots(OopClosure* scan_non_heap_roots,
    89                         OopClosure* scan_non_heap_weak_roots,
    90                         G1GCPhaseTimes* phase_times,
    91                         uint worker_i);
    93   void process_string_table_roots(OopClosure* scan_non_heap_weak_roots,
    94                                   G1GCPhaseTimes* phase_times,
    95                                   uint worker_i);
    97   void process_code_cache_roots(CodeBlobClosure* code_closure,
    98                                 G1GCPhaseTimes* phase_times,
    99                                 uint worker_i);
   101 public:
   102   G1RootProcessor(G1CollectedHeap* g1h);
   104   // Apply closures to the strongly and weakly reachable roots in the system
   105   // in a single pass.
   106   // Record and report timing measurements for sub phases using the worker_i
   107   void evacuate_roots(OopClosure* scan_non_heap_roots,
   108                       OopClosure* scan_non_heap_weak_roots,
   109                       CLDClosure* scan_strong_clds,
   110                       CLDClosure* scan_weak_clds,
   111                       bool trace_metadata,
   112                       uint worker_i);
   114   // Apply oops, clds and blobs to all strongly reachable roots in the system
   115   void process_strong_roots(OopClosure* oops,
   116                             CLDClosure* clds,
   117                             CodeBlobClosure* blobs);
   119   // Apply oops, clds and blobs to strongly and weakly reachable roots in the system
   120   void process_all_roots(OopClosure* oops,
   121                          CLDClosure* clds,
   122                          CodeBlobClosure* blobs);
   124   // Apply scan_rs to all locations in the union of the remembered sets for all
   125   // regions in the collection set
   126   // (having done "set_region" to indicate the region in which the root resides),
   127   void scan_remembered_sets(G1ParPushHeapRSClosure* scan_rs,
   128                             OopClosure* scan_non_heap_weak_roots,
   129                             uint worker_i);
   131   // Apply oops, clds and blobs to strongly and weakly reachable roots in the system,
   132   // the only thing different from process_all_roots is that we skip the string table
   133   // to avoid keeping every string live when doing class unloading.
   134   void process_all_roots_no_string_table(OopClosure* oops,
   135                                          CLDClosure* clds,
   136                                          CodeBlobClosure* blobs);
   138   // Inform the root processor about the number of worker threads
   139   void set_num_workers(int active_workers);
   140 };
   142 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP

mercurial