src/hotspot/share/gc/z/zRootsIterator.cpp
author eosterlund
Tue, 16 Oct 2018 13:14:18 +0200
changeset 52140 3a168f782e80
parent 51959 db0c3952de52
child 52141 de6dc206a92b
permissions -rw-r--r--
8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently Reviewed-by: pliden, kbarrett
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
/*
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
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"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    30
#include "gc/shared/oopStorageParState.inline.hpp"
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    31
#include "gc/shared/suspendibleThreadSet.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    32
#include "gc/z/zGlobals.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    33
#include "gc/z/zNMethodTable.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    34
#include "gc/z/zOopClosures.inline.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    35
#include "gc/z/zRootsIterator.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    36
#include "gc/z/zStat.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    37
#include "gc/z/zThreadLocalData.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    38
#include "memory/resourceArea.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    39
#include "memory/universe.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    40
#include "prims/jvmtiExport.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    41
#include "runtime/atomic.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    42
#include "runtime/jniHandles.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    43
#include "runtime/thread.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    44
#include "runtime/safepoint.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    45
#include "runtime/synchronizer.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    46
#include "services/management.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    47
#include "utilities/debug.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
#if INCLUDE_JFR
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    49
#include "jfr/jfr.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    50
#endif
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    51
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    52
static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    53
static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    54
static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    55
static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    56
static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    57
static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    58
static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    59
static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    60
static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    61
static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    62
static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    63
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    64
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
    65
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
    66
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
    67
static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles");
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
    68
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
    69
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    70
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
    71
static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    72
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
    73
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
    74
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
    75
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    76
static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    77
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
    78
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
    79
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable");
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    80
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    81
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
    82
ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    83
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    84
    _claimed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    85
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    86
template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    87
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
    88
  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
    89
    (_iter->*F)(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    90
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    91
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    92
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    93
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
    94
ZParallelOopsDo<T, F>::ZParallelOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    95
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    96
    _completed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    97
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    98
template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
    99
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
   100
  if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   101
    (_iter->*F)(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   102
    if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   103
      _completed = true;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   104
    }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   105
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   106
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   107
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   108
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
   109
ZSerialWeakOopsDo<T, F>::ZSerialWeakOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   110
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   111
    _claimed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   112
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   113
template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   114
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
   115
  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
   116
    (_iter->*F)(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   117
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   118
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   119
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   120
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
   121
ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   122
    _iter(iter),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   123
    _completed(false) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   124
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   125
template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   126
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
   127
  if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   128
    (_iter->*F)(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   129
    if (!_completed) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   130
      _completed = true;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   131
    }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   132
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   133
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   134
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   135
ZRootsIterator::ZRootsIterator() :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   136
    _universe(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   137
    _object_synchronizer(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   138
    _management(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   139
    _jvmti_export(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   140
    _jvmti_weak_export(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   141
    _system_dictionary(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   142
    _threads(this),
51590
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   143
    _code_cache(this) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   144
  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
   145
  ZStatTimer timer(ZSubPhasePauseRootsSetup);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   146
  Threads::change_thread_claim_parity();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   147
  COMPILER2_PRESENT(DerivedPointerTable::clear());
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   148
  CodeCache::gc_prologue();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   149
  ZNMethodTable::gc_prologue();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   150
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   151
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   152
ZRootsIterator::~ZRootsIterator() {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   153
  ZStatTimer timer(ZSubPhasePauseRootsTeardown);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   154
  ResourceMark rm;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   155
  ZNMethodTable::gc_epilogue();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   156
  CodeCache::gc_epilogue();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   157
  JvmtiExport::gc_epilogue();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   158
  COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   159
  Threads::assert_all_threads_claimed();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   160
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   161
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   162
void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   163
  ZStatTimer timer(ZSubPhasePauseRootsUniverse);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   164
  Universe::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   165
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   166
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   167
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
   168
  ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   169
  ObjectSynchronizer::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   170
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   171
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   172
void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   173
  ZStatTimer timer(ZSubPhasePauseRootsManagement);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   174
  Management::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   175
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   176
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   177
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
   178
  ZStatTimer timer(ZSubPhasePauseRootsJVMTIExport);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   179
  JvmtiExport::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   180
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   181
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   182
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
   183
  ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   184
  AlwaysTrueClosure always_alive;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   185
  JvmtiExport::weak_oops_do(&always_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   186
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   187
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   188
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
   189
  ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   190
  SystemDictionary::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   191
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   192
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   193
void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   194
  ZStatTimer timer(ZSubPhasePauseRootsThreads);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   195
  ResourceMark rm;
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   196
  Threads::possibly_parallel_threads_do(true, cl);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   197
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   198
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   199
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
   200
  ZStatTimer timer(ZSubPhasePauseRootsCodeCache);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   201
  ZNMethodTable::oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   202
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   203
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   204
void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   205
  ZStatTimer timer(ZSubPhasePauseRoots);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   206
  _universe.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   207
  _object_synchronizer.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   208
  _management.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   209
  _jvmti_export.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   210
  _system_dictionary.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   211
  _threads.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   212
  _code_cache.oops_do(cl);
51590
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   213
  if (visit_jvmti_weak_export) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   214
    _jvmti_weak_export.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   215
  }
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
52140
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   218
ZConcurrentRootsIterator::ZConcurrentRootsIterator(bool marking) :
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   219
    _marking(marking),
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   220
    _sts_joiner(marking /* active */),
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   221
    _jni_handles_iter(JNIHandles::global_handles()),
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   222
    _jni_handles(this),
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   223
    _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
   224
  ZStatTimer timer(ZSubPhaseConcurrentRootsSetup);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   225
  if (_marking) {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   226
    ClassLoaderDataGraph_lock->lock();
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   227
    ClassLoaderDataGraph::clear_claimed_marks();
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   228
  }
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   229
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   230
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   231
ZConcurrentRootsIterator::~ZConcurrentRootsIterator() {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   232
  ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   233
  if (_marking) {
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   234
    ClassLoaderDataGraph_lock->unlock();
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   235
  }
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   236
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   237
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   238
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
   239
  ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   240
  _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
   241
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   242
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   243
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
   244
  ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   245
  CLDToOopClosure cld_cl(cl, _marking /* must_claim */);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   246
  ClassLoaderDataGraph::cld_do(&cld_cl);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   247
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   248
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   249
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
   250
  ZStatTimer timer(ZSubPhaseConcurrentRoots);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   251
  _jni_handles.oops_do(cl);
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   252
  _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
   253
}
3a168f782e80 8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents: 51959
diff changeset
   254
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   255
ZWeakRootsIterator::ZWeakRootsIterator() :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   256
    _jvmti_weak_export(this),
51587
b459c731901b 8210061: ZGC: Remove STW weak processor mode
eosterlund
parents: 51405
diff changeset
   257
    _jfr_weak(this) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   258
  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
   259
  ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   260
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   261
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   262
ZWeakRootsIterator::~ZWeakRootsIterator() {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   263
  ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   264
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   265
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   266
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
   267
  ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   268
  JvmtiExport::weak_oops_do(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   269
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   270
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   271
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
   272
#if INCLUDE_JFR
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   273
  ZStatTimer timer(ZSubPhasePauseWeakRootsJFRWeak);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   274
  Jfr::weak_oops_do(is_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   275
#endif
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   276
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   277
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   278
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
   279
  ZStatTimer timer(ZSubPhasePauseWeakRoots);
51590
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   280
  _jvmti_weak_export.weak_oops_do(is_alive, cl);
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   281
  _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
   282
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   283
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   284
void ZWeakRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   285
  AlwaysTrueClosure always_alive;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   286
  weak_oops_do(&always_alive, cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   287
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   288
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   289
ZConcurrentWeakRootsIterator::ZConcurrentWeakRootsIterator() :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   290
    _vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   291
    _jni_weak_handles_iter(JNIHandles::weak_global_handles()),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   292
    _string_table_iter(StringTable::weak_storage()),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   293
    _vm_weak_handles(this),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   294
    _jni_weak_handles(this),
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   295
    _string_table(this) {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   296
  StringTable::reset_dead_counter();
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   297
}
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   298
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   299
ZConcurrentWeakRootsIterator::~ZConcurrentWeakRootsIterator() {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   300
  StringTable::finish_dead_counter();
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   301
}
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   302
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   303
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
   304
  ZStatTimer timer(ZSubPhaseConcurrentWeakRootsVMWeakHandles);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   305
  _vm_weak_handles_iter.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   306
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   307
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   308
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
   309
  ZStatTimer timer(ZSubPhaseConcurrentWeakRootsJNIWeakHandles);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   310
  _jni_weak_handles_iter.oops_do(cl);
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
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   313
class ZStringTableDeadCounterClosure : public ZRootsIteratorClosure  {
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   314
private:
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   315
  ZRootsIteratorClosure* const _cl;
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   316
  size_t                       _ndead;
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   317
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   318
public:
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   319
  ZStringTableDeadCounterClosure(ZRootsIteratorClosure* cl) :
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   320
      _cl(cl),
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   321
      _ndead(0) {}
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   322
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   323
  ~ZStringTableDeadCounterClosure() {
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   324
    StringTable::inc_dead_counter(_ndead);
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   325
  }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   326
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   327
  virtual void do_oop(oop* p) {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   328
    _cl->do_oop(p);
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   329
    if (*p == NULL) {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   330
      _ndead++;
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   331
    }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   332
  }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   333
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   334
  virtual void do_oop(narrowOop* p) {
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   335
    ShouldNotReachHere();
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   336
  }
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   337
};
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   338
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   339
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
   340
  ZStatTimer timer(ZSubPhaseConcurrentWeakRootsStringTable);
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   341
  ZStringTableDeadCounterClosure counter_cl(cl);
50556
e5a40146791b 8204613: StringTable: Calculates wrong number of uncleaned items.
rehn
parents: 50525
diff changeset
   342
  _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
   343
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   344
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   345
void ZConcurrentWeakRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   346
  ZStatTimer timer(ZSubPhaseConcurrentWeakRoots);
51590
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   347
  _vm_weak_handles.oops_do(cl);
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   348
  _jni_weak_handles.oops_do(cl);
3aaf039a3636 8210065: ZGC: Remove mode for treating weaks as strong
eosterlund
parents: 51587
diff changeset
   349
  _string_table.oops_do(cl);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   350
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   351
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   352
ZThreadRootsIterator::ZThreadRootsIterator() :
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   353
    _threads(this) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   354
  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
   355
  ZStatTimer timer(ZSubPhasePauseRootsSetup);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   356
  Threads::change_thread_claim_parity();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   357
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   358
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   359
ZThreadRootsIterator::~ZThreadRootsIterator() {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   360
  ZStatTimer timer(ZSubPhasePauseRootsTeardown);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   361
  Threads::assert_all_threads_claimed();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   362
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   363
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   364
void ZThreadRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   365
  ZStatTimer timer(ZSubPhasePauseRootsThreads);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   366
  ResourceMark rm;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   367
  Threads::possibly_parallel_oops_do(true, cl, NULL);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   368
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   369
51803
a16777c0a6c5 8210881: ZGC: Introduce ZRootsIteratorClosure
pliden
parents: 51744
diff changeset
   370
void ZThreadRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   371
  ZStatTimer timer(ZSubPhasePauseRoots);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   372
  _threads.oops_do(cl);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   373
}