|
1 /* |
|
2 * Copyright (c) 2017, 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 #ifndef SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP |
|
26 #define SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP |
|
27 |
|
28 #include "memory/allocation.hpp" |
|
29 #include "memory/iterator.hpp" |
|
30 |
|
31 // Helper class to aid in root scanning and cleaning of weak oops in the VM. |
|
32 // |
|
33 // New containers of weak oops added to this class will automatically |
|
34 // be cleaned by all GCs, including the young generation GCs. |
|
35 class WeakProcessor : AllStatic { |
|
36 public: |
|
37 // Visit all oop*s and apply the keep_alive closure if the referenced |
|
38 // object is considered alive by the is_alive closure, otherwise do some |
|
39 // container specific cleanup of element holding the oop. |
|
40 // |
|
41 // The complete closure is used as a post-processing step, |
|
42 // called after all container have been processed. |
|
43 static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, VoidClosure* complete = NULL); |
|
44 |
|
45 // Visit all oop*s and apply the given closure. |
|
46 static void oops_do(OopClosure* closure); |
|
47 }; |
|
48 |
|
49 #endif // SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP |