hotspot/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp
author mgerdin
Mon, 01 Dec 2014 15:24:56 +0100
changeset 29693 fac175f7a466
child 29694 442c3305ba39
permissions -rw-r--r--
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap Summary: Create a G1RootProcessor and move SharedHeap root processing to GenCollectedHeap Reviewed-by: brutisso, tschatzl, ehelin
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
/*
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    27
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    28
#include "memory/allocation.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    29
#include "memory/sharedHeap.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;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    35
class G1ParPushHeapRSClosure;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    36
class Monitor;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    37
class OopClosure;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    38
class SubTasksDone;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    39
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    40
// 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
    41
// 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
    42
// 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
    43
// 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
    44
// 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
    45
class G1RootProcessor : public StackObj {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    46
  G1CollectedHeap* _g1h;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    47
  SubTasksDone* _process_strong_tasks;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    48
  SharedHeap::StrongRootsScope _srs;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    49
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    50
  // 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
    51
  Monitor _lock;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    52
  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
    53
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    54
  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
    55
    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
    56
    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
    57
    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
    58
    G1RP_PS_FlatProfiler_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_Management_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_SystemDictionary_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_ClassLoaderDataGraph_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_jvmti_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_CodeCache_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_filter_satb_buffers,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    65
    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
    66
    // Leave this one last.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    67
    G1RP_PS_NumElements
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    68
  };
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    69
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    70
  void worker_has_discovered_all_strong_classes();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    71
  void wait_until_all_strong_classes_discovered();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    72
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    73
  void process_java_roots(OopClosure* scan_non_heap_roots,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    74
                          CLDClosure* thread_stack_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    75
                          CLDClosure* scan_strong_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    76
                          CLDClosure* scan_weak_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    77
                          CodeBlobClosure* scan_strong_code);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    78
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    79
  void process_vm_roots(OopClosure* scan_non_heap_roots,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    80
                        OopClosure* scan_non_heap_weak_roots);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    81
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    82
public:
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    83
  G1RootProcessor(G1CollectedHeap* g1h);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    84
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    85
  // Apply closures to the 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
    86
  // in a single pass.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    87
  // Record and report timing measurements for sub phases using the worker_i
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    88
  void evacuate_roots(OopClosure* scan_non_heap_roots,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    89
                      OopClosure* scan_non_heap_weak_roots,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    90
                      CLDClosure* scan_strong_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    91
                      CLDClosure* scan_weak_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    92
                      bool trace_metadata,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    93
                      uint worker_i);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    94
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    95
  // 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
    96
  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
    97
                            CLDClosure* clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    98
                            CodeBlobClosure* blobs);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    99
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   100
  // 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
   101
  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
   102
                         CLDClosure* clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   103
                         CodeBlobClosure* blobs);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   104
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   105
  // Apply scan_rs to all locations in the union of the remembered sets for all
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   106
  // regions in the collection set
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   107
  // (having done "set_region" to indicate the region in which the root resides),
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   108
  void scan_remembered_sets(G1ParPushHeapRSClosure* scan_rs,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   109
                            OopClosure* scan_non_heap_weak_roots,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   110
                            uint worker_i);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   111
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   112
  // Inform the root processor about the number of worker threads
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   113
  void set_num_workers(int active_workers);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   114
};
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   115
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   116
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP