57510
|
1 |
/*
|
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include "precompiled.hpp"
|
|
26 |
|
|
27 |
#include "gc/g1/g1ParallelCleaning.hpp"
|
|
28 |
#if INCLUDE_JVMCI
|
|
29 |
#include "jvmci/jvmci.hpp"
|
|
30 |
#endif
|
|
31 |
|
|
32 |
#if INCLUDE_JVMCI
|
|
33 |
JVMCICleaningTask::JVMCICleaningTask() :
|
|
34 |
_cleaning_claimed(0) {
|
|
35 |
}
|
|
36 |
|
|
37 |
bool JVMCICleaningTask::claim_cleaning_task() {
|
|
38 |
if (_cleaning_claimed) {
|
|
39 |
return false;
|
|
40 |
}
|
|
41 |
|
|
42 |
return Atomic::cmpxchg(1, &_cleaning_claimed, 0) == 0;
|
|
43 |
}
|
|
44 |
|
|
45 |
void JVMCICleaningTask::work(bool unloading_occurred) {
|
|
46 |
// One worker will clean JVMCI metadata handles.
|
|
47 |
if (unloading_occurred && EnableJVMCI && claim_cleaning_task()) {
|
|
48 |
JVMCI::do_unloading(unloading_occurred);
|
|
49 |
}
|
|
50 |
}
|
|
51 |
#endif // INCLUDE_JVMCI
|
|
52 |
|
|
53 |
G1ParallelCleaningTask::G1ParallelCleaningTask(BoolObjectClosure* is_alive,
|
|
54 |
uint num_workers,
|
|
55 |
bool unloading_occurred,
|
|
56 |
bool resize_dedup_table) :
|
|
57 |
AbstractGangTask("G1 Parallel Cleaning"),
|
|
58 |
_unloading_occurred(unloading_occurred),
|
|
59 |
_string_dedup_task(is_alive, NULL, resize_dedup_table),
|
|
60 |
_code_cache_task(num_workers, is_alive, unloading_occurred),
|
|
61 |
JVMCI_ONLY(_jvmci_cleaning_task() COMMA)
|
|
62 |
_klass_cleaning_task() {
|
|
63 |
}
|
|
64 |
|
|
65 |
// The parallel work done by all worker threads.
|
|
66 |
void G1ParallelCleaningTask::work(uint worker_id) {
|
|
67 |
// Clean JVMCI metadata handles.
|
|
68 |
// Execute this task first because it is serial task.
|
|
69 |
JVMCI_ONLY(_jvmci_cleaning_task.work(_unloading_occurred);)
|
|
70 |
|
|
71 |
// Do first pass of code cache cleaning.
|
|
72 |
_code_cache_task.work(worker_id);
|
|
73 |
|
|
74 |
// Clean the string dedup data structures.
|
|
75 |
_string_dedup_task.work(worker_id);
|
|
76 |
|
|
77 |
// Clean all klasses that were not unloaded.
|
|
78 |
// The weak metadata in klass doesn't need to be
|
|
79 |
// processed if there was no unloading.
|
|
80 |
if (_unloading_occurred) {
|
|
81 |
_klass_cleaning_task.work();
|
|
82 |
}
|
|
83 |
}
|