author | coleenp |
Wed, 24 Jul 2019 10:22:11 -0400 | |
changeset 57511 | 00ae3b739184 |
parent 54511 | fbfcebad8e66 |
child 57828 | 35db8fba55f9 |
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 |
#include "precompiled.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
26 |
#include "classfile/systemDictionary.hpp" |
50445
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49824
diff
changeset
|
27 |
#include "classfile/stringTable.hpp" |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
28 |
#include "gc/shared/oopStorage.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
29 |
#include "oops/access.inline.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
30 |
#include "oops/oop.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
31 |
#include "oops/weakHandle.inline.hpp" |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
50599
diff
changeset
|
32 |
#include "prims/resolvedMethodTable.hpp" |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
33 |
#include "utilities/debug.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
34 |
#include "utilities/ostream.hpp" |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
35 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
36 |
template <> OopStorage* WeakHandle<vm_class_loader_data>::get_storage() { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
37 |
return SystemDictionary::vm_weak_oop_storage(); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
38 |
} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
39 |
|
50445
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49824
diff
changeset
|
40 |
template <> OopStorage* WeakHandle<vm_string_table_data>::get_storage() { |
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49824
diff
changeset
|
41 |
return StringTable::weak_storage(); |
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49824
diff
changeset
|
42 |
} |
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49824
diff
changeset
|
43 |
|
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
50599
diff
changeset
|
44 |
template <> OopStorage* WeakHandle<vm_resolved_method_table_data>::get_storage() { |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
50599
diff
changeset
|
45 |
return ResolvedMethodTable::weak_storage(); |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
50599
diff
changeset
|
46 |
} |
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
50599
diff
changeset
|
47 |
|
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
48 |
template <WeakHandleType T> |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
49 |
WeakHandle<T> WeakHandle<T>::create(Handle obj) { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
50 |
assert(obj() != NULL, "no need to create weak null oop"); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
51 |
oop* oop_addr = get_storage()->allocate(); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
52 |
if (oop_addr == NULL) { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
53 |
vm_exit_out_of_memory(sizeof(oop*), OOM_MALLOC_ERROR, "Unable to create new weak oop handle in OopStorage"); |
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 |
// Create WeakHandle with address returned and store oop into it. |
50599
ecc2af326b5f
8204939: Change Access nomenclature: root to native
kbarrett
parents:
50445
diff
changeset
|
56 |
NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(oop_addr, obj()); |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
57 |
return WeakHandle(oop_addr); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
58 |
} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
59 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
60 |
template <WeakHandleType T> |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
61 |
void WeakHandle<T>::release() const { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
62 |
// Only release if the pointer to the object has been created. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
63 |
if (_obj != NULL) { |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49738
diff
changeset
|
64 |
// Clear the WeakHandle. For race in creating ClassLoaderData, we can release this |
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49738
diff
changeset
|
65 |
// WeakHandle before it is cleared by GC. |
50599
ecc2af326b5f
8204939: Change Access nomenclature: root to native
kbarrett
parents:
50445
diff
changeset
|
66 |
NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(_obj, (oop)NULL); |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
67 |
get_storage()->release(_obj); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
68 |
} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
69 |
} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
70 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
71 |
template <WeakHandleType T> |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
72 |
void WeakHandle<T>::print() const { print_on(tty); } |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
73 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
74 |
template <WeakHandleType T> |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
75 |
void WeakHandle<T>::print_on(outputStream* st) const { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
76 |
st->print("WeakHandle: " PTR_FORMAT, p2i(peek())); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
77 |
} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
78 |
|
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
79 |
// Provide instantiation. |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
diff
changeset
|
80 |
template class WeakHandle<vm_class_loader_data>; |
50445
bd6b78feb6a3
8195097: Make it possible to process StringTable outside safepoint
rehn
parents:
49824
diff
changeset
|
81 |
template class WeakHandle<vm_string_table_data>; |
54511
fbfcebad8e66
8221393: ResolvedMethodTable too small for StackWalking applications
stefank
parents:
50599
diff
changeset
|
82 |
template class WeakHandle<vm_resolved_method_table_data>; |