src/hotspot/share/gc/g1/g1RootProcessor.cpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 49751 c3a10df652c0
child 49911 358be4680d12
permissions -rw-r--r--
8200426: Make G1 code use _g1h members Summary: Consistently use _g1h member names for cached G1CollectedHeap* variables. Reviewed-by: sangheki, sjohanss
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
/*
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 47885
diff changeset
     2
 * Copyright (c) 2015, 2018, 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
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    25
#include "precompiled.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    26
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
    27
#include "aot/aotLoader.hpp"
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    28
#include "classfile/stringTable.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    29
#include "classfile/systemDictionary.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    30
#include "code/codeCache.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    31
#include "gc/g1/bufferingOopClosure.hpp"
49751
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49643
diff changeset
    32
#include "gc/g1/g1BarrierSet.hpp"
32617
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents: 32348
diff changeset
    33
#include "gc/g1/g1CodeBlobClosure.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    34
#include "gc/g1/g1CollectedHeap.inline.hpp"
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents: 30869
diff changeset
    35
#include "gc/g1/g1CollectorState.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    36
#include "gc/g1/g1GCPhaseTimes.hpp"
37985
539c597ee0fa 8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents: 33213
diff changeset
    37
#include "gc/g1/g1Policy.hpp"
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    38
#include "gc/g1/g1RootClosures.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    39
#include "gc/g1/g1RootProcessor.hpp"
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31331
diff changeset
    40
#include "gc/g1/heapRegion.inline.hpp"
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    41
#include "gc/shared/weakProcessor.hpp"
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    42
#include "memory/allocation.inline.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    43
#include "runtime/mutex.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    44
#include "services/management.hpp"
46681
f17cefd211b4 8183935: G1GCPhaseTimes and G1RootProcessor do not include macros.hpp
mgerdin
parents: 42650
diff changeset
    45
#include "utilities/macros.hpp"
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    46
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    47
void G1RootProcessor::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
    48
  assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    49
30178
33317ec95df7 8077710: BACKOUT - java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options
sangheki
parents: 30172
diff changeset
    50
  uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
    51
  if (new_value == n_workers()) {
30178
33317ec95df7 8077710: BACKOUT - java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options
sangheki
parents: 30172
diff changeset
    52
    // This thread is last. Notify the others.
33317ec95df7 8077710: BACKOUT - java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options
sangheki
parents: 30172
diff changeset
    53
    MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
33317ec95df7 8077710: BACKOUT - java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options
sangheki
parents: 30172
diff changeset
    54
    _lock.notify_all();
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    55
  }
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
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    58
void G1RootProcessor::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
    59
  assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    60
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
    61
  if ((uint)_n_workers_discovered_strong_classes != n_workers()) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    62
    MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
    63
    while ((uint)_n_workers_discovered_strong_classes != n_workers()) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    64
      _lock.wait(Mutex::_no_safepoint_check_flag, 0, false);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    65
    }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    66
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    67
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    68
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
    69
G1RootProcessor::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
    70
    _g1h(g1h),
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
    71
    _process_strong_tasks(G1RP_PS_NumElements),
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
    72
    _srs(n_workers),
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    73
    _lock(Mutex::leaf, "G1 Root Scanning barrier lock", false, Monitor::_safepoint_check_never),
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    74
    _n_workers_discovered_strong_classes(0) {}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    75
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    76
void G1RootProcessor::evacuate_roots(G1EvacuationRootClosures* closures, uint worker_i) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    77
  double ext_roots_start = os::elapsedTime();
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    78
  G1GCPhaseTimes* phase_times = _g1h->g1_policy()->phase_times();
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
  process_java_roots(closures, phase_times, worker_i);
29693
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
  // This is the point where this worker thread will not find more strong CLDs/nmethods.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    83
  // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing.
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    84
  if (closures->trace_metadata()) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    85
    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
    86
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    87
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    88
  process_vm_roots(closures, phase_times, worker_i);
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
    89
  process_string_table_roots(closures, phase_times, worker_i);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    90
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    91
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    92
    // Now the CM ref_processor roots.
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    93
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CMRefRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
    94
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_refProcessor_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    95
      // We need to treat the discovered reference lists of the
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    96
      // concurrent mark ref processor as roots and keep entries
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    97
      // (which are added by the marking threads) on them live
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
    98
      // until they can be processed at the end of marking.
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
    99
      _g1h->ref_processor_cm()->weak_oops_do(closures->strong_oops());
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   100
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   101
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   102
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   103
  if (closures->trace_metadata()) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   104
    {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   105
      G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WaitForStrongCLD, worker_i);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   106
      // Barrier to make sure all workers passed
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   107
      // the strong CLD and strong nmethods phases.
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   108
      wait_until_all_strong_classes_discovered();
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   109
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   110
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   111
    // Now take the complement of the strong CLDs.
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   112
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WeakCLDRoots, worker_i);
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   113
    assert(closures->second_pass_weak_clds() != NULL, "Should be non-null if we are tracing metadata.");
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   114
    ClassLoaderDataGraph::roots_cld_do(NULL, closures->second_pass_weak_clds());
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   115
  } else {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   116
    phase_times->record_time_secs(G1GCPhaseTimes::WaitForStrongCLD, worker_i, 0.0);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   117
    phase_times->record_time_secs(G1GCPhaseTimes::WeakCLDRoots, worker_i, 0.0);
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   118
    assert(closures->second_pass_weak_clds() == NULL, "Should be null if not tracing metadata.");
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   119
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   120
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   121
  // Finish up any enqueued closure apps (attributed as object copy time).
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   122
  closures->flush();
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   123
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   124
  double obj_copy_time_sec = closures->closure_app_seconds();
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   125
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   126
  phase_times->record_time_secs(G1GCPhaseTimes::ObjCopy, worker_i, obj_copy_time_sec);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   127
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   128
  double ext_root_time_sec = os::elapsedTime() - ext_roots_start - obj_copy_time_sec;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   129
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   130
  phase_times->record_time_secs(G1GCPhaseTimes::ExtRootScan, worker_i, ext_root_time_sec);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   131
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   132
  // During conc marking we have to filter the per-thread SATB buffers
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   133
  // to make sure we remove any oops into the CSet (which will show up
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   134
  // as implicitly live).
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   135
  {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   136
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SATBFiltering, worker_i);
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 47885
diff changeset
   137
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_filter_satb_buffers) && _g1h->collector_state()->mark_or_rebuild_in_progress()) {
49751
c3a10df652c0 8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents: 49643
diff changeset
   138
      G1BarrierSet::satb_mark_queue_set().filter_thread_buffers();
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   139
    }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   140
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   141
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   142
  _process_strong_tasks.all_tasks_completed(n_workers());
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   143
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   144
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   145
// Adaptor to pass the closures to the strong roots in the VM.
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   146
class StrongRootsClosures : public G1RootClosures {
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   147
  OopClosure* _roots;
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   148
  CLDClosure* _clds;
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   149
  CodeBlobClosure* _blobs;
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   150
public:
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   151
  StrongRootsClosures(OopClosure* roots, CLDClosure* clds, CodeBlobClosure* blobs) :
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   152
      _roots(roots), _clds(clds), _blobs(blobs) {}
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   153
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   154
  OopClosure* weak_oops()   { return NULL; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   155
  OopClosure* strong_oops() { return _roots; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   156
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   157
  CLDClosure* weak_clds()        { return NULL; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   158
  CLDClosure* strong_clds()      { return _clds; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   159
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   160
  CodeBlobClosure* strong_codeblobs() { return _blobs; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   161
};
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   162
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   163
void G1RootProcessor::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
   164
                                           CLDClosure* clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   165
                                           CodeBlobClosure* blobs) {
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   166
  StrongRootsClosures closures(oops, clds, blobs);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   167
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   168
  process_java_roots(&closures, NULL, 0);
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   169
  process_vm_roots(&closures, NULL, 0);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   170
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   171
  _process_strong_tasks.all_tasks_completed(n_workers());
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   172
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   173
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   174
// Adaptor to pass the closures to all the roots in the VM.
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   175
class AllRootsClosures : public G1RootClosures {
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   176
  OopClosure* _roots;
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   177
  CLDClosure* _clds;
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   178
public:
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   179
  AllRootsClosures(OopClosure* roots, CLDClosure* clds) :
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   180
      _roots(roots), _clds(clds) {}
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   181
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   182
  OopClosure* weak_oops() { return _roots; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   183
  OopClosure* strong_oops() { return _roots; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   184
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   185
  // By returning the same CLDClosure for both weak and strong CLDs we ensure
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   186
  // that a single walk of the CLDG will invoke the closure on all CLDs i the
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   187
  // system.
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   188
  CLDClosure* weak_clds() { return _clds; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   189
  CLDClosure* strong_clds() { return _clds; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   190
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   191
  // We don't want to visit code blobs more than once, so we return NULL for the
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   192
  // strong case and walk the entire code cache as a separate step.
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   193
  CodeBlobClosure* strong_codeblobs() { return NULL; }
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   194
};
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   195
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   196
void G1RootProcessor::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
   197
                                        CLDClosure* clds,
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   198
                                        CodeBlobClosure* blobs,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   199
                                        bool process_string_table) {
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   200
  AllRootsClosures closures(oops, clds);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   201
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   202
  process_java_roots(&closures, NULL, 0);
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   203
  process_vm_roots(&closures, NULL, 0);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   204
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   205
  if (process_string_table) {
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   206
    process_string_table_roots(&closures, NULL, 0);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   207
  }
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   208
  process_code_cache_roots(blobs, NULL, 0);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   209
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   210
  _process_strong_tasks.all_tasks_completed(n_workers());
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   211
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   212
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   213
void G1RootProcessor::process_all_roots(OopClosure* oops,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   214
                                        CLDClosure* clds,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   215
                                        CodeBlobClosure* blobs) {
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   216
  process_all_roots(oops, clds, blobs, true);
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   217
}
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   218
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   219
void G1RootProcessor::process_all_roots_no_string_table(OopClosure* oops,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   220
                                                        CLDClosure* clds,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   221
                                                        CodeBlobClosure* blobs) {
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   222
  assert(!ClassUnloading, "Should only be used when class unloading is disabled");
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   223
  process_all_roots(oops, clds, blobs, false);
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   224
}
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   225
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   226
void G1RootProcessor::process_java_roots(G1RootClosures* closures,
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   227
                                         G1GCPhaseTimes* phase_times,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   228
                                         uint worker_i) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   229
  // Iterating over the CLDG and the Threads are done early to allow us to
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   230
  // first process the strong CLDs and nmethods and then, after a barrier,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   231
  // let the thread process the weak CLDs and nmethods.
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   232
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   233
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   234
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   235
      ClassLoaderDataGraph::roots_cld_do(closures->strong_clds(), closures->weak_clds());
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   236
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   237
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   238
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   239
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   240
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ThreadRoots, worker_i);
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   241
    bool is_par = n_workers() > 1;
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   242
    Threads::possibly_parallel_oops_do(is_par,
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   243
                                       closures->strong_oops(),
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   244
                                       closures->strong_codeblobs());
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   245
  }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   246
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   247
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   248
void G1RootProcessor::process_vm_roots(G1RootClosures* closures,
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   249
                                       G1GCPhaseTimes* phase_times,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   250
                                       uint worker_i) {
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   251
  OopClosure* strong_roots = closures->strong_oops();
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   252
  OopClosure* weak_roots = closures->weak_oops();
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 32617
diff changeset
   253
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   254
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   255
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::UniverseRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   256
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Universe_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   257
      Universe::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   258
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   259
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   260
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   261
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   262
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JNIRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   263
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_JNIHandles_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   264
      JNIHandles::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   265
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   266
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   267
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   268
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   269
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ObjectSynchronizerRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   270
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_ObjectSynchronizer_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   271
      ObjectSynchronizer::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   272
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   273
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   274
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   275
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   276
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   277
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Management_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   278
      Management::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   279
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   280
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   281
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   282
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   283
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   284
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_jvmti_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   285
      JvmtiExport::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   286
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   287
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   288
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   289
#if INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   290
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   291
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::AOTCodeRoots, worker_i);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   292
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_aot_oops_do)) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   293
        AOTLoader::oops_do(strong_roots);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   294
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   295
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   296
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41077
diff changeset
   297
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   298
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   299
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SystemDictionaryRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   300
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_SystemDictionary_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   301
      SystemDictionary::roots_oops_do(strong_roots, weak_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   302
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   303
  }
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   304
}
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   305
41077
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   306
void G1RootProcessor::process_string_table_roots(G1RootClosures* closures,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   307
                                                 G1GCPhaseTimes* phase_times,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   308
                                                 uint worker_i) {
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   309
  assert(closures->weak_oops() != NULL, "Should only be called when all roots are processed");
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   310
  G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i);
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   311
  // All threads execute the following. A specific chunk of buckets
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   312
  // from the StringTable are the individual tasks.
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   313
  StringTable::possibly_parallel_oops_do(closures->weak_oops());
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   314
}
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   315
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   316
void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   317
                                               G1GCPhaseTimes* phase_times,
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   318
                                               uint worker_i) {
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   319
  if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) {
19f70464986e 8114823: G1 doesn't honor request to disable class unloading
sjohanss
parents: 38074
diff changeset
   320
    CodeCache::blobs_do(code_closure);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   321
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   322
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   323
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   324
void G1RootProcessor::process_full_gc_weak_roots(OopClosure* oops) {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   325
  if (!_process_strong_tasks.is_task_claimed(G1RP_PS_refProcessor_oops_do)) {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   326
    _g1h->ref_processor_stw()->weak_oops_do(oops);
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   327
  }
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   328
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   329
  if (!_process_strong_tasks.is_task_claimed(G1RP_PS_weakProcessor_oops_do)) {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   330
    WeakProcessor::oops_do(oops);
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   331
  }
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   332
}
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   333
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   334
uint G1RootProcessor::n_workers() const {
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   335
  return _srs.n_threads();
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   336
}