author | eosterlund |
Fri, 08 Jun 2018 11:30:10 +0200 | |
changeset 50470 | f3aac763a315 |
parent 50445 | bd6b78feb6a3 |
child 52853 | 0e2e67902add |
permissions | -rw-r--r-- |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
1 |
/* |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
4 |
* |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
8 |
* |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
14 |
* |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
18 |
* |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
21 |
* questions. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
22 |
* |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
23 |
*/ |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
24 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
25 |
#ifndef SHARE_VM_OOPS_WEAKHANDLE_HPP |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
26 |
#define SHARE_VM_OOPS_WEAKHANDLE_HPP |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
27 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
28 |
#include "oops/oop.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
29 |
#include "runtime/handles.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
30 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
31 |
class outputStream; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
32 |
class OopStorage; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
33 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
34 |
// A WeakHandle is a pointer to an oop that is stored in an OopStorage that is |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
35 |
// processed weakly by GC. The runtime structures that point to the oop must |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
36 |
// either peek or resolve the oop, the latter will keep the oop alive for |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
37 |
// the GC cycle. The runtime structures that reference the oop must test |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
38 |
// if the value is NULL. If it is NULL, it has been cleaned out by GC. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
39 |
// This is the vm version of jweak but has different GC lifetimes and policies, |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
40 |
// depending on the type. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
41 |
|
50445
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49818
diff
changeset
|
42 |
enum WeakHandleType { vm_class_loader_data, vm_string, vm_string_table_data }; |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
43 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
44 |
template <WeakHandleType T> |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
45 |
class WeakHandle { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
46 |
public: |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
47 |
private: |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
48 |
oop* _obj; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
49 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
50 |
WeakHandle(oop* w) : _obj(w) {} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
51 |
static OopStorage* get_storage(); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
52 |
public: |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
53 |
WeakHandle() : _obj(NULL) {} // needed for init |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
54 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
55 |
static WeakHandle create(Handle obj); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
56 |
inline oop resolve() const; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
57 |
inline oop peek() const; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
58 |
void release() const; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
59 |
bool is_null() const { return _obj == NULL; } |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
60 |
|
50445
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49818
diff
changeset
|
61 |
void replace(oop with_obj); |
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49818
diff
changeset
|
62 |
|
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
63 |
void print() const; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
64 |
void print_on(outputStream* st) const; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
65 |
}; |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
66 |
|
49818
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
49738
diff
changeset
|
67 |
typedef WeakHandle<vm_class_loader_data> ClassLoaderWeakHandle; |
e57e6addb978
8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents:
49738
diff
changeset
|
68 |
|
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
69 |
#endif // SHARE_VM_OOPS_WEAKHANDLE_HPP |