src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
author zgu
Wed, 27 Nov 2019 11:52:57 -0500
changeset 59296 9186be5c78ba
parent 57837 2227a0cfd6b3
permissions -rw-r--r--
8228720: Shenandoah: Implementation of concurrent class unloading Reviewed-by: rkennke
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     1
/*
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     2
 * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     3
 *
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     6
 * published by the Free Software Foundation.
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     7
 *
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    12
 * accompanied this code).
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    13
 *
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    17
 *
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    18
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    19
 * or visit www.oracle.com if you need additional information or have any
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    20
 * questions.
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    21
 *
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    22
 */
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    23
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    24
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    25
#define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    26
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
    27
#include "classfile/classLoaderDataGraph.hpp"
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    28
#include "classfile/stringTable.hpp"
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    29
#include "classfile/systemDictionary.hpp"
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
    30
#include "gc/shared/oopStorageParState.inline.hpp"
59296
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
    31
#include "gc/shenandoah/shenandoahClosures.inline.hpp"
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
    32
#include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
    33
#include "gc/shenandoah/shenandoahHeuristics.hpp"
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    34
#include "gc/shenandoah/shenandoahRootProcessor.hpp"
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
    35
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
55082
335f474becde 8224970: ShenandoahRootScanner::roots_do assert is too strong
shade
parents: 54976
diff changeset
    36
#include "gc/shenandoah/shenandoahUtils.hpp"
54976
b1f070f4a4ae 8224579: ResourceMark not declared in shenandoahRootProcessor.inline.hpp with --disable-precompiled-headers
shade
parents: 54940
diff changeset
    37
#include "memory/resourceArea.hpp"
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    38
#include "prims/resolvedMethodTable.hpp"
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
    39
#include "runtime/safepoint.hpp"
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    40
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
    41
template <bool CONCURRENT>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    42
inline ShenandoahVMRoot<CONCURRENT>::ShenandoahVMRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    43
  _itr(storage), _phase(phase) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    44
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    45
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    46
template <bool CONCURRENT>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    47
template <typename Closure>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    48
inline void ShenandoahVMRoot<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    49
  if (CONCURRENT) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    50
    _itr.oops_do(cl);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    51
  } else {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    52
    ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
57666
850f456d1e22 8229206: Shenandoah: ShenandoahWeakRoot::oops_do() uses wrong timing phase
zgu
parents: 55587
diff changeset
    53
    ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    54
    _itr.oops_do(cl);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    55
  }
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    56
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    57
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    58
template <bool CONCURRENT>
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    59
inline ShenandoahWeakRoot<CONCURRENT>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    60
  ShenandoahVMRoot<CONCURRENT>(storage, phase) {
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    61
}
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    62
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    63
inline ShenandoahWeakRoot<false>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    64
  _itr(storage), _phase(phase) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    65
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    66
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    67
template <typename IsAliveClosure, typename KeepAliveClosure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    68
void ShenandoahWeakRoot<false /* concurrent */>::weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    69
  ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    70
  ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    71
  _itr.weak_oops_do(is_alive, keep_alive);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    72
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    73
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    74
template <bool CONCURRENT>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    75
ShenandoahWeakRoots<CONCURRENT>::ShenandoahWeakRoots() :
57837
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    76
  _jni_roots(OopStorageSet::jni_weak(), ShenandoahPhaseTimings::JNIWeakRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    77
  _string_table_roots(OopStorageSet::string_table_weak(), ShenandoahPhaseTimings::StringTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    78
  _resolved_method_table_roots(OopStorageSet::resolved_method_table_weak(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    79
  _vm_roots(OopStorageSet::vm_weak(), ShenandoahPhaseTimings::VMWeakRoots) {
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    80
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    81
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    82
template <bool CONCURRENT>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    83
template <typename Closure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    84
void ShenandoahWeakRoots<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    85
  _jni_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    86
  _string_table_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    87
  _resolved_method_table_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    88
  _vm_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    89
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    90
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    91
inline ShenandoahWeakRoots<false /* concurrent */>::ShenandoahWeakRoots() :
57837
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    92
  _jni_roots(OopStorageSet::jni_weak(), ShenandoahPhaseTimings::JNIWeakRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    93
  _string_table_roots(OopStorageSet::string_table_weak(), ShenandoahPhaseTimings::StringTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    94
  _resolved_method_table_roots(OopStorageSet::resolved_method_table_weak(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    95
  _vm_roots(OopStorageSet::vm_weak(), ShenandoahPhaseTimings::VMWeakRoots) {
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    96
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    97
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    98
template <typename IsAliveClosure, typename KeepAliveClosure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    99
void ShenandoahWeakRoots<false /* concurrent*/>::weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   100
  _jni_roots.weak_oops_do(is_alive, keep_alive, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   101
  _string_table_roots.weak_oops_do(is_alive, keep_alive, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   102
  _resolved_method_table_roots.weak_oops_do(is_alive, keep_alive, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   103
  _vm_roots.weak_oops_do(is_alive, keep_alive, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   104
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   105
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   106
template <typename Closure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   107
void ShenandoahWeakRoots<false /* concurrent */>::oops_do(Closure* cl, uint worker_id) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   108
  AlwaysTrueClosure always_true;
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   109
  weak_oops_do<AlwaysTrueClosure, Closure>(&always_true, cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   110
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   111
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   112
template <bool CONCURRENT>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   113
ShenandoahVMRoots<CONCURRENT>::ShenandoahVMRoots() :
57837
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
   114
  _jni_handle_roots(OopStorageSet::jni_global(), ShenandoahPhaseTimings::JNIRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
   115
  _vm_global_roots(OopStorageSet::vm_global(), ShenandoahPhaseTimings::VMGlobalRoots) {
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   116
}
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   117
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   118
template <bool CONCURRENT>
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   119
template <typename T>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   120
void ShenandoahVMRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   121
  _jni_handle_roots.oops_do(cl, worker_id);
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   122
  _vm_global_roots.oops_do(cl, worker_id);
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   123
}
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   124
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   125
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   126
ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::ShenandoahClassLoaderDataRoots() {
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   127
  if (!SINGLE_THREADED) {
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   128
    ClassLoaderDataGraph::clear_claimed_marks();
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   129
  }
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   130
  if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   131
    ClassLoaderDataGraph_lock->lock();
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   132
  }
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   133
}
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   134
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   135
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   136
ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::~ShenandoahClassLoaderDataRoots() {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   137
  if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   138
    ClassLoaderDataGraph_lock->unlock();
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   139
  }
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   140
}
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   141
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   142
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   143
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   144
void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::always_strong_cld_do(CLDClosure* clds, uint worker_id) {
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   145
  if (SINGLE_THREADED) {
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   146
    assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   147
    assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   148
    ClassLoaderDataGraph::always_strong_cld_do(clds);
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   149
  } else if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   150
     ClassLoaderDataGraph::always_strong_cld_do(clds);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   151
  } else {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   152
   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   153
   ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CLDGRoots, worker_id);
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   154
   ClassLoaderDataGraph::always_strong_cld_do(clds);
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   155
  }
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   156
}
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   157
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   158
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   159
void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::cld_do(CLDClosure* clds, uint worker_id) {
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   160
  if (SINGLE_THREADED) {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   161
    assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   162
    assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   163
    ClassLoaderDataGraph::cld_do(clds);
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   164
  } else if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   165
    ClassLoaderDataGraph::cld_do(clds);
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   166
  }  else {
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   167
    ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   168
    ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CLDGRoots, worker_id);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   169
    ClassLoaderDataGraph::cld_do(clds);
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   170
  }
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   171
}
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   172
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   173
template <typename ITR>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   174
ShenandoahCodeCacheRoots<ITR>::ShenandoahCodeCacheRoots() {
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   175
  nmethod::oops_do_marking_prologue();
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   176
}
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   177
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   178
template <typename ITR>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   179
void ShenandoahCodeCacheRoots<ITR>::code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id) {
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   180
  ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   181
  ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   182
  _coderoots_iterator.possibly_parallel_blobs_do(blob_cl);
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   183
}
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   184
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   185
template <typename ITR>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   186
ShenandoahCodeCacheRoots<ITR>::~ShenandoahCodeCacheRoots() {
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   187
  nmethod::oops_do_marking_epilogue();
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   188
}
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   189
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   190
class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   191
private:
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   192
  OopClosure* _f;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   193
  CodeBlobClosure* _cf;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   194
  ThreadClosure* _thread_cl;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   195
public:
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   196
  ShenandoahParallelOopsDoThreadClosure(OopClosure* f, CodeBlobClosure* cf, ThreadClosure* thread_cl) :
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   197
    _f(f), _cf(cf), _thread_cl(thread_cl) {}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   198
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   199
  void do_thread(Thread* t) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   200
    if (_thread_cl != NULL) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   201
      _thread_cl->do_thread(t);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   202
    }
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   203
    t->oops_do(_f, _cf);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   204
  }
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   205
};
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   206
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   207
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   208
ShenandoahRootScanner<ITR>::ShenandoahRootScanner(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   209
  ShenandoahRootProcessor(phase),
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   210
  _thread_roots(n_workers > 1) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   211
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   212
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   213
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   214
void ShenandoahRootScanner<ITR>::roots_do(uint worker_id, OopClosure* oops) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   215
  CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   216
  MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   217
  roots_do(worker_id, oops, &clds_cl, &blobs_cl);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   218
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   219
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   220
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   221
void ShenandoahRootScanner<ITR>::strong_roots_do(uint worker_id, OopClosure* oops) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   222
  CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   223
  MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   224
  strong_roots_do(worker_id, oops, &clds_cl, &blobs_cl);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   225
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   226
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   227
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   228
void ShenandoahRootScanner<ITR>::roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure *tc) {
55082
335f474becde 8224970: ShenandoahRootScanner::roots_do assert is too strong
shade
parents: 54976
diff changeset
   229
  assert(!ShenandoahSafepoint::is_at_shenandoah_safepoint() ||
335f474becde 8224970: ShenandoahRootScanner::roots_do assert is too strong
shade
parents: 54976
diff changeset
   230
         !ShenandoahHeap::heap()->unload_classes() ||
55587
4644b3155fce 8226757: Shenandoah: Make traversal and passive modes explicit
rkennke
parents: 55477
diff changeset
   231
          ShenandoahHeap::heap()->is_traversal_mode(),
55082
335f474becde 8224970: ShenandoahRootScanner::roots_do assert is too strong
shade
parents: 54976
diff changeset
   232
          "Expect class unloading or traversal when Shenandoah cycle is running");
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   233
  ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   234
  ResourceMark rm;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   235
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   236
  _serial_roots.oops_do(oops, worker_id);
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   237
  _vm_roots.oops_do(oops, worker_id);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   238
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   239
  if (clds != NULL) {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   240
    _cld_roots.cld_do(clds, worker_id);
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   241
  } else {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   242
    assert(ShenandoahHeap::heap()->is_concurrent_traversal_in_progress(), "Only possible with traversal GC");
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   243
  }
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   244
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   245
  _thread_roots.threads_do(&tc_cl, worker_id);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   246
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   247
  // With ShenandoahConcurrentScanCodeRoots, we avoid scanning the entire code cache here,
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   248
  // and instead do that in concurrent phase under the relevant lock. This saves init mark
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   249
  // pause time.
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   250
  if (code != NULL && !ShenandoahConcurrentScanCodeRoots) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   251
    _code_roots.code_blobs_do(code, worker_id);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   252
  }
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   253
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   254
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   255
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   256
void ShenandoahRootScanner<ITR>::strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   257
  assert(ShenandoahHeap::heap()->unload_classes(), "Should be used during class unloading");
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   258
  ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   259
  ResourceMark rm;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   260
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   261
  _serial_roots.oops_do(oops, worker_id);
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   262
  _vm_roots.oops_do(oops, worker_id);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   263
  _cld_roots.always_strong_cld_do(clds, worker_id);
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   264
  _thread_roots.threads_do(&tc_cl, worker_id);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   265
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   266
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   267
template <typename IsAlive, typename KeepAlive>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   268
void ShenandoahRootUpdater::roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive) {
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   269
  CodeBlobToOopClosure update_blobs(keep_alive, CodeBlobToOopClosure::FixRelocations);
59296
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
   270
  ShenandoahCodeBlobAndDisarmClosure blobs_and_disarm_Cl(keep_alive);
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
   271
  CodeBlobToOopClosure* codes_cl = ShenandoahConcurrentRoots::can_do_concurrent_class_unloading() ?
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
   272
                                  static_cast<CodeBlobToOopClosure*>(&blobs_and_disarm_Cl) :
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
   273
                                  static_cast<CodeBlobToOopClosure*>(&update_blobs);
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
   274
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   275
  CLDToOopClosure clds(keep_alive, ClassLoaderData::_claim_strong);
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   276
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   277
  _serial_roots.oops_do(keep_alive, worker_id);
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   278
  _vm_roots.oops_do(keep_alive, worker_id);
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   279
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   280
  _cld_roots.cld_do(&clds, worker_id);
57732
23e13076e102 8229474: Shenandoah: Cleanup CM::update_roots()
zgu
parents: 57669
diff changeset
   281
  _code_roots.code_blobs_do(&update_blobs, worker_id);
59296
9186be5c78ba 8228720: Shenandoah: Implementation of concurrent class unloading
zgu
parents: 57837
diff changeset
   282
  _thread_roots.oops_do(keep_alive, NULL, worker_id);
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   283
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   284
  _serial_weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   285
  _weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   286
  _dedup_roots.oops_do(is_alive, keep_alive, worker_id);
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   287
}
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   288
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   289
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP