hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp
author tschatzl
Thu, 20 Aug 2015 15:17:41 +0200
changeset 32380 1dcdb686f0cb
parent 32348 47acdfbd402c
child 32617 a59435e1fecc
permissions -rw-r--r--
8133530: Add JFR event for evacuation statistics Summary: Introduce two new JFR events for young/old generation allocation statistics based on previous changes. Reviewed-by: ehelin, mgerdin
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
#include "precompiled.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    26
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    27
#include "classfile/stringTable.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    28
#include "classfile/systemDictionary.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    29
#include "code/codeCache.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    30
#include "gc/g1/bufferingOopClosure.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    31
#include "gc/g1/g1CollectedHeap.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    32
#include "gc/g1/g1CollectorPolicy.hpp"
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents: 30869
diff changeset
    33
#include "gc/g1/g1CollectorState.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    34
#include "gc/g1/g1GCPhaseTimes.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    35
#include "gc/g1/g1RemSet.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30585
diff changeset
    36
#include "gc/g1/g1RootProcessor.hpp"
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31331
diff changeset
    37
#include "gc/g1/heapRegion.inline.hpp"
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    38
#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
    39
#include "runtime/fprofiler.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    40
#include "runtime/mutex.hpp"
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    41
#include "services/management.hpp"
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
class G1CodeBlobClosure : public CodeBlobClosure {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    44
  class HeapRegionGatheringOopClosure : public OopClosure {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    45
    G1CollectedHeap* _g1h;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    46
    OopClosure* _work;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    47
    nmethod* _nm;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    48
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    49
    template <typename T>
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    50
    void do_oop_work(T* p) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    51
      _work->do_oop(p);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    52
      T oop_or_narrowoop = oopDesc::load_heap_oop(p);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    53
      if (!oopDesc::is_null(oop_or_narrowoop)) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    54
        oop o = oopDesc::decode_heap_oop_not_null(oop_or_narrowoop);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    55
        HeapRegion* hr = _g1h->heap_region_containing_raw(o);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    56
        assert(!_g1h->obj_in_cs(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in CS then evacuation failed and nm must already be in the remset");
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    57
        hr->add_strong_code_root(_nm);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    58
      }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    59
    }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    60
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    61
  public:
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    62
    HeapRegionGatheringOopClosure(OopClosure* oc) : _g1h(G1CollectedHeap::heap()), _work(oc), _nm(NULL) {}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    63
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    64
    void do_oop(oop* o) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    65
      do_oop_work(o);
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
    void do_oop(narrowOop* o) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    69
      do_oop_work(o);
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
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    72
    void set_nm(nmethod* nm) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    73
      _nm = nm;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    74
    }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    75
  };
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    76
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    77
  HeapRegionGatheringOopClosure _oc;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    78
public:
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    79
  G1CodeBlobClosure(OopClosure* oc) : _oc(oc) {}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    80
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    81
  void do_code_blob(CodeBlob* cb) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    82
    nmethod* nm = cb->as_nmethod_or_null();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    83
    if (nm != NULL) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    84
      if (!nm->test_set_oops_do_mark()) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    85
        _oc.set_nm(nm);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    86
        nm->oops_do(&_oc);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    87
        nm->fix_oop_relocations();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    88
      }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    89
    }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    90
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    91
};
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    92
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    93
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
    94
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
    95
  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
    96
30178
33317ec95df7 8077710: BACKOUT - java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options
sangheki
parents: 30172
diff changeset
    97
  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
    98
  if (new_value == n_workers()) {
30178
33317ec95df7 8077710: BACKOUT - java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options
sangheki
parents: 30172
diff changeset
    99
    // This thread is last. Notify the others.
33317ec95df7 8077710: BACKOUT - java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options
sangheki
parents: 30172
diff changeset
   100
    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
   101
    _lock.notify_all();
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   102
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   103
}
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
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
   106
  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
   107
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   108
  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
   109
    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
   110
    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
   111
      _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
   112
    }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   113
  }
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
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   116
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
   117
    _g1h(g1h),
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   118
    _process_strong_tasks(G1RP_PS_NumElements),
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   119
    _srs(n_workers),
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   120
    _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
   121
    _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
   122
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   123
void G1RootProcessor::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
   124
                                     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
   125
                                     CLDClosure* scan_strong_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   126
                                     CLDClosure* scan_weak_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   127
                                     bool trace_metadata,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   128
                                     uint worker_i) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   129
  // First scan the shared roots.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   130
  double ext_roots_start = os::elapsedTime();
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   131
  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
   132
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   133
  BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   134
  BufferingOopClosure buf_scan_non_heap_weak_roots(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
   135
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   136
  OopClosure* const weak_roots = &buf_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
   137
  OopClosure* const strong_roots = &buf_scan_non_heap_roots;
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   138
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   139
  // CodeBlobClosures are not interoperable with BufferingOopClosures
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   140
  G1CodeBlobClosure root_code_blobs(scan_non_heap_roots);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   141
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   142
  process_java_roots(strong_roots,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   143
                     trace_metadata ? scan_strong_clds : NULL,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   144
                     scan_strong_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   145
                     trace_metadata ? NULL : scan_weak_clds,
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   146
                     &root_code_blobs,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   147
                     phase_times,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   148
                     worker_i);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   149
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   150
  // 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
   151
  // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing.
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   152
  if (trace_metadata) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   153
    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
   154
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   155
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   156
  process_vm_roots(strong_roots, weak_roots, 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
   157
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   158
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   159
    // Now the CM ref_processor roots.
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   160
    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
   161
    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
   162
      // 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
   163
      // concurrent mark ref processor as roots and keep entries
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   164
      // (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
   165
      // until they can be processed at the end of marking.
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   166
      _g1h->ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   167
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   168
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   169
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   170
  if (trace_metadata) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   171
    {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   172
      G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WaitForStrongCLD, worker_i);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   173
      // Barrier to make sure all workers passed
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   174
      // the strong CLD and strong nmethods phases.
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   175
      wait_until_all_strong_classes_discovered();
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   176
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   177
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   178
    // Now take the complement of the strong CLDs.
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   179
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WeakCLDRoots, worker_i);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   180
    ClassLoaderDataGraph::roots_cld_do(NULL, scan_weak_clds);
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   181
  } else {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   182
    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
   183
    phase_times->record_time_secs(G1GCPhaseTimes::WeakCLDRoots, worker_i, 0.0);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   184
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   185
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   186
  // Finish up any enqueued closure apps (attributed as object copy time).
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   187
  buf_scan_non_heap_roots.done();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   188
  buf_scan_non_heap_weak_roots.done();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   189
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   190
  double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds()
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   191
      + buf_scan_non_heap_weak_roots.closure_app_seconds();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   192
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   193
  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
   194
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   195
  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
   196
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   197
  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
   198
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   199
  // 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
   200
  // 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
   201
  // as implicitly live).
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   202
  {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   203
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SATBFiltering, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   204
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_filter_satb_buffers) && _g1h->collector_state()->mark_in_progress()) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   205
      JavaThread::satb_mark_queue_set().filter_thread_buffers();
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   206
    }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   207
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   208
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   209
  _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
   210
}
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
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
   213
                                           CLDClosure* clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   214
                                           CodeBlobClosure* blobs) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   215
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   216
  process_java_roots(oops, clds, clds, NULL, blobs, NULL, 0);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   217
  process_vm_roots(oops, NULL, NULL, 0);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   218
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   219
  _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
   220
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   221
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   222
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
   223
                                        CLDClosure* clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   224
                                        CodeBlobClosure* blobs) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   225
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   226
  process_java_roots(oops, NULL, clds, clds, NULL, NULL, 0);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   227
  process_vm_roots(oops, oops, NULL, 0);
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   228
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   229
  if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   230
    CodeCache::blobs_do(blobs);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   231
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   232
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   233
  _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
   234
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   235
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   236
void G1RootProcessor::process_java_roots(OopClosure* strong_roots,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   237
                                         CLDClosure* thread_stack_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   238
                                         CLDClosure* strong_clds,
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   239
                                         CLDClosure* weak_clds,
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   240
                                         CodeBlobClosure* strong_code,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   241
                                         G1GCPhaseTimes* phase_times,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   242
                                         uint worker_i) {
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   243
  assert(thread_stack_clds == NULL || weak_clds == NULL, "There is overlap between those, only one may be set");
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   244
  // 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
   245
  // 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
   246
  // 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
   247
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   248
    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
   249
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   250
      ClassLoaderDataGraph::roots_cld_do(strong_clds, weak_clds);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   251
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   252
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
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::ThreadRoots, worker_i);
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   256
    bool is_par = n_workers() > 1;
30147
af9a41999c6e 8076314: Remove the static instance variable SharedHeap:: _sh
brutisso
parents: 29694
diff changeset
   257
    Threads::possibly_parallel_oops_do(is_par, strong_roots, thread_stack_clds, strong_code);
29694
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
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   261
void G1RootProcessor::process_vm_roots(OopClosure* strong_roots,
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   262
                                       OopClosure* weak_roots,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   263
                                       G1GCPhaseTimes* phase_times,
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   264
                                       uint worker_i) {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   265
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   266
    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
   267
    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
   268
      Universe::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   269
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   270
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   271
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   272
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   273
    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
   274
    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
   275
      JNIHandles::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   276
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   277
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   278
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   279
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   280
    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
   281
    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
   282
      ObjectSynchronizer::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   283
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   284
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   285
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   286
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   287
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::FlatProfilerRoots, worker_i);
32348
47acdfbd402c 8133193: Memory leak in G1 because G1RootProcessor doesn't have desctructor
david
parents: 32185
diff changeset
   288
    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_FlatProfiler_oops_do)) {
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   289
      FlatProfiler::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   290
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   291
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   292
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   293
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   294
    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
   295
    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
   296
      Management::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   297
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   298
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   299
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   300
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   301
    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
   302
    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
   303
      JvmtiExport::oops_do(strong_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
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
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   306
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   307
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   308
    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
   309
    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
   310
      SystemDictionary::roots_oops_do(strong_roots, weak_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   311
    }
29693
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   312
  }
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   313
29694
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   314
  {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   315
    G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   316
    // All threads execute the following. A specific chunk of buckets
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   317
    // from the StringTable are the individual tasks.
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   318
    if (weak_roots != NULL) {
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   319
      StringTable::possibly_parallel_oops_do(weak_roots);
442c3305ba39 8027962: Per-phase timing measurements for strong roots processing
brutisso
parents: 29693
diff changeset
   320
    }
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
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   324
void G1RootProcessor::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
   325
                                           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
   326
                                           uint worker_i) {
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   327
  G1CodeBlobClosure scavenge_cs_nmethods(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
   328
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   329
  _g1h->g1_rem_set()->oops_into_collection_set_do(scan_rs, &scavenge_cs_nmethods, worker_i);
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   330
}
fac175f7a466 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
diff changeset
   331
30868
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   332
uint G1RootProcessor::n_workers() const {
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   333
  return _srs.n_threads();
c1b24f26deed 8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents: 30867
diff changeset
   334
}