src/hotspot/share/gc/g1/g1RootProcessor.hpp
author manc
Mon, 14 Oct 2019 18:48:10 -0700
changeset 58652 9b67dd88a931
parent 58264 4e96939a5746
child 58679 9c3209ff7550
child 58777 18c246ad2ff9
permissions -rw-r--r--
8232232: G1RemSetSummary::_rs_threads_vtimes is not initialized to zero Summary: Fix error in "Concurrent refinement threads times" in GC log and cleanup. Reviewed-by: tschatzl, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     4
 *
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     8
 *
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    13
 * accompanied this code).
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    14
 *
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    18
 *
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    21
 * questions.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    22
 *
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    23
 */
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
    25
#ifndef SHARE_GC_G1_G1ROOTPROCESSOR_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
    26
#define SHARE_GC_G1_G1ROOTPROCESSOR_HPP
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    28
#include "gc/shared/strongRootsScope.hpp"
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    29
#include "memory/allocation.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    30
#include "runtime/mutex.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    31
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    32
class CLDClosure;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    33
class CodeBlobClosure;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    34
class G1CollectedHeap;
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    35
class G1EvacuationRootClosures;
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    36
class G1GCPhaseTimes;
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 47885
diff changeset
    37
class G1ParScanThreadState;
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    38
class G1RootClosures;
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    39
class Monitor;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    40
class OopClosure;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    41
class SubTasksDone;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    42
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    43
// Scoped object to assist in applying oop, CLD and code blob closures to
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    44
// root locations. Handles claiming of different root scanning tasks
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    45
// and takes care of global state for root scanning via a StrongRootsScope.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    46
// In the parallel case there is a shared G1RootProcessor object where all
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    47
// worker thread call the process_roots methods.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    48
class G1RootProcessor : public StackObj {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    49
  G1CollectedHeap* _g1h;
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 30869
diff changeset
    50
  SubTasksDone _process_strong_tasks;
30153
596ed88949ad 8076289: Move the StrongRootsScope out of SharedHeap
brutisso
parents: 29694
diff changeset
    51
  StrongRootsScope _srs;
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    52
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    53
  // Used to implement the Thread work barrier.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    54
  Monitor _lock;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    55
  volatile jint _n_workers_discovered_strong_classes;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    56
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    57
  enum G1H_process_roots_tasks {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    58
    G1RP_PS_Universe_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    59
    G1RP_PS_JNIHandles_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    60
    G1RP_PS_ObjectSynchronizer_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    61
    G1RP_PS_Management_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    62
    G1RP_PS_SystemDictionary_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    63
    G1RP_PS_ClassLoaderDataGraph_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    64
    G1RP_PS_jvmti_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    65
    G1RP_PS_CodeCache_oops_do,
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54364
diff changeset
    66
    AOT_ONLY(G1RP_PS_aot_oops_do COMMA)
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    67
    G1RP_PS_refProcessor_oops_do,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    68
    // Leave this one last.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    69
    G1RP_PS_NumElements
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    70
  };
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    71
58263
4fbc534fdf69 8159984: Remove call to ClassLoaderDataGraph::clear_claimed_marks during the initial mark pause
tschatzl
parents: 55740
diff changeset
    72
  void worker_has_discovered_all_strong_nmethods();
4fbc534fdf69 8159984: Remove call to ClassLoaderDataGraph::clear_claimed_marks during the initial mark pause
tschatzl
parents: 55740
diff changeset
    73
  void wait_until_all_strong_nmethods_discovered();
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    74
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    75
  void process_java_roots(G1RootClosures* closures,
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    76
                          G1GCPhaseTimes* phase_times,
58264
4e96939a5746 8231189: Rename worker_i parameters to worker_id
tschatzl
parents: 58263
diff changeset
    77
                          uint worker_id,
58263
4fbc534fdf69 8159984: Remove call to ClassLoaderDataGraph::clear_claimed_marks during the initial mark pause
tschatzl
parents: 55740
diff changeset
    78
                          bool notify_claimed_nmethods_done = false);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    79
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    80
  void process_vm_roots(G1RootClosures* closures,
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    81
                        G1GCPhaseTimes* phase_times,
58264
4e96939a5746 8231189: Rename worker_i parameters to worker_id
tschatzl
parents: 58263
diff changeset
    82
                        uint worker_id);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    83
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 33213
diff changeset
    84
  void process_code_cache_roots(CodeBlobClosure* code_closure,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 33213
diff changeset
    85
                                G1GCPhaseTimes* phase_times,
58264
4e96939a5746 8231189: Rename worker_i parameters to worker_id
tschatzl
parents: 58263
diff changeset
    86
                                uint worker_id);
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 33213
diff changeset
    87
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    88
public:
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30764
diff changeset
    89
  G1RootProcessor(G1CollectedHeap* g1h, uint n_workers);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    90
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 47885
diff changeset
    91
  // Apply correct closures from pss to the strongly and weakly reachable roots in the system
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    92
  // in a single pass.
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 53244
diff changeset
    93
  // Record and report timing measurements for sub phases using worker_id.
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 47885
diff changeset
    94
  void evacuate_roots(G1ParScanThreadState* pss, uint worker_id);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    95
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    96
  // Apply oops, clds and blobs to all strongly reachable roots in the system
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    97
  void process_strong_roots(OopClosure* oops,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    98
                            CLDClosure* clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    99
                            CodeBlobClosure* blobs);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   100
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   101
  // Apply oops, clds and blobs to strongly and weakly reachable roots in the system
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   102
  void process_all_roots(OopClosure* oops,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   103
                         CLDClosure* clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   104
                         CodeBlobClosure* blobs);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   105
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30764
diff changeset
   106
  // Number of worker threads used by the root processor.
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30764
diff changeset
   107
  uint n_workers() const;
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   108
};
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   109
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
   110
#endif // SHARE_GC_G1_G1ROOTPROCESSOR_HPP