src/hotspot/share/gc/z/zRootsIterator.cpp
author stuefe
Tue, 26 Nov 2019 16:21:29 +0100
branchstuefe-new-metaspace-branch
changeset 59272 54750b448264
parent 58777 18c246ad2ff9
child 59252 623722a6aeb9
permissions -rw-r--r--
Metadatatype back to metaspace.hpp to reduce patch size
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     1
/*
54385
9559ba212c18 8221102: Allow GC threads to participate in threads claiming protocol
kbarrett
parents: 53894
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     4
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     8
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    13
 * accompanied this code).
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    14
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    18
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    21
 * questions.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    22
 */
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    23
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    24
#include "precompiled.hpp"
51959
db0c3952de52 8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents: 51803
diff changeset
    25
#include "classfile/classLoaderDataGraph.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
#include "classfile/stringTable.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    27
#include "classfile/systemDictionary.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    28
#include "code/codeCache.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    29
#include "compiler/oopMap.hpp"
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
    30
#include "gc/shared/barrierSet.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
    31
#include "gc/shared/barrierSetNMethod.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    32
#include "gc/shared/oopStorageParState.inline.hpp"
57828
35db8fba55f9 8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents: 57659
diff changeset
    33
#include "gc/shared/oopStorageSet.hpp"
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    34
#include "gc/shared/suspendibleThreadSet.hpp"
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
    35
#include "gc/z/zBarrierSetNMethod.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    36
#include "gc/z/zGlobals.hpp"
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 53890
diff changeset
    37
#include "gc/z/zNMethod.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    38
#include "gc/z/zOopClosures.inline.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    39
#include "gc/z/zRootsIterator.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    40
#include "gc/z/zStat.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    41
#include "gc/z/zThreadLocalData.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    42
#include "memory/resourceArea.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    43
#include "memory/universe.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    44
#include "prims/jvmtiExport.hpp"
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
    45
#include "prims/resolvedMethodTable.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    46
#include "runtime/atomic.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    47
#include "runtime/thread.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
#include "runtime/safepoint.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    49
#include "runtime/synchronizer.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    50
#include "services/management.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    51
#include "utilities/debug.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    52
#if INCLUDE_JFR
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    53
#include "jfr/jfr.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    54
#endif
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    55
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    56
static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    57
static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    58
static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    59
static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    60
static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    61
static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    62
static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    63
static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    64
static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    65
static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    66
static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    67
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    68
static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup");
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    69
static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots");
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    70
static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown");
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    71
static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles");
55740
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
    72
static const ZStatSubPhase ZSubPhaseConcurrentRootsVMHandles("Concurrent Roots VMHandles");
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    73
static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph");
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    74
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    75
static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    76
static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    77
static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    78
static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    79
static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    80
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    81
static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    82
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    83
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    84
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable");
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
    85
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsResolvedMethodTable("Concurrent Weak Roots ResolvedMethodTable");
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    86
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    87
template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    88
ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    89
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    90
    _claimed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    91
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    92
template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    93
void ZSerialOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    94
  if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    95
    (_iter->*F)(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    96
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    97
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    98
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    99
template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   100
ZParallelOopsDo<T, F>::ZParallelOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   101
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   102
    _completed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   103
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   104
template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   105
void ZParallelOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   106
  if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   107
    (_iter->*F)(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   108
    if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   109
      _completed = true;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   110
    }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   111
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   112
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   113
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   114
template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   115
ZSerialWeakOopsDo<T, F>::ZSerialWeakOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   116
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   117
    _claimed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   118
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   119
template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   120
void ZSerialWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   121
  if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   122
    (_iter->*F)(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   123
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   124
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   125
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   126
template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   127
ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   128
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   129
    _completed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   130
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   131
template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   132
void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   133
  if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   134
    (_iter->*F)(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   135
    if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   136
      _completed = true;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   137
    }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   138
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   139
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   140
53843
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   141
class ZRootsIteratorCodeBlobClosure : public CodeBlobToOopClosure {
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   142
private:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   143
  BarrierSetNMethod* _bs;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   144
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   145
public:
53843
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   146
  ZRootsIteratorCodeBlobClosure(OopClosure* cl) :
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   147
    CodeBlobToOopClosure(cl, true /* fix_relocations */),
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   148
    _bs(BarrierSet::barrier_set()->barrier_set_nmethod()) {}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   149
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   150
  virtual void do_code_blob(CodeBlob* cb) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   151
    nmethod* const nm = cb->as_nmethod_or_null();
58777
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 58066
diff changeset
   152
    if (nm != NULL && nm->oops_do_try_claim()) {
53843
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   153
      CodeBlobToOopClosure::do_code_blob(cb);
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   154
      _bs->disarm(nm);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   155
    }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   156
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   157
};
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   158
53843
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   159
class ZRootsIteratorThreadClosure : public ThreadClosure {
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   160
private:
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   161
  ZRootsIteratorClosure* _cl;
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   162
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   163
public:
58066
8407928b9fe5 8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents: 57851
diff changeset
   164
  ZRootsIteratorThreadClosure(ZRootsIteratorClosure* cl) :
8407928b9fe5 8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents: 57851
diff changeset
   165
      _cl(cl) {}
53843
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   166
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   167
  virtual void do_thread(Thread* thread) {
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   168
    ZRootsIteratorCodeBlobClosure code_cl(_cl);
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   169
    thread->oops_do(_cl, ClassUnloading ? &code_cl : NULL);
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   170
    _cl->do_thread(thread);
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   171
  }
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   172
};
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   173
58066
8407928b9fe5 8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents: 57851
diff changeset
   174
ZRootsIterator::ZRootsIterator(bool visit_jvmti_weak_export) :
57851
6728c41f2a08 8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents: 57828
diff changeset
   175
    _visit_jvmti_weak_export(visit_jvmti_weak_export),
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   176
    _universe(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   177
    _object_synchronizer(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   178
    _management(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   179
    _jvmti_export(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   180
    _jvmti_weak_export(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   181
    _system_dictionary(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   182
    _threads(this),
51590
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   183
    _code_cache(this) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   184
  assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   185
  ZStatTimer timer(ZSubPhasePauseRootsSetup);
54385
9559ba212c18 8221102: Allow GC threads to participate in threads claiming protocol
kbarrett
parents: 53894
diff changeset
   186
  Threads::change_thread_claim_token();
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   187
  COMPILER2_PRESENT(DerivedPointerTable::clear());
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   188
  if (ClassUnloading) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   189
    nmethod::oops_do_marking_prologue();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   190
  } else {
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 53890
diff changeset
   191
    ZNMethod::oops_do_begin();
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   192
  }
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   193
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   194
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   195
ZRootsIterator::~ZRootsIterator() {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   196
  ZStatTimer timer(ZSubPhasePauseRootsTeardown);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   197
  ResourceMark rm;
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   198
  if (ClassUnloading) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   199
    nmethod::oops_do_marking_epilogue();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   200
  } else {
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 53890
diff changeset
   201
    ZNMethod::oops_do_end();
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   202
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   203
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   204
  COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   205
  Threads::assert_all_threads_claimed();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   206
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   207
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   208
void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   209
  ZStatTimer timer(ZSubPhasePauseRootsUniverse);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   210
  Universe::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   211
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   212
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   213
void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   214
  ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   215
  ObjectSynchronizer::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   216
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   217
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   218
void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   219
  ZStatTimer timer(ZSubPhasePauseRootsManagement);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   220
  Management::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   221
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   222
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   223
void ZRootsIterator::do_jvmti_export(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   224
  ZStatTimer timer(ZSubPhasePauseRootsJVMTIExport);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   225
  JvmtiExport::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   226
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   227
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   228
void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   229
  ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   230
  AlwaysTrueClosure always_alive;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   231
  JvmtiExport::weak_oops_do(&always_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   232
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   233
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   234
void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   235
  ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
55740
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   236
  // Handles are processed via _vm_handles.
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   237
  SystemDictionary::oops_do(cl, false /* include_handles */);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   238
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   239
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   240
void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   241
  ZStatTimer timer(ZSubPhasePauseRootsThreads);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   242
  ResourceMark rm;
58066
8407928b9fe5 8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents: 57851
diff changeset
   243
  ZRootsIteratorThreadClosure thread_cl(cl);
53843
b38d76fc4835 8219332: ZGC: Improve ZRootsIteratorClosure abstraction
pliden
parents: 52939
diff changeset
   244
  Threads::possibly_parallel_threads_do(true, &thread_cl);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   245
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   246
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   247
void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   248
  ZStatTimer timer(ZSubPhasePauseRootsCodeCache);
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 53890
diff changeset
   249
  ZNMethod::oops_do(cl);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   250
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   251
57851
6728c41f2a08 8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents: 57828
diff changeset
   252
void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   253
  ZStatTimer timer(ZSubPhasePauseRoots);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   254
  _universe.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   255
  _object_synchronizer.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   256
  _management.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   257
  _jvmti_export.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   258
  _system_dictionary.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   259
  _threads.oops_do(cl);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   260
  if (!ClassUnloading) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   261
    _code_cache.oops_do(cl);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 52141
diff changeset
   262
  }
57851
6728c41f2a08 8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents: 57828
diff changeset
   263
  if (_visit_jvmti_weak_export) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   264
    _jvmti_weak_export.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   265
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   266
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   267
55603
3868dde58ebb 8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents: 54511
diff changeset
   268
ZConcurrentRootsIterator::ZConcurrentRootsIterator(int cld_claim) :
57828
35db8fba55f9 8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents: 57659
diff changeset
   269
    _jni_handles_iter(OopStorageSet::jni_global()),
35db8fba55f9 8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents: 57659
diff changeset
   270
    _vm_handles_iter(OopStorageSet::vm_global()),
55603
3868dde58ebb 8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents: 54511
diff changeset
   271
    _cld_claim(cld_claim),
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   272
    _jni_handles(this),
55740
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   273
    _vm_handles(this),
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   274
    _class_loader_data_graph(this) {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   275
  ZStatTimer timer(ZSubPhaseConcurrentRootsSetup);
57658
0022b39ae5ae 8229017: ZGC: Various cleanups of ZVerify
pliden
parents: 55740
diff changeset
   276
  ClassLoaderDataGraph::clear_claimed_marks(cld_claim);
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   277
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   278
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   279
ZConcurrentRootsIterator::~ZConcurrentRootsIterator() {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   280
  ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   281
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   282
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   283
void ZConcurrentRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   284
  ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   285
  _jni_handles_iter.oops_do(cl);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   286
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   287
55740
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   288
void ZConcurrentRootsIterator::do_vm_handles(ZRootsIteratorClosure* cl) {
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   289
  ZStatTimer timer(ZSubPhaseConcurrentRootsVMHandles);
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   290
  _vm_handles_iter.oops_do(cl);
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   291
}
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   292
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   293
void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   294
  ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph);
55603
3868dde58ebb 8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents: 54511
diff changeset
   295
  CLDToOopClosure cld_cl(cl, _cld_claim);
3868dde58ebb 8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents: 54511
diff changeset
   296
  ClassLoaderDataGraph::always_strong_cld_do(&cld_cl);
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   297
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   298
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   299
void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   300
  ZStatTimer timer(ZSubPhaseConcurrentRoots);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   301
  _jni_handles.oops_do(cl);
55740
b3ff56f955c8 8227653: Add VM Global OopStorage
kbarrett
parents: 55605
diff changeset
   302
  _vm_handles.oops_do(cl),
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   303
  _class_loader_data_graph.oops_do(cl);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   304
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   305
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   306
ZWeakRootsIterator::ZWeakRootsIterator() :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   307
    _jvmti_weak_export(this),
51587
b459c731901b 8210061: ZGC: Remove STW weak processor mode
eosterlund
parents: 51405
diff changeset
   308
    _jfr_weak(this) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   309
  assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   310
  ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   311
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   312
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   313
ZWeakRootsIterator::~ZWeakRootsIterator() {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   314
  ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   315
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   316
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   317
void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   318
  ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   319
  JvmtiExport::weak_oops_do(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   320
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   321
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   322
void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   323
#if INCLUDE_JFR
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   324
  ZStatTimer timer(ZSubPhasePauseWeakRootsJFRWeak);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   325
  Jfr::weak_oops_do(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   326
#endif
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   327
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   328
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   329
void ZWeakRootsIterator::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   330
  ZStatTimer timer(ZSubPhasePauseWeakRoots);
51590
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   331
  _jvmti_weak_export.weak_oops_do(is_alive, cl);
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   332
  _jfr_weak.weak_oops_do(is_alive, cl);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   333
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   334
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   335
void ZWeakRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   336
  AlwaysTrueClosure always_alive;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   337
  weak_oops_do(&always_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   338
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   339
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   340
ZConcurrentWeakRootsIterator::ZConcurrentWeakRootsIterator() :
57828
35db8fba55f9 8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents: 57659
diff changeset
   341
    _vm_weak_handles_iter(OopStorageSet::vm_weak()),
35db8fba55f9 8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents: 57659
diff changeset
   342
    _jni_weak_handles_iter(OopStorageSet::jni_weak()),
35db8fba55f9 8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents: 57659
diff changeset
   343
    _string_table_iter(OopStorageSet::string_table_weak()),
35db8fba55f9 8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents: 57659
diff changeset
   344
    _resolved_method_table_iter(OopStorageSet::resolved_method_table_weak()),
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   345
    _vm_weak_handles(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   346
    _jni_weak_handles(this),
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   347
    _string_table(this),
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   348
    _resolved_method_table(this) {
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   349
  StringTable::reset_dead_counter();
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   350
  ResolvedMethodTable::reset_dead_counter();
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   351
}
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   352
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   353
ZConcurrentWeakRootsIterator::~ZConcurrentWeakRootsIterator() {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   354
  StringTable::finish_dead_counter();
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   355
  ResolvedMethodTable::finish_dead_counter();
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   356
}
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   357
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   358
void ZConcurrentWeakRootsIterator::do_vm_weak_handles(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   359
  ZStatTimer timer(ZSubPhaseConcurrentWeakRootsVMWeakHandles);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   360
  _vm_weak_handles_iter.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   361
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   362
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   363
void ZConcurrentWeakRootsIterator::do_jni_weak_handles(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   364
  ZStatTimer timer(ZSubPhaseConcurrentWeakRootsJNIWeakHandles);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   365
  _jni_weak_handles_iter.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   366
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   367
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   368
template <class Container>
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   369
class ZDeadCounterClosure : public ZRootsIteratorClosure  {
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   370
private:
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   371
  ZRootsIteratorClosure* const _cl;
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   372
  size_t                       _ndead;
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   373
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   374
public:
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   375
  ZDeadCounterClosure(ZRootsIteratorClosure* cl) :
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   376
      _cl(cl),
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   377
      _ndead(0) {}
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   378
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   379
  ~ZDeadCounterClosure() {
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   380
    Container::inc_dead_counter(_ndead);
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   381
  }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   382
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   383
  virtual void do_oop(oop* p) {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   384
    _cl->do_oop(p);
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   385
    if (*p == NULL) {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   386
      _ndead++;
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   387
    }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   388
  }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   389
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   390
  virtual void do_oop(narrowOop* p) {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   391
    ShouldNotReachHere();
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   392
  }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   393
};
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   394
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   395
void ZConcurrentWeakRootsIterator::do_string_table(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   396
  ZStatTimer timer(ZSubPhaseConcurrentWeakRootsStringTable);
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   397
  ZDeadCounterClosure<StringTable> counter_cl(cl);
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   398
  _string_table_iter.oops_do(&counter_cl);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   399
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   400
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   401
void ZConcurrentWeakRootsIterator::do_resolved_method_table(ZRootsIteratorClosure* cl) {
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   402
  ZStatTimer timer(ZSubPhaseConcurrentWeakRootsResolvedMethodTable);
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   403
  ZDeadCounterClosure<ResolvedMethodTable> counter_cl(cl);
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   404
  _resolved_method_table_iter.oops_do(&counter_cl);
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   405
}
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   406
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   407
void ZConcurrentWeakRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   408
  ZStatTimer timer(ZSubPhaseConcurrentWeakRoots);
51590
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   409
  _vm_weak_handles.oops_do(cl);
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   410
  _jni_weak_handles.oops_do(cl);
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   411
  _string_table.oops_do(cl);
54511
fbfcebad8e66 8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents: 54385
diff changeset
   412
  _resolved_method_table.oops_do(cl);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   413
}