src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
author stefank
Tue, 26 Nov 2019 10:47:46 +0100
changeset 59290 97d13893ec3c
parent 57837 2227a0cfd6b3
child 58679 9c3209ff7550
child 59296 9186be5c78ba
permissions -rw-r--r--
8234748: Clean up atomic and orderAccess includes Reviewed-by: dholmes
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"
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
    31
#include "gc/shenandoah/shenandoahHeuristics.hpp"
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    32
#include "gc/shenandoah/shenandoahRootProcessor.hpp"
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
    33
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
55082
335f474becde 8224970: ShenandoahRootScanner::roots_do assert is too strong
shade
parents: 54976
diff changeset
    34
#include "gc/shenandoah/shenandoahUtils.hpp"
54976
b1f070f4a4ae 8224579: ResourceMark not declared in shenandoahRootProcessor.inline.hpp with --disable-precompiled-headers
shade
parents: 54940
diff changeset
    35
#include "memory/resourceArea.hpp"
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    36
#include "prims/resolvedMethodTable.hpp"
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
    37
#include "runtime/safepoint.hpp"
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
    38
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
    39
template <bool CONCURRENT>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    40
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
    41
  _itr(storage), _phase(phase) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    42
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    43
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    44
template <bool CONCURRENT>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    45
template <typename Closure>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    46
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
    47
  if (CONCURRENT) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    48
    _itr.oops_do(cl);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    49
  } else {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    50
    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
    51
    ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    52
    _itr.oops_do(cl);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    53
  }
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    54
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    55
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    56
template <bool CONCURRENT>
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    57
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
    58
  ShenandoahVMRoot<CONCURRENT>(storage, phase) {
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    59
}
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
    60
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    61
inline ShenandoahWeakRoot<false>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    62
  _itr(storage), _phase(phase) {
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    63
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    64
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    65
template <typename IsAliveClosure, typename KeepAliveClosure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    66
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
    67
  ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    68
  ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    69
  _itr.weak_oops_do(is_alive, keep_alive);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    70
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    71
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    72
template <bool CONCURRENT>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    73
ShenandoahWeakRoots<CONCURRENT>::ShenandoahWeakRoots() :
57837
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    74
  _jni_roots(OopStorageSet::jni_weak(), ShenandoahPhaseTimings::JNIWeakRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    75
  _string_table_roots(OopStorageSet::string_table_weak(), ShenandoahPhaseTimings::StringTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    76
  _resolved_method_table_roots(OopStorageSet::resolved_method_table_weak(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    77
  _vm_roots(OopStorageSet::vm_weak(), ShenandoahPhaseTimings::VMWeakRoots) {
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    78
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    79
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    80
template <bool CONCURRENT>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    81
template <typename Closure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    82
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
    83
  _jni_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    84
  _string_table_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    85
  _resolved_method_table_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    86
  _vm_roots.oops_do(cl, worker_id);
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    87
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    88
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    89
inline ShenandoahWeakRoots<false /* concurrent */>::ShenandoahWeakRoots() :
57837
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    90
  _jni_roots(OopStorageSet::jni_weak(), ShenandoahPhaseTimings::JNIWeakRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    91
  _string_table_roots(OopStorageSet::string_table_weak(), ShenandoahPhaseTimings::StringTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    92
  _resolved_method_table_roots(OopStorageSet::resolved_method_table_weak(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
    93
  _vm_roots(OopStorageSet::vm_weak(), ShenandoahPhaseTimings::VMWeakRoots) {
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    94
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    95
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    96
template <typename IsAliveClosure, typename KeepAliveClosure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
    97
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
    98
  _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
    99
  _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
   100
  _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
   101
  _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
   102
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   103
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   104
template <typename Closure>
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   105
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
   106
  AlwaysTrueClosure always_true;
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   107
  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
   108
}
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   109
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   110
template <bool CONCURRENT>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   111
ShenandoahVMRoots<CONCURRENT>::ShenandoahVMRoots() :
57837
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
   112
  _jni_handle_roots(OopStorageSet::jni_global(), ShenandoahPhaseTimings::JNIRoots),
2227a0cfd6b3 8229998: Build failure after JDK-8227054
shade
parents: 57732
diff changeset
   113
  _vm_global_roots(OopStorageSet::vm_global(), ShenandoahPhaseTimings::VMGlobalRoots) {
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   114
}
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   115
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   116
template <bool CONCURRENT>
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   117
template <typename T>
57669
18f189e69b29 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently
zgu
parents: 57666
diff changeset
   118
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
   119
  _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
   120
  _vm_global_roots.oops_do(cl, worker_id);
55428
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   121
}
e9da3a44a7ed 8225582: Shenandoah: Enable concurrent evacuation of JNIHandles
zgu
parents: 55395
diff changeset
   122
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   123
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   124
ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::ShenandoahClassLoaderDataRoots() {
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   125
  if (!SINGLE_THREADED) {
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   126
    ClassLoaderDataGraph::clear_claimed_marks();
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   127
  }
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   128
  if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   129
    ClassLoaderDataGraph_lock->lock();
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   130
  }
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   131
}
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   132
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   133
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   134
ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::~ShenandoahClassLoaderDataRoots() {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   135
  if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   136
    ClassLoaderDataGraph_lock->unlock();
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   137
  }
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   138
}
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
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   142
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
   143
  if (SINGLE_THREADED) {
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   144
    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
   145
    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
   146
    ClassLoaderDataGraph::always_strong_cld_do(clds);
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   147
  } else if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   148
     ClassLoaderDataGraph::always_strong_cld_do(clds);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   149
  } else {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   150
   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   151
   ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CLDGRoots, worker_id);
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   152
   ClassLoaderDataGraph::always_strong_cld_do(clds);
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   153
  }
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   154
}
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   155
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   156
template <bool CONCURRENT, bool SINGLE_THREADED>
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   157
void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::cld_do(CLDClosure* clds, uint worker_id) {
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   158
  if (SINGLE_THREADED) {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   159
    assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   160
    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
   161
    ClassLoaderDataGraph::cld_do(clds);
55477
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   162
  } else if (CONCURRENT) {
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   163
    ClassLoaderDataGraph::cld_do(clds);
c396e381cfa4 8226310: Shenandoah: Concurrent evacuation of CLDG
zgu
parents: 55476
diff changeset
   164
  }  else {
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   165
    ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   166
    ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CLDGRoots, worker_id);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   167
    ClassLoaderDataGraph::cld_do(clds);
55444
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   168
  }
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   169
}
6a7d6b6bbd78 8226413: Shenandoah: Separate root scanner for SH::object_iterate()
zgu
parents: 55428
diff changeset
   170
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   171
template <typename ITR>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   172
ShenandoahCodeCacheRoots<ITR>::ShenandoahCodeCacheRoots() {
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   173
  nmethod::oops_do_marking_prologue();
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   174
}
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   175
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   176
template <typename ITR>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   177
void ShenandoahCodeCacheRoots<ITR>::code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id) {
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   178
  ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   179
  ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   180
  _coderoots_iterator.possibly_parallel_blobs_do(blob_cl);
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   181
}
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   182
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   183
template <typename ITR>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   184
ShenandoahCodeCacheRoots<ITR>::~ShenandoahCodeCacheRoots() {
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   185
  nmethod::oops_do_marking_epilogue();
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   186
}
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   187
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   188
class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   189
private:
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   190
  OopClosure* _f;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   191
  CodeBlobClosure* _cf;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   192
  ThreadClosure* _thread_cl;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   193
public:
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   194
  ShenandoahParallelOopsDoThreadClosure(OopClosure* f, CodeBlobClosure* cf, ThreadClosure* thread_cl) :
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   195
    _f(f), _cf(cf), _thread_cl(thread_cl) {}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   196
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   197
  void do_thread(Thread* t) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   198
    if (_thread_cl != NULL) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   199
      _thread_cl->do_thread(t);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   200
    }
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   201
    t->oops_do(_f, _cf);
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
};
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
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   206
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
   207
  ShenandoahRootProcessor(phase),
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   208
  _thread_roots(n_workers > 1) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   209
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   210
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   211
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   212
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
   213
  CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   214
  MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   215
  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
   216
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   217
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   218
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   219
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
   220
  CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   221
  MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   222
  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
   223
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   224
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   225
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   226
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
   227
  assert(!ShenandoahSafepoint::is_at_shenandoah_safepoint() ||
335f474becde 8224970: ShenandoahRootScanner::roots_do assert is too strong
shade
parents: 54976
diff changeset
   228
         !ShenandoahHeap::heap()->unload_classes() ||
55587
4644b3155fce 8226757: Shenandoah: Make traversal and passive modes explicit
rkennke
parents: 55477
diff changeset
   229
          ShenandoahHeap::heap()->is_traversal_mode(),
55082
335f474becde 8224970: ShenandoahRootScanner::roots_do assert is too strong
shade
parents: 54976
diff changeset
   230
          "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
   231
  ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   232
  ResourceMark rm;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   233
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   234
  _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
   235
  _vm_roots.oops_do(oops, worker_id);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   236
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   237
  if (clds != NULL) {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   238
    _cld_roots.cld_do(clds, worker_id);
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   239
  } else {
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   240
    assert(ShenandoahHeap::heap()->is_concurrent_traversal_in_progress(), "Only possible with traversal GC");
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   241
  }
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   242
54940
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   243
  _thread_roots.threads_do(&tc_cl, worker_id);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   244
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   245
  // 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
   246
  // 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
   247
  // pause time.
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   248
  if (code != NULL && !ShenandoahConcurrentScanCodeRoots) {
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   249
    _code_roots.code_blobs_do(code, worker_id);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   250
  }
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   251
}
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
template <typename ITR>
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   254
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
   255
  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
   256
  ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   257
  ResourceMark rm;
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   258
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   259
  _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
   260
  _vm_roots.oops_do(oops, worker_id);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   261
  _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
   262
  _thread_roots.threads_do(&tc_cl, worker_id);
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   263
}
2d90a0988c95 8224210: Shenandoah: Refactor ShenandoahRootScanner to support scanning CSet codecache roots
zgu
parents: 54924
diff changeset
   264
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   265
template <typename IsAlive, typename KeepAlive>
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   266
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
   267
  CodeBlobToOopClosure update_blobs(keep_alive, CodeBlobToOopClosure::FixRelocations);
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   268
  CLDToOopClosure clds(keep_alive, ClassLoaderData::_claim_strong);
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   269
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   270
  _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
   271
  _vm_roots.oops_do(keep_alive, worker_id);
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   272
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   273
  _thread_roots.oops_do(keep_alive, NULL, worker_id);
55450
79a7fc6c9bc7 8225590: Shenandoah: Refactor ShenandoahClassLoaderDataRoots API
zgu
parents: 55444
diff changeset
   274
  _cld_roots.cld_do(&clds, worker_id);
57732
23e13076e102 8229474: Shenandoah: Cleanup CM::update_roots()
zgu
parents: 57669
diff changeset
   275
  _code_roots.code_blobs_do(&update_blobs, worker_id);
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   276
55476
aee0d296c0ef 8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents: 55450
diff changeset
   277
  _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
   278
  _weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);
54924
ba1eccda5450 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family
zgu
parents: 54344
diff changeset
   279
  _dedup_roots.oops_do(is_alive, keep_alive, worker_id);
54344
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   280
}
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   281
8cd2af66ac7c 8221629: Shenandoah: Cleanup class unloading logic
zgu
parents:
diff changeset
   282
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP