author | coleenp |
Tue, 26 Sep 2017 10:03:17 -0400 | |
changeset 47532 | d8e417df3468 |
parent 47216 | 71c04702a3d5 |
child 47549 | 0a0fae0c05ac |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46324
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
39398
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
26 |
#include "classfile/classLoaderData.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28741
diff
changeset
|
27 |
#include "classfile/javaClasses.inline.hpp" |
15430
7c35f12cf1e5
8006040: NPG: on_stack processing wastes space in ConstantPool
coleenp
parents:
15229
diff
changeset
|
28 |
#include "classfile/metadataOnStackMark.hpp" |
24426
0a69c8cdfca9
8038654: Separate SymbolTable and StringTable code
gziemski
parents:
24334
diff
changeset
|
29 |
#include "classfile/stringTable.hpp" |
7397 | 30 |
#include "classfile/systemDictionary.hpp" |
31 |
#include "classfile/vmSymbols.hpp" |
|
32 |
#include "interpreter/linkResolver.hpp" |
|
15437 | 33 |
#include "memory/heapInspection.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
34 |
#include "memory/metadataFactory.hpp" |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
35 |
#include "memory/metaspaceClosure.hpp" |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
36 |
#include "memory/metaspaceShared.hpp" |
7397 | 37 |
#include "memory/oopFactory.hpp" |
37248 | 38 |
#include "memory/resourceArea.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
39 |
#include "oops/constantPool.hpp" |
7397 | 40 |
#include "oops/instanceKlass.hpp" |
41 |
#include "oops/objArrayKlass.hpp" |
|
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28741
diff
changeset
|
42 |
#include "oops/objArrayOop.inline.hpp" |
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28741
diff
changeset
|
43 |
#include "oops/oop.inline.hpp" |
46560
388aa8d67c80
8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
46427
diff
changeset
|
44 |
#include "prims/jvm.h" |
7397 | 45 |
#include "runtime/fieldType.hpp" |
46 |
#include "runtime/init.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
47 |
#include "runtime/javaCalls.hpp" |
7397 | 48 |
#include "runtime/signature.hpp" |
49 |
#include "runtime/vframe.hpp" |
|
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28741
diff
changeset
|
50 |
#include "utilities/copy.hpp" |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
51 |
#if INCLUDE_ALL_GCS |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
52 |
#include "gc/g1/g1SATBCardTableModRefBS.hpp" |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
53 |
#endif // INCLUDE_ALL_GCS |
1 | 54 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
55 |
ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
56 |
Array<u1>* tags = MetadataFactory::new_array<u1>(loader_data, length, 0, CHECK_NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
57 |
int size = ConstantPool::size(length); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
58 |
return new (loader_data, size, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
59 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
60 |
|
34666 | 61 |
#ifdef ASSERT |
15430
7c35f12cf1e5
8006040: NPG: on_stack processing wastes space in ConstantPool
coleenp
parents:
15229
diff
changeset
|
62 |
|
34666 | 63 |
// MetaspaceObj allocation invariant is calloc equivalent memory |
64 |
// simple verification of this here (JVM_CONSTANT_Invalid == 0 ) |
|
65 |
static bool tag_array_is_zero_initialized(Array<u1>* tags) { |
|
66 |
assert(tags != NULL, "invariant"); |
|
67 |
const int length = tags->length(); |
|
68 |
for (int index = 0; index < length; ++index) { |
|
69 |
if (JVM_CONSTANT_Invalid != tags->at(index)) { |
|
70 |
return false; |
|
71 |
} |
|
72 |
} |
|
73 |
return true; |
|
74 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
75 |
|
34666 | 76 |
#endif |
77 |
||
78 |
ConstantPool::ConstantPool(Array<u1>* tags) : |
|
79 |
_tags(tags), |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
80 |
_length(tags->length()) { |
34666 | 81 |
|
82 |
assert(_tags != NULL, "invariant"); |
|
83 |
assert(tags->length() == _length, "invariant"); |
|
84 |
assert(tag_array_is_zero_initialized(tags), "invariant"); |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
85 |
assert(0 == flags(), "invariant"); |
34666 | 86 |
assert(0 == version(), "invariant"); |
87 |
assert(NULL == _pool_holder, "invariant"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
88 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
89 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
90 |
void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) { |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
91 |
if (cache() != NULL) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
92 |
MetadataFactory::free_metadata(loader_data, cache()); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
93 |
set_cache(NULL); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
94 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
95 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
96 |
MetadataFactory::free_array<Klass*>(loader_data, resolved_klasses()); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
97 |
set_resolved_klasses(NULL); |
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
22539
diff
changeset
|
98 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
99 |
MetadataFactory::free_array<jushort>(loader_data, operands()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
100 |
set_operands(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
101 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
102 |
release_C_heap_structures(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
103 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
104 |
// free tag array |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
105 |
MetadataFactory::free_array<u1>(loader_data, tags()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
106 |
set_tags(NULL); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
107 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
108 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
109 |
void ConstantPool::release_C_heap_structures() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
110 |
// walk constant pool and decrement symbol reference counts |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
111 |
unreference_symbols(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
112 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
113 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
114 |
void ConstantPool::metaspace_pointers_do(MetaspaceClosure* it) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
115 |
log_trace(cds)("Iter(ConstantPool): %p", this); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
116 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
117 |
it->push(&_tags, MetaspaceClosure::_writable); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
118 |
it->push(&_cache); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
119 |
it->push(&_pool_holder); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
120 |
it->push(&_operands); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
121 |
it->push(&_resolved_klasses, MetaspaceClosure::_writable); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
122 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
123 |
for (int i = 0; i < length(); i++) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
124 |
// The only MSO's embedded in the CP entries are Symbols: |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
125 |
// JVM_CONSTANT_String (normal and pseudo) |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
126 |
// JVM_CONSTANT_Utf8 |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
127 |
constantTag ctag = tag_at(i); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
128 |
if (ctag.is_string() || ctag.is_utf8()) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
129 |
it->push(symbol_at_addr(i)); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
130 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
131 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
132 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
133 |
|
31046
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
134 |
objArrayOop ConstantPool::resolved_references() const { |
46961
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46816
diff
changeset
|
135 |
return (objArrayOop)_cache->resolved_references(); |
31046
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
136 |
} |
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
137 |
|
47532
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
138 |
// Called from outside constant pool resolution where a resolved_reference array |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
139 |
// may not be present. |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
140 |
objArrayOop ConstantPool::resolved_references_or_null() const { |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
141 |
if (_cache == NULL) { |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
142 |
return NULL; |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
143 |
} else { |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
144 |
return (objArrayOop)_cache->resolved_references(); |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
145 |
} |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
146 |
} |
d8e417df3468
8081323: ConstantPool::_resolved_references is missing in heap dump
coleenp
parents:
47216
diff
changeset
|
147 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
148 |
// Create resolved_references array and mapping array for original cp indexes |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
149 |
// The ldc bytecode was rewritten to have the resolved reference array index so need a way |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
150 |
// to map it back for resolving and some unlikely miscellaneous uses. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
151 |
// The objects created by invokedynamic are appended to this list. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
152 |
void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data, |
33232
75e0112d3eb5
8140452: Internal Error memory/allocation.cpp:179
mgerdin
parents:
33148
diff
changeset
|
153 |
const intStack& reference_map, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
154 |
int constant_pool_map_length, |
20063
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
155 |
TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
156 |
// Initialized the resolved object cache. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
157 |
int map_length = reference_map.length(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
158 |
if (map_length > 0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
159 |
// Only need mapping back to constant pool entries. The map isn't used for |
20063
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
160 |
// invokedynamic resolved_reference entries. For invokedynamic entries, |
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
161 |
// the constant pool cache index has the mapping back to both the constant |
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
162 |
// pool and to the resolved reference index. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
163 |
if (constant_pool_map_length > 0) { |
20063
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
164 |
Array<u2>* om = MetadataFactory::new_array<u2>(loader_data, constant_pool_map_length, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
165 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
166 |
for (int i = 0; i < constant_pool_map_length; i++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
167 |
int x = reference_map.at(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
168 |
assert(x == (int)(jushort) x, "klass index is too big"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
169 |
om->at_put(i, (jushort)x); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
170 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
171 |
set_reference_map(om); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
172 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
173 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
174 |
// Create Java array for holding resolved strings, methodHandles, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
175 |
// methodTypes, invokedynamic and invokehandle appendix objects, etc. |
31046
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
176 |
objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK); |
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
177 |
Handle refs_handle (THREAD, (oop)stom); // must handleize. |
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
178 |
set_resolved_references(loader_data->add_handle(refs_handle)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
179 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
180 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
181 |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
182 |
void ConstantPool::allocate_resolved_klasses(ClassLoaderData* loader_data, int num_klasses, TRAPS) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
183 |
// A ConstantPool can't possibly have 0xffff valid class entries, |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
184 |
// because entry #0 must be CONSTANT_Invalid, and each class entry must refer to a UTF8 |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
185 |
// entry for the class's name. So at most we will have 0xfffe class entries. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
186 |
// This allows us to use 0xffff (ConstantPool::_temp_resolved_klass_index) to indicate |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
187 |
// UnresolvedKlass entries that are temporarily created during class redefinition. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
188 |
assert(num_klasses < CPKlassSlot::_temp_resolved_klass_index, "sanity"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
189 |
assert(resolved_klasses() == NULL, "sanity"); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46630
diff
changeset
|
190 |
Array<Klass*>* rk = MetadataFactory::new_array<Klass*>(loader_data, num_klasses, CHECK); |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
191 |
set_resolved_klasses(rk); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
192 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
193 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
194 |
void ConstantPool::initialize_unresolved_klasses(ClassLoaderData* loader_data, TRAPS) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
195 |
int len = length(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
196 |
int num_klasses = 0; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
197 |
for (int i = 1; i <len; i++) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
198 |
switch (tag_at(i).value()) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
199 |
case JVM_CONSTANT_ClassIndex: |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
200 |
{ |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
201 |
const int class_index = klass_index_at(i); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
202 |
unresolved_klass_at_put(i, class_index, num_klasses++); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
203 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
204 |
break; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
205 |
#ifndef PRODUCT |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
206 |
case JVM_CONSTANT_Class: |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
207 |
case JVM_CONSTANT_UnresolvedClass: |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
208 |
case JVM_CONSTANT_UnresolvedClassInError: |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
209 |
// All of these should have been reverted back to ClassIndex before calling |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
210 |
// this function. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
211 |
ShouldNotReachHere(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
212 |
#endif |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
213 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
214 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
215 |
allocate_resolved_klasses(loader_data, num_klasses, THREAD); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
216 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
217 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
218 |
// Anonymous class support: |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
219 |
void ConstantPool::klass_at_put(int class_index, int name_index, int resolved_klass_index, Klass* k, Symbol* name) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
220 |
assert(is_within_bounds(class_index), "index out of bounds"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
221 |
assert(is_within_bounds(name_index), "index out of bounds"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
222 |
assert((resolved_klass_index & 0xffff0000) == 0, "must be"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
223 |
*int_at_addr(class_index) = |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
224 |
build_int_from_shorts((jushort)resolved_klass_index, (jushort)name_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
225 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
226 |
symbol_at_put(name_index, name); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
227 |
name->increment_refcount(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
228 |
Klass** adr = resolved_klasses()->adr_at(resolved_klass_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
229 |
OrderAccess::release_store_ptr((Klass* volatile *)adr, k); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
230 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
231 |
// The interpreter assumes when the tag is stored, the klass is resolved |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
232 |
// and the Klass* non-NULL, so we need hardware store ordering here. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
233 |
if (k != NULL) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
234 |
release_tag_at_put(class_index, JVM_CONSTANT_Class); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
235 |
} else { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
236 |
release_tag_at_put(class_index, JVM_CONSTANT_UnresolvedClass); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
237 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
238 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
239 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
240 |
// Anonymous class support: |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
241 |
void ConstantPool::klass_at_put(int class_index, Klass* k) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
242 |
assert(k != NULL, "must be valid klass"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
243 |
CPKlassSlot kslot = klass_slot_at(class_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
244 |
int resolved_klass_index = kslot.resolved_klass_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
245 |
Klass** adr = resolved_klasses()->adr_at(resolved_klass_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
246 |
OrderAccess::release_store_ptr((Klass* volatile *)adr, k); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
247 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
248 |
// The interpreter assumes when the tag is stored, the klass is resolved |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
249 |
// and the Klass* non-NULL, so we need hardware store ordering here. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
250 |
release_tag_at_put(class_index, JVM_CONSTANT_Class); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
251 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
252 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
253 |
#if INCLUDE_CDS_JAVA_HEAP |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
254 |
// Archive the resolved references |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
255 |
void ConstantPool::archive_resolved_references(Thread* THREAD) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
256 |
if (_cache == NULL) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
257 |
return; // nothing to do |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
258 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
259 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
260 |
InstanceKlass *ik = pool_holder(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
261 |
if (!(ik->is_shared_boot_class() || ik->is_shared_platform_class() || |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
262 |
ik->is_shared_app_class())) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
263 |
// Archiving resolved references for classes from non-builtin loaders |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
264 |
// is not yet supported. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
265 |
set_resolved_references(NULL); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
266 |
return; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
267 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
268 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
269 |
objArrayOop rr = resolved_references(); |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
270 |
Array<u2>* ref_map = reference_map(); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
271 |
if (rr != NULL) { |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
272 |
int ref_map_len = ref_map == NULL ? 0 : ref_map->length(); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
273 |
int rr_len = rr->length(); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
274 |
for (int i = 0; i < rr_len; i++) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
275 |
oop p = rr->obj_at(i); |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
276 |
rr->obj_at_put(i, NULL); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
277 |
if (p != NULL && i < ref_map_len) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
278 |
int index = object_to_cp_index(i); |
46816
f64eb2bfb250
8186238: The constant pool entry to empty string ("") should not be pre-resolved during CDS dump time.
jiangli
parents:
46810
diff
changeset
|
279 |
// Skip the entry if the string hash code is 0 since the string |
f64eb2bfb250
8186238: The constant pool entry to empty string ("") should not be pre-resolved during CDS dump time.
jiangli
parents:
46810
diff
changeset
|
280 |
// is not included in the shared string_table, see StringTable::copy_shared_string. |
f64eb2bfb250
8186238: The constant pool entry to empty string ("") should not be pre-resolved during CDS dump time.
jiangli
parents:
46810
diff
changeset
|
281 |
if (tag_at(index).is_string() && java_lang_String::hash_code(p) != 0) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
282 |
oop op = StringTable::create_archived_string(p, THREAD); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
283 |
// If the String object is not archived (possibly too large), |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
284 |
// NULL is returned. Also set it in the array, so we won't |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
285 |
// have a 'bad' reference in the archived resolved_reference |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
286 |
// array. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
287 |
rr->obj_at_put(i, op); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
288 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
289 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
290 |
} |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
291 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
292 |
oop archived = MetaspaceShared::archive_heap_object(rr, THREAD); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
293 |
_cache->set_archived_references(archived); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
294 |
set_resolved_references(NULL); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
295 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
296 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
297 |
#endif |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
298 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
299 |
// CDS support. Create a new resolved_references array. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
300 |
void ConstantPool::restore_unshareable_info(TRAPS) { |
46324
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
39398
diff
changeset
|
301 |
assert(is_constantPool(), "ensure C++ vtable is restored"); |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
302 |
assert(on_stack(), "should always be set for shared constant pools"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
303 |
assert(is_shared(), "should always be set for shared constant pools"); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
304 |
assert(_cache != NULL, "constant pool _cache should not be NULL"); |
31046
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
305 |
|
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
306 |
// Only create the new resolved references array if it hasn't been attempted before |
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
307 |
if (resolved_references() != NULL) return; |
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
308 |
|
31038
2fd2fdc6a70a
8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
29576
diff
changeset
|
309 |
// restore the C++ vtable from the shared archive |
2fd2fdc6a70a
8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
29576
diff
changeset
|
310 |
restore_vtable(); |
2fd2fdc6a70a
8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
29576
diff
changeset
|
311 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
312 |
if (SystemDictionary::Object_klass_loaded()) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
313 |
ClassLoaderData* loader_data = pool_holder()->class_loader_data(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
314 |
#if INCLUDE_CDS_JAVA_HEAP |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
315 |
if (MetaspaceShared::open_archive_heap_region_mapped() && |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
316 |
_cache->archived_references() != NULL) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
317 |
oop archived = _cache->archived_references(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
318 |
// Make sure GC knows the cached object is now live. This is necessary after |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
319 |
// initial GC marking and during concurrent marking as strong roots are only |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
320 |
// scanned during initial marking (at the start of the GC marking). |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
321 |
assert(UseG1GC, "Requires G1 GC"); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
322 |
G1SATBCardTableModRefBS::enqueue(archived); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
323 |
// Create handle for the archived resolved reference array object |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
324 |
Handle refs_handle(THREAD, (oop)archived); |
31046
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
325 |
set_resolved_references(loader_data->add_handle(refs_handle)); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
326 |
} else |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
327 |
#endif |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
328 |
{ |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
329 |
// No mapped archived resolved reference array |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
330 |
// Recreate the object array and add to ClassLoaderData. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
331 |
int map_length = resolved_reference_length(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
332 |
if (map_length > 0) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
333 |
objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
334 |
Handle refs_handle(THREAD, (oop)stom); // must handleize. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
335 |
set_resolved_references(loader_data->add_handle(refs_handle)); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
336 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
337 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
338 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
339 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
340 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
341 |
void ConstantPool::remove_unshareable_info() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
342 |
// Resolved references are not in the shared archive. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
343 |
// Save the length for restoration. It is not necessarily the same length |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
344 |
// as reference_map.length() if invokedynamic is saved. It is needed when |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
345 |
// re-creating the resolved reference array if archived heap data cannot be map |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
346 |
// at runtime. |
31046
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
347 |
set_resolved_reference_length( |
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31038
diff
changeset
|
348 |
resolved_references() != NULL ? resolved_references()->length() : 0); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
349 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
350 |
// If archiving heap objects is not allowed, clear the resolved references. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
351 |
// Otherwise, it is cleared after the resolved references array is cached |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
352 |
// (see archive_resolved_references()). |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
353 |
if (!MetaspaceShared::is_heap_object_archiving_allowed()) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
354 |
set_resolved_references(NULL); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
355 |
} |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
356 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
357 |
// Shared ConstantPools are in the RO region, so the _flags cannot be modified. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
358 |
// The _on_stack flag is used to prevent ConstantPools from deallocation during |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
359 |
// class redefinition. Since shared ConstantPools cannot be deallocated anyway, |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
360 |
// we always set _on_stack to true to avoid having to change _flags during runtime. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
361 |
_flags |= (_on_stack | _is_shared); |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
362 |
int num_klasses = 0; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
363 |
for (int index = 1; index < length(); index++) { // Index 0 is unused |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
364 |
assert(!tag_at(index).is_unresolved_klass_in_error(), "This must not happen during dump time"); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
365 |
if (tag_at(index).is_klass()) { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
366 |
// This class was resolved as a side effect of executing Java code |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
367 |
// during dump time. We need to restore it back to an UnresolvedClass, |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
368 |
// so that the proper class loading and initialization can happen |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
369 |
// at runtime. |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
370 |
CPKlassSlot kslot = klass_slot_at(index); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
371 |
int resolved_klass_index = kslot.resolved_klass_index(); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
372 |
int name_index = kslot.name_index(); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
373 |
assert(tag_at(name_index).is_symbol(), "sanity"); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
374 |
resolved_klasses()->at_put(resolved_klass_index, NULL); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
375 |
tag_at_put(index, JVM_CONSTANT_UnresolvedClass); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
376 |
assert(klass_name_at(index) == symbol_at(name_index), "sanity"); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
377 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
378 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
379 |
if (cache() != NULL) { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
380 |
cache()->remove_unshareable_info(); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47095
diff
changeset
|
381 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
382 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
383 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
384 |
int ConstantPool::cp_to_object_index(int cp_index) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
385 |
// this is harder don't do this so much. |
20063
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
386 |
int i = reference_map()->find(cp_index); |
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
387 |
// We might not find the index for jsr292 call. |
8965b97fcbb2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
coleenp
parents:
18439
diff
changeset
|
388 |
return (i < 0) ? _no_index_sentinel : i; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
389 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
390 |
|
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
35219
diff
changeset
|
391 |
void ConstantPool::string_at_put(int which, int obj_index, oop str) { |
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
35219
diff
changeset
|
392 |
resolved_references()->obj_at_put(obj_index, str); |
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
35219
diff
changeset
|
393 |
} |
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
35219
diff
changeset
|
394 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
395 |
void ConstantPool::trace_class_resolution(const constantPoolHandle& this_cp, Klass* k) { |
25325 | 396 |
ResourceMark rm; |
397 |
int line_number = -1; |
|
398 |
const char * source_file = NULL; |
|
399 |
if (JavaThread::current()->has_last_Java_frame()) { |
|
400 |
// try to identify the method which called this function. |
|
401 |
vframeStream vfst(JavaThread::current()); |
|
402 |
if (!vfst.at_end()) { |
|
403 |
line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
|
404 |
Symbol* s = vfst.method()->method_holder()->source_file_name(); |
|
405 |
if (s != NULL) { |
|
406 |
source_file = s->as_C_string(); |
|
407 |
} |
|
408 |
} |
|
409 |
} |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
410 |
if (k != this_cp->pool_holder()) { |
25325 | 411 |
// only print something if the classes are different |
412 |
if (source_file != NULL) { |
|
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
37475
diff
changeset
|
413 |
log_debug(class, resolve)("%s %s %s:%d", |
25325 | 414 |
this_cp->pool_holder()->external_name(), |
33602 | 415 |
k->external_name(), source_file, line_number); |
25325 | 416 |
} else { |
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
37475
diff
changeset
|
417 |
log_debug(class, resolve)("%s %s", |
25325 | 418 |
this_cp->pool_holder()->external_name(), |
33602 | 419 |
k->external_name()); |
25325 | 420 |
} |
421 |
} |
|
422 |
} |
|
423 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
424 |
Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which, |
27408
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
425 |
bool save_resolution_error, TRAPS) { |
25325 | 426 |
assert(THREAD->is_Java_thread(), "must be a Java thread"); |
427 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
428 |
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*. |
25325 | 429 |
// It is not safe to rely on the tag bit's here, since we don't have a lock, and |
430 |
// the entry and tag is not updated atomicly. |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
431 |
CPKlassSlot kslot = this_cp->klass_slot_at(which); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
432 |
int resolved_klass_index = kslot.resolved_klass_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
433 |
int name_index = kslot.name_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
434 |
assert(this_cp->tag_at(name_index).is_symbol(), "sanity"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
435 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
436 |
Klass* klass = this_cp->resolved_klasses()->at(resolved_klass_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
437 |
if (klass != NULL) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
438 |
return klass; |
1 | 439 |
} |
440 |
||
25325 | 441 |
// This tag doesn't change back to unresolved class unless at a safepoint. |
442 |
if (this_cp->tag_at(which).is_unresolved_klass_in_error()) { |
|
443 |
// The original attempt to resolve this constant pool entry failed so find the |
|
444 |
// class of the original error and throw another error of the same class |
|
445 |
// (JVMS 5.4.3). |
|
446 |
// If there is a detail message, pass that detail message to the error. |
|
447 |
// The JVMS does not strictly require us to duplicate the same detail message, |
|
448 |
// or any internal exception fields such as cause or stacktrace. But since the |
|
449 |
// detail message is often a class name or other literal string, we will repeat it |
|
450 |
// if we can find it in the symbol table. |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
451 |
throw_resolution_error(this_cp, which, CHECK_0); |
25325 | 452 |
ShouldNotReachHere(); |
1 | 453 |
} |
454 |
||
25325 | 455 |
Handle mirror_handle; |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
456 |
Symbol* name = this_cp->symbol_at(name_index); |
25325 | 457 |
Handle loader (THREAD, this_cp->pool_holder()->class_loader()); |
458 |
Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain()); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
459 |
Klass* k = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD); |
25325 | 460 |
if (!HAS_PENDING_EXCEPTION) { |
461 |
// preserve the resolved klass from unloading |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
462 |
mirror_handle = Handle(THREAD, k->java_mirror()); |
25325 | 463 |
// Do access check for klasses |
464 |
verify_constant_pool_resolve(this_cp, k, THREAD); |
|
465 |
} |
|
1 | 466 |
|
25325 | 467 |
// Failed to resolve class. We must record the errors so that subsequent attempts |
468 |
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3). |
|
469 |
if (HAS_PENDING_EXCEPTION) { |
|
27408
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
470 |
if (save_resolution_error) { |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
471 |
save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_NULL); |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
472 |
// If CHECK_NULL above doesn't return the exception, that means that |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
473 |
// some other thread has beaten us and has resolved the class. |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
474 |
// To preserve old behavior, we return the resolved class. |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
475 |
klass = this_cp->resolved_klasses()->at(resolved_klass_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
476 |
assert(klass != NULL, "must be resolved if exception was cleared"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
477 |
return klass; |
27408
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
478 |
} else { |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
479 |
return NULL; // return the pending exception |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
480 |
} |
25325 | 481 |
} |
1 | 482 |
|
25325 | 483 |
// Make this class loader depend upon the class loader owning the class reference |
484 |
ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data(); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
485 |
this_key->record_dependency(k, CHECK_NULL); // Can throw OOM |
25325 | 486 |
|
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
37475
diff
changeset
|
487 |
// logging for class+resolve. |
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
37475
diff
changeset
|
488 |
if (log_is_enabled(Debug, class, resolve)){ |
37451
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
489 |
trace_class_resolution(this_cp, k); |
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
490 |
} |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
491 |
Klass** adr = this_cp->resolved_klasses()->adr_at(resolved_klass_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
492 |
OrderAccess::release_store_ptr((Klass* volatile *)adr, k); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
493 |
// The interpreter assumes when the tag is stored, the klass is resolved |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
494 |
// and the Klass* stored in _resolved_klasses is non-NULL, so we need |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
495 |
// hardware store ordering here. |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
496 |
this_cp->release_tag_at_put(which, JVM_CONSTANT_Class); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
497 |
return k; |
1 | 498 |
} |
499 |
||
500 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
501 |
// Does not update ConstantPool* - to avoid any exception throwing. Used |
1 | 502 |
// by compiler and exception handling. Also used to avoid classloads for |
503 |
// instanceof operations. Returns NULL if the class has not been loaded or |
|
504 |
// if the verification of constant pool failed |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
505 |
Klass* ConstantPool::klass_at_if_loaded(const constantPoolHandle& this_cp, int which) { |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
506 |
CPKlassSlot kslot = this_cp->klass_slot_at(which); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
507 |
int resolved_klass_index = kslot.resolved_klass_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
508 |
int name_index = kslot.name_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
509 |
assert(this_cp->tag_at(name_index).is_symbol(), "sanity"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
510 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
511 |
Klass* k = this_cp->resolved_klasses()->at(resolved_klass_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
512 |
if (k != NULL) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
513 |
return k; |
1 | 514 |
} else { |
515 |
Thread *thread = Thread::current(); |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
516 |
Symbol* name = this_cp->symbol_at(name_index); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
517 |
oop loader = this_cp->pool_holder()->class_loader(); |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
518 |
oop protection_domain = this_cp->pool_holder()->protection_domain(); |
1 | 519 |
Handle h_prot (thread, protection_domain); |
520 |
Handle h_loader (thread, loader); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
521 |
Klass* k = SystemDictionary::find(name, h_loader, h_prot, thread); |
1 | 522 |
|
523 |
if (k != NULL) { |
|
524 |
// Make sure that resolving is legal |
|
525 |
EXCEPTION_MARK; |
|
526 |
// return NULL if verification fails |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
527 |
verify_constant_pool_resolve(this_cp, k, THREAD); |
1 | 528 |
if (HAS_PENDING_EXCEPTION) { |
529 |
CLEAR_PENDING_EXCEPTION; |
|
530 |
return NULL; |
|
531 |
} |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
532 |
return k; |
1 | 533 |
} else { |
534 |
return k; |
|
535 |
} |
|
536 |
} |
|
537 |
} |
|
538 |
||
539 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
540 |
Klass* ConstantPool::klass_ref_at_if_loaded(const constantPoolHandle& this_cp, int which) { |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
541 |
return klass_at_if_loaded(this_cp, this_cp->klass_ref_index_at(which)); |
1 | 542 |
} |
543 |
||
544 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
545 |
Method* ConstantPool::method_at_if_loaded(const constantPoolHandle& cpool, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
546 |
int which) { |
11626
7423003cc783
7140882: Don't return booleans from methods returning pointers
brutisso
parents:
10565
diff
changeset
|
547 |
if (cpool->cache() == NULL) return NULL; // nothing to load yet |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
548 |
int cache_index = decode_cpcache_index(which, true); |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9116
diff
changeset
|
549 |
if (!(cache_index >= 0 && cache_index < cpool->cache()->length())) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
550 |
// FIXME: should be an assert |
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
37475
diff
changeset
|
551 |
log_debug(class, resolve)("bad operand %d in:", which); cpool->print(); |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9116
diff
changeset
|
552 |
return NULL; |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9116
diff
changeset
|
553 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9116
diff
changeset
|
554 |
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
555 |
return e->method_if_resolved(cpool); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
556 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
557 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
558 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
559 |
bool ConstantPool::has_appendix_at_if_loaded(const constantPoolHandle& cpool, int which) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
560 |
if (cpool->cache() == NULL) return false; // nothing to load yet |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
561 |
int cache_index = decode_cpcache_index(which, true); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
562 |
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
563 |
return e->has_appendix(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
564 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
565 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
566 |
oop ConstantPool::appendix_at_if_loaded(const constantPoolHandle& cpool, int which) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
567 |
if (cpool->cache() == NULL) return NULL; // nothing to load yet |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
568 |
int cache_index = decode_cpcache_index(which, true); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
569 |
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
570 |
return e->appendix_if_resolved(cpool); |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9116
diff
changeset
|
571 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9116
diff
changeset
|
572 |
|
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9116
diff
changeset
|
573 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
574 |
bool ConstantPool::has_method_type_at_if_loaded(const constantPoolHandle& cpool, int which) { |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
575 |
if (cpool->cache() == NULL) return false; // nothing to load yet |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
576 |
int cache_index = decode_cpcache_index(which, true); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
577 |
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
578 |
return e->has_method_type(); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
579 |
} |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
580 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
581 |
oop ConstantPool::method_type_at_if_loaded(const constantPoolHandle& cpool, int which) { |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
582 |
if (cpool->cache() == NULL) return NULL; // nothing to load yet |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
583 |
int cache_index = decode_cpcache_index(which, true); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
584 |
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
585 |
return e->method_type_if_resolved(cpool); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
586 |
} |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
587 |
|
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13736
diff
changeset
|
588 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
589 |
Symbol* ConstantPool::impl_name_ref_at(int which, bool uncached) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
590 |
int name_index = name_ref_index_at(impl_name_and_type_ref_index_at(which, uncached)); |
1 | 591 |
return symbol_at(name_index); |
592 |
} |
|
593 |
||
594 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
595 |
Symbol* ConstantPool::impl_signature_ref_at(int which, bool uncached) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
596 |
int signature_index = signature_ref_index_at(impl_name_and_type_ref_index_at(which, uncached)); |
1 | 597 |
return symbol_at(signature_index); |
598 |
} |
|
599 |
||
600 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
601 |
int ConstantPool::impl_name_and_type_ref_index_at(int which, bool uncached) { |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
602 |
int i = which; |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
603 |
if (!uncached && cache() != NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
604 |
if (ConstantPool::is_invokedynamic_index(which)) { |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
605 |
// Invokedynamic index is index into the constant pool cache |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
606 |
int pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index(); |
9116 | 607 |
pool_index = invoke_dynamic_name_and_type_ref_index_at(pool_index); |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
608 |
assert(tag_at(pool_index).is_name_and_type(), ""); |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
609 |
return pool_index; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
610 |
} |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
611 |
// change byte-ordering and go via cache |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
612 |
i = remap_instruction_operand_from_cache(which); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
613 |
} else { |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
614 |
if (tag_at(which).is_invoke_dynamic()) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
615 |
int pool_index = invoke_dynamic_name_and_type_ref_index_at(which); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
616 |
assert(tag_at(pool_index).is_name_and_type(), ""); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
617 |
return pool_index; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
618 |
} |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
619 |
} |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
620 |
assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
621 |
assert(!tag_at(i).is_invoke_dynamic(), "Must be handled above"); |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
622 |
jint ref_index = *int_at_addr(i); |
1 | 623 |
return extract_high_short_from_int(ref_index); |
624 |
} |
|
625 |
||
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
626 |
constantTag ConstantPool::impl_tag_ref_at(int which, bool uncached) { |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
627 |
int pool_index = which; |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
628 |
if (!uncached && cache() != NULL) { |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
629 |
if (ConstantPool::is_invokedynamic_index(which)) { |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
630 |
// Invokedynamic index is index into resolved_references |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
631 |
pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index(); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
632 |
} else { |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
633 |
// change byte-ordering and go via cache |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
634 |
pool_index = remap_instruction_operand_from_cache(which); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
635 |
} |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
636 |
} |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
637 |
return tag_at(pool_index); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
638 |
} |
1 | 639 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
640 |
int ConstantPool::impl_klass_ref_index_at(int which, bool uncached) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
641 |
guarantee(!ConstantPool::is_invokedynamic_index(which), |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
642 |
"an invokedynamic instruction does not have a klass"); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
643 |
int i = which; |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
644 |
if (!uncached && cache() != NULL) { |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
645 |
// change byte-ordering and go via cache |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
646 |
i = remap_instruction_operand_from_cache(which); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
647 |
} |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
648 |
assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
649 |
jint ref_index = *int_at_addr(i); |
1 | 650 |
return extract_low_short_from_int(ref_index); |
651 |
} |
|
652 |
||
653 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
654 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
655 |
int ConstantPool::remap_instruction_operand_from_cache(int operand) { |
5688 | 656 |
int cpc_index = operand; |
657 |
DEBUG_ONLY(cpc_index -= CPCACHE_INDEX_TAG); |
|
658 |
assert((int)(u2)cpc_index == cpc_index, "clean u2"); |
|
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
659 |
int member_index = cache()->entry_at(cpc_index)->constant_pool_index(); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
660 |
return member_index; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
661 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
662 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
663 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
664 |
void ConstantPool::verify_constant_pool_resolve(const constantPoolHandle& this_cp, Klass* k, TRAPS) { |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
665 |
if (k->is_instance_klass() || k->is_objArray_klass()) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
666 |
InstanceKlass* holder = this_cp->pool_holder(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
667 |
Klass* elem = k->is_instance_klass() ? k : ObjArrayKlass::cast(k)->bottom_klass(); |
1 | 668 |
|
669 |
// The element type could be a typeArray - we only need the access check if it is |
|
670 |
// an reference to another class |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
671 |
if (elem->is_instance_klass()) { |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
672 |
LinkResolver::check_klass_accessability(holder, elem, CHECK); |
1 | 673 |
} |
674 |
} |
|
675 |
} |
|
676 |
||
677 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
678 |
int ConstantPool::name_ref_index_at(int which_nt) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
679 |
jint ref_index = name_and_type_at(which_nt); |
1 | 680 |
return extract_low_short_from_int(ref_index); |
681 |
} |
|
682 |
||
683 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
684 |
int ConstantPool::signature_ref_index_at(int which_nt) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
685 |
jint ref_index = name_and_type_at(which_nt); |
1 | 686 |
return extract_high_short_from_int(ref_index); |
687 |
} |
|
688 |
||
689 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
690 |
Klass* ConstantPool::klass_ref_at(int which, TRAPS) { |
27680
8ecc0871c18e
8064811: Use THREAD instead of CHECK_NULL in return statements
stefank
parents:
27408
diff
changeset
|
691 |
return klass_at(klass_ref_index_at(which), THREAD); |
1 | 692 |
} |
693 |
||
34666 | 694 |
Symbol* ConstantPool::klass_name_at(int which) const { |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
695 |
return symbol_at(klass_slot_at(which).name_index()); |
1 | 696 |
} |
697 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
698 |
Symbol* ConstantPool::klass_ref_at_noresolve(int which) { |
1 | 699 |
jint ref_index = klass_ref_index_at(which); |
700 |
return klass_at_noresolve(ref_index); |
|
701 |
} |
|
702 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
703 |
Symbol* ConstantPool::uncached_klass_ref_at_noresolve(int which) { |
5882 | 704 |
jint ref_index = uncached_klass_ref_index_at(which); |
705 |
return klass_at_noresolve(ref_index); |
|
706 |
} |
|
707 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
708 |
char* ConstantPool::string_at_noresolve(int which) { |
28741
1f10b1bd612d
8008678: JSR 292: constant pool reconstitution must support pseudo strings
sspitsyn
parents:
27680
diff
changeset
|
709 |
return unresolved_string_at(which)->as_C_string(); |
1 | 710 |
} |
711 |
||
34666 | 712 |
BasicType ConstantPool::basic_type_for_signature_at(int which) const { |
1 | 713 |
return FieldType::basic_type(symbol_at(which)); |
714 |
} |
|
715 |
||
716 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
717 |
void ConstantPool::resolve_string_constants_impl(const constantPoolHandle& this_cp, TRAPS) { |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
718 |
for (int index = 1; index < this_cp->length(); index++) { // Index 0 is unused |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
719 |
if (this_cp->tag_at(index).is_string()) { |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
720 |
this_cp->string_at(index, CHECK); |
1 | 721 |
} |
722 |
} |
|
723 |
} |
|
724 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
725 |
bool ConstantPool::resolve_class_constants(TRAPS) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
726 |
constantPoolHandle cp(THREAD, this); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
727 |
for (int index = 1; index < length(); index++) { // Index 0 is unused |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
728 |
if (tag_at(index).is_string()) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
729 |
Symbol* sym = cp->unresolved_string_at(index); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
730 |
// Look up only. Only resolve references to already interned strings. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
731 |
oop str = StringTable::lookup(sym); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
732 |
if (str != NULL) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
733 |
int cache_index = cp->cp_to_object_index(index); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
734 |
cp->string_at_put(index, cache_index, str); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
735 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
736 |
} |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
737 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
738 |
return true; |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
739 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
740 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
741 |
Symbol* ConstantPool::exception_message(const constantPoolHandle& this_cp, int which, constantTag tag, oop pending_exception) { |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
742 |
// Dig out the detailed message to reuse if possible |
25624
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25325
diff
changeset
|
743 |
Symbol* message = java_lang_Throwable::detail_message(pending_exception); |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25325
diff
changeset
|
744 |
if (message != NULL) { |
b3bd733f04e9
8048933: -XX:+TraceExceptions output should include the message
coleenp
parents:
25325
diff
changeset
|
745 |
return message; |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
746 |
} |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
747 |
|
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
748 |
// Return specific message for the tag |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
749 |
switch (tag.value()) { |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
750 |
case JVM_CONSTANT_UnresolvedClass: |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
751 |
// return the class name in the error message |
25325 | 752 |
message = this_cp->klass_name_at(which); |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
753 |
break; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
754 |
case JVM_CONSTANT_MethodHandle: |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
755 |
// return the method handle name in the error message |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
756 |
message = this_cp->method_handle_name_ref_at(which); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
757 |
break; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
758 |
case JVM_CONSTANT_MethodType: |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
759 |
// return the method type signature in the error message |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
760 |
message = this_cp->method_type_signature_at(which); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
761 |
break; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
762 |
default: |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
763 |
ShouldNotReachHere(); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
764 |
} |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
765 |
|
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
766 |
return message; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
767 |
} |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
768 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
769 |
void ConstantPool::throw_resolution_error(const constantPoolHandle& this_cp, int which, TRAPS) { |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
770 |
Symbol* message = NULL; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
771 |
Symbol* error = SystemDictionary::find_resolution_error(this_cp, which, &message); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
772 |
assert(error != NULL && message != NULL, "checking"); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
773 |
CLEAR_PENDING_EXCEPTION; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
774 |
ResourceMark rm; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
775 |
THROW_MSG(error, message->as_C_string()); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
776 |
} |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
777 |
|
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
778 |
// If resolution for Class, MethodHandle or MethodType fails, save the exception |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
779 |
// in the resolution error table, so that the same exception is thrown again. |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
780 |
void ConstantPool::save_and_throw_exception(const constantPoolHandle& this_cp, int which, |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
781 |
constantTag tag, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
782 |
Symbol* error = PENDING_EXCEPTION->klass()->name(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
783 |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
784 |
int error_tag = tag.error_value(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
785 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
786 |
if (!PENDING_EXCEPTION-> |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
787 |
is_a(SystemDictionary::LinkageError_klass())) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
788 |
// Just throw the exception and don't prevent these classes from |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
789 |
// being loaded due to virtual machine errors like StackOverflow |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
790 |
// and OutOfMemoryError, etc, or if the thread was hit by stop() |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
791 |
// Needs clarification to section 5.4.3 of the VM spec (see 6308271) |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
792 |
} else if (this_cp->tag_at(which).value() != error_tag) { |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
793 |
Symbol* message = exception_message(this_cp, which, tag, PENDING_EXCEPTION); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
794 |
SystemDictionary::add_resolution_error(this_cp, which, error, message); |
25325 | 795 |
// CAS in the tag. If a thread beat us to registering this error that's fine. |
27408
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
796 |
// If another thread resolved the reference, this is a race condition. This |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
797 |
// thread may have had a security manager or something temporary. |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
798 |
// This doesn't deterministically get an error. So why do we save this? |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
799 |
// We save this because jvmti can add classes to the bootclass path after |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
800 |
// this error, so it needs to get the same error if the error is first. |
25325 | 801 |
jbyte old_tag = Atomic::cmpxchg((jbyte)error_tag, |
802 |
(jbyte*)this_cp->tag_addr_at(which), (jbyte)tag.value()); |
|
27408
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
803 |
if (old_tag != error_tag && old_tag != tag.value()) { |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
804 |
// MethodHandles and MethodType doesn't change to resolved version. |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
805 |
assert(this_cp->tag_at(which).is_klass(), "Wrong tag value"); |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
806 |
// Forget the exception and use the resolved class. |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
807 |
CLEAR_PENDING_EXCEPTION; |
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
808 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
809 |
} else { |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
810 |
// some other thread put this in error state |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
811 |
throw_resolution_error(this_cp, which, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
812 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
813 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
814 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
815 |
// Called to resolve constants in the constant pool and return an oop. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
816 |
// Some constant pool entries cache their resolved oop. This is also |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
817 |
// called to create oops from constants to use in arguments for invokedynamic |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
818 |
oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, int index, int cache_index, TRAPS) { |
5882 | 819 |
oop result_oop = NULL; |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
820 |
Handle throw_exception; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
821 |
|
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
822 |
if (cache_index == _possible_index_sentinel) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
823 |
// It is possible that this constant is one which is cached in the objects. |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
824 |
// We'll do a linear search. This should be OK because this usage is rare. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
825 |
assert(index > 0, "valid index"); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
826 |
cache_index = this_cp->cp_to_object_index(index); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
827 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
828 |
assert(cache_index == _no_index_sentinel || cache_index >= 0, ""); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
829 |
assert(index == _no_index_sentinel || index >= 0, ""); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
830 |
|
5882 | 831 |
if (cache_index >= 0) { |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
832 |
result_oop = this_cp->resolved_references()->obj_at(cache_index); |
5882 | 833 |
if (result_oop != NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
834 |
return result_oop; |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
835 |
// That was easy... |
5882 | 836 |
} |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
837 |
index = this_cp->object_to_cp_index(cache_index); |
5882 | 838 |
} |
839 |
||
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
840 |
jvalue prim_value; // temp used only in a few cases below |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
841 |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
842 |
constantTag tag = this_cp->tag_at(index); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
843 |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
844 |
switch (tag.value()) { |
5882 | 845 |
|
846 |
case JVM_CONSTANT_UnresolvedClass: |
|
847 |
case JVM_CONSTANT_UnresolvedClassInError: |
|
848 |
case JVM_CONSTANT_Class: |
|
849 |
{ |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
850 |
assert(cache_index == _no_index_sentinel, "should not have been set"); |
27408
9a8090dd6ec3
8058093: Test nsk/stress/jck60/jck60014: assert in src/share/vm/oops/constantPool.cpp: should not be resolved otherwise
coleenp
parents:
27247
diff
changeset
|
851 |
Klass* resolved = klass_at_impl(this_cp, index, true, CHECK_NULL); |
5882 | 852 |
// ldc wants the java mirror. |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8651
diff
changeset
|
853 |
result_oop = resolved->java_mirror(); |
5882 | 854 |
break; |
855 |
} |
|
856 |
||
857 |
case JVM_CONSTANT_String: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
858 |
assert(cache_index != _no_index_sentinel, "should have been set"); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
859 |
if (this_cp->is_pseudo_string_at(index)) { |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
860 |
result_oop = this_cp->pseudo_string_at(index, cache_index); |
5882 | 861 |
break; |
862 |
} |
|
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
863 |
result_oop = string_at_impl(this_cp, index, cache_index, CHECK_NULL); |
5882 | 864 |
break; |
865 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
866 |
case JVM_CONSTANT_MethodHandleInError: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
867 |
case JVM_CONSTANT_MethodTypeInError: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
868 |
{ |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
869 |
throw_resolution_error(this_cp, index, CHECK_NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
870 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
871 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
872 |
|
5882 | 873 |
case JVM_CONSTANT_MethodHandle: |
874 |
{ |
|
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
875 |
int ref_kind = this_cp->method_handle_ref_kind_at(index); |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
876 |
int callee_index = this_cp->method_handle_klass_index_at(index); |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
877 |
Symbol* name = this_cp->method_handle_name_ref_at(index); |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
878 |
Symbol* signature = this_cp->method_handle_signature_ref_at(index); |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
879 |
constantTag m_tag = this_cp->tag_at(this_cp->method_handle_index_at(index)); |
37451
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
880 |
{ ResourceMark rm(THREAD); |
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
37475
diff
changeset
|
881 |
log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s", |
37451
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
882 |
ref_kind, index, this_cp->method_handle_index_at(index), |
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
883 |
callee_index, name->as_C_string(), signature->as_C_string()); |
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
884 |
} |
39398
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
885 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
886 |
Klass* callee = klass_at_impl(this_cp, callee_index, true, CHECK_NULL); |
39398
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
887 |
|
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
888 |
// Check constant pool method consistency |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
889 |
if ((callee->is_interface() && m_tag.is_method()) || |
39398
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
890 |
((!callee->is_interface() && m_tag.is_interface_method()))) { |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
891 |
ResourceMark rm(THREAD); |
39398
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
892 |
char buf[400]; |
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
893 |
jio_snprintf(buf, sizeof(buf), |
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
894 |
"Inconsistent constant pool data in classfile for class %s. " |
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
895 |
"Method %s%s at index %d is %s and should be %s", |
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
896 |
callee->name()->as_C_string(), name->as_C_string(), signature->as_C_string(), index, |
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
897 |
callee->is_interface() ? "CONSTANT_MethodRef" : "CONSTANT_InterfaceMethodRef", |
16b3ed4012f8
8159470: Error message for ICCE for MethodHandle constant pool not helpful
coleenp
parents:
38719
diff
changeset
|
898 |
callee->is_interface() ? "CONSTANT_InterfaceMethodRef" : "CONSTANT_MethodRef"); |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
899 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
900 |
} |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38658
diff
changeset
|
901 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
902 |
Klass* klass = this_cp->pool_holder(); |
5882 | 903 |
Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind, |
904 |
callee, name, signature, |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
905 |
THREAD); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
906 |
result_oop = value(); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
907 |
if (HAS_PENDING_EXCEPTION) { |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
908 |
save_and_throw_exception(this_cp, index, tag, CHECK_NULL); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
909 |
} |
5882 | 910 |
break; |
911 |
} |
|
912 |
||
913 |
case JVM_CONSTANT_MethodType: |
|
914 |
{ |
|
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
915 |
Symbol* signature = this_cp->method_type_signature_at(index); |
37451
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
916 |
{ ResourceMark rm(THREAD); |
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
37475
diff
changeset
|
917 |
log_debug(class, resolve)("resolve JVM_CONSTANT_MethodType [%d/%d] %s", |
37451
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
918 |
index, this_cp->method_type_index_at(index), |
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
919 |
signature->as_C_string()); |
ab07c0e0b05c
8152468: PrintMiscellaneous in constantPool should use classresolve logging.
mockner
parents:
37248
diff
changeset
|
920 |
} |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
921 |
Klass* klass = this_cp->pool_holder(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
922 |
Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
923 |
result_oop = value(); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
924 |
if (HAS_PENDING_EXCEPTION) { |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
925 |
save_and_throw_exception(this_cp, index, tag, CHECK_NULL); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
926 |
} |
5882 | 927 |
break; |
928 |
} |
|
929 |
||
930 |
case JVM_CONSTANT_Integer: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
931 |
assert(cache_index == _no_index_sentinel, "should not have been set"); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
932 |
prim_value.i = this_cp->int_at(index); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
933 |
result_oop = java_lang_boxing_object::create(T_INT, &prim_value, CHECK_NULL); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
934 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
935 |
|
5882 | 936 |
case JVM_CONSTANT_Float: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
937 |
assert(cache_index == _no_index_sentinel, "should not have been set"); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
938 |
prim_value.f = this_cp->float_at(index); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
939 |
result_oop = java_lang_boxing_object::create(T_FLOAT, &prim_value, CHECK_NULL); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
940 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
941 |
|
5882 | 942 |
case JVM_CONSTANT_Long: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
943 |
assert(cache_index == _no_index_sentinel, "should not have been set"); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
944 |
prim_value.j = this_cp->long_at(index); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
945 |
result_oop = java_lang_boxing_object::create(T_LONG, &prim_value, CHECK_NULL); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
946 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
947 |
|
5882 | 948 |
case JVM_CONSTANT_Double: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
949 |
assert(cache_index == _no_index_sentinel, "should not have been set"); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
950 |
prim_value.d = this_cp->double_at(index); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
951 |
result_oop = java_lang_boxing_object::create(T_DOUBLE, &prim_value, CHECK_NULL); |
5882 | 952 |
break; |
953 |
||
954 |
default: |
|
955 |
DEBUG_ONLY( tty->print_cr("*** %p: tag at CP[%d/%d] = %d", |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
23872
diff
changeset
|
956 |
this_cp(), index, cache_index, tag.value())); |
5882 | 957 |
assert(false, "unexpected constant tag"); |
958 |
break; |
|
959 |
} |
|
960 |
||
961 |
if (cache_index >= 0) { |
|
25325 | 962 |
// Benign race condition: resolved_references may already be filled in. |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
963 |
// The important thing here is that all threads pick up the same result. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
964 |
// It doesn't matter which racing thread wins, as long as only one |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
965 |
// result is used by all threads, and all future queries. |
25325 | 966 |
oop old_result = this_cp->resolved_references()->atomic_compare_exchange_oop(cache_index, result_oop, NULL); |
967 |
if (old_result == NULL) { |
|
968 |
return result_oop; // was installed |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
969 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
970 |
// Return the winning thread's result. This can be different than |
25325 | 971 |
// the result here for MethodHandles. |
972 |
return old_result; |
|
5882 | 973 |
} |
974 |
} else { |
|
975 |
return result_oop; |
|
976 |
} |
|
977 |
} |
|
978 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
979 |
oop ConstantPool::uncached_string_at(int which, TRAPS) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
980 |
Symbol* sym = unresolved_string_at(which); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
981 |
oop str = StringTable::intern(sym, CHECK_(NULL)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
982 |
assert(java_lang_String::is_instance(str), "must be string"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
983 |
return str; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
984 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
985 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
986 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
987 |
oop ConstantPool::resolve_bootstrap_specifier_at_impl(const constantPoolHandle& this_cp, int index, TRAPS) { |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
988 |
assert(this_cp->tag_at(index).is_invoke_dynamic(), "Corrupted constant pool"); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
989 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
990 |
Handle bsm; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
991 |
int argc; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
992 |
{ |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
993 |
// JVM_CONSTANT_InvokeDynamic is an ordered pair of [bootm, name&type], plus optional arguments |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
994 |
// The bootm, being a JVM_CONSTANT_MethodHandle, has its own cache entry. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
995 |
// It is accompanied by the optional arguments. |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
996 |
int bsm_index = this_cp->invoke_dynamic_bootstrap_method_ref_index_at(index); |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
997 |
oop bsm_oop = this_cp->resolve_possibly_cached_constant_at(bsm_index, CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
998 |
if (!java_lang_invoke_MethodHandle::is_instance(bsm_oop)) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
999 |
THROW_MSG_NULL(vmSymbols::java_lang_LinkageError(), "BSM not an MethodHandle"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1000 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1001 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1002 |
// Extract the optional static arguments. |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
1003 |
argc = this_cp->invoke_dynamic_argument_count_at(index); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1004 |
if (argc == 0) return bsm_oop; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1005 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1006 |
bsm = Handle(THREAD, bsm_oop); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1007 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1008 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1009 |
objArrayHandle info; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1010 |
{ |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1011 |
objArrayOop info_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), 1+argc, CHECK_NULL); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1012 |
info = objArrayHandle(THREAD, info_oop); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1013 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1014 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1015 |
info->obj_at_put(0, bsm()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1016 |
for (int i = 0; i < argc; i++) { |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
1017 |
int arg_index = this_cp->invoke_dynamic_argument_index_at(index, i); |
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
1018 |
oop arg_oop = this_cp->resolve_possibly_cached_constant_at(arg_index, CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1019 |
info->obj_at_put(1+i, arg_oop); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1020 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1021 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1022 |
return info(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1023 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11626
diff
changeset
|
1024 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1025 |
oop ConstantPool::string_at_impl(const constantPoolHandle& this_cp, int which, int obj_index, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1026 |
// If the string has already been interned, this entry will be non-null |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
1027 |
oop str = this_cp->resolved_references()->obj_at(obj_index); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1028 |
if (str != NULL) return str; |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
1029 |
Symbol* sym = this_cp->unresolved_string_at(which); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1030 |
str = StringTable::intern(sym, CHECK_(NULL)); |
23515
f4872ef5df09
8031820: NPG: Fix remaining references to metadata as oops in comments
coleenp
parents:
23175
diff
changeset
|
1031 |
this_cp->string_at_put(which, obj_index, str); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1032 |
assert(java_lang_String::is_instance(str), "must be string"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1033 |
return str; |
1 | 1034 |
} |
1035 |
||
1036 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46324
diff
changeset
|
1037 |
bool ConstantPool::klass_name_at_matches(const InstanceKlass* k, int which) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1038 |
// Names are interned, so we can compare Symbol*s directly |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1039 |
Symbol* cp_name = klass_name_at(which); |
1 | 1040 |
return (cp_name == k->name()); |
1041 |
} |
|
1042 |
||
1043 |
||
25325 | 1044 |
// Iterate over symbols and decrement ones which are Symbol*s |
1045 |
// This is done during GC. |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
1046 |
// Only decrement the UTF8 symbols. Strings point to |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1047 |
// these symbols but didn't increment the reference count. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1048 |
void ConstantPool::unreference_symbols() { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1049 |
for (int index = 1; index < length(); index++) { // Index 0 is unused |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1050 |
constantTag tag = tag_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1051 |
if (tag.is_symbol()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1052 |
symbol_at(index)->decrement_refcount(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1053 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1054 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1055 |
} |
1 | 1056 |
|
1057 |
||
1058 |
// Compare this constant pool's entry at index1 to the constant pool |
|
1059 |
// cp2's entry at index2. |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1060 |
bool ConstantPool::compare_entry_to(int index1, const constantPoolHandle& cp2, |
1 | 1061 |
int index2, TRAPS) { |
1062 |
||
20677
ff4fc393de4c
8022592: assert at constantTag.cpp:57: ShouldNotReachHere()
coleenp
parents:
20672
diff
changeset
|
1063 |
// The error tags are equivalent to non-error tags when comparing |
ff4fc393de4c
8022592: assert at constantTag.cpp:57: ShouldNotReachHere()
coleenp
parents:
20672
diff
changeset
|
1064 |
jbyte t1 = tag_at(index1).non_error_value(); |
ff4fc393de4c
8022592: assert at constantTag.cpp:57: ShouldNotReachHere()
coleenp
parents:
20672
diff
changeset
|
1065 |
jbyte t2 = cp2->tag_at(index2).non_error_value(); |
1 | 1066 |
|
1067 |
if (t1 != t2) { |
|
1068 |
// Not the same entry type so there is nothing else to check. Note |
|
1069 |
// that this style of checking will consider resolved/unresolved |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1070 |
// class pairs as different. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1071 |
// From the ConstantPool* API point of view, this is correct |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1072 |
// behavior. See VM_RedefineClasses::merge_constant_pools() to see how this |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1073 |
// plays out in the context of ConstantPool* merging. |
1 | 1074 |
return false; |
1075 |
} |
|
1076 |
||
1077 |
switch (t1) { |
|
1078 |
case JVM_CONSTANT_Class: |
|
1079 |
{ |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1080 |
Klass* k1 = klass_at(index1, CHECK_false); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1081 |
Klass* k2 = cp2->klass_at(index2, CHECK_false); |
1 | 1082 |
if (k1 == k2) { |
1083 |
return true; |
|
1084 |
} |
|
1085 |
} break; |
|
1086 |
||
1087 |
case JVM_CONSTANT_ClassIndex: |
|
1088 |
{ |
|
1089 |
int recur1 = klass_index_at(index1); |
|
1090 |
int recur2 = cp2->klass_index_at(index2); |
|
1091 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
1092 |
if (match) { |
|
1093 |
return true; |
|
1094 |
} |
|
1095 |
} break; |
|
1096 |
||
1097 |
case JVM_CONSTANT_Double: |
|
1098 |
{ |
|
1099 |
jdouble d1 = double_at(index1); |
|
1100 |
jdouble d2 = cp2->double_at(index2); |
|
1101 |
if (d1 == d2) { |
|
1102 |
return true; |
|
1103 |
} |
|
1104 |
} break; |
|
1105 |
||
1106 |
case JVM_CONSTANT_Fieldref: |
|
1107 |
case JVM_CONSTANT_InterfaceMethodref: |
|
1108 |
case JVM_CONSTANT_Methodref: |
|
1109 |
{ |
|
1110 |
int recur1 = uncached_klass_ref_index_at(index1); |
|
1111 |
int recur2 = cp2->uncached_klass_ref_index_at(index2); |
|
1112 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
1113 |
if (match) { |
|
1114 |
recur1 = uncached_name_and_type_ref_index_at(index1); |
|
1115 |
recur2 = cp2->uncached_name_and_type_ref_index_at(index2); |
|
1116 |
match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
1117 |
if (match) { |
|
1118 |
return true; |
|
1119 |
} |
|
1120 |
} |
|
1121 |
} break; |
|
1122 |
||
1123 |
case JVM_CONSTANT_Float: |
|
1124 |
{ |
|
1125 |
jfloat f1 = float_at(index1); |
|
1126 |
jfloat f2 = cp2->float_at(index2); |
|
1127 |
if (f1 == f2) { |
|
1128 |
return true; |
|
1129 |
} |
|
1130 |
} break; |
|
1131 |
||
1132 |
case JVM_CONSTANT_Integer: |
|
1133 |
{ |
|
1134 |
jint i1 = int_at(index1); |
|
1135 |
jint i2 = cp2->int_at(index2); |
|
1136 |
if (i1 == i2) { |
|
1137 |
return true; |
|
1138 |
} |
|
1139 |
} break; |
|
1140 |
||
1141 |
case JVM_CONSTANT_Long: |
|
1142 |
{ |
|
1143 |
jlong l1 = long_at(index1); |
|
1144 |
jlong l2 = cp2->long_at(index2); |
|
1145 |
if (l1 == l2) { |
|
1146 |
return true; |
|
1147 |
} |
|
1148 |
} break; |
|
1149 |
||
1150 |
case JVM_CONSTANT_NameAndType: |
|
1151 |
{ |
|
1152 |
int recur1 = name_ref_index_at(index1); |
|
1153 |
int recur2 = cp2->name_ref_index_at(index2); |
|
1154 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
1155 |
if (match) { |
|
1156 |
recur1 = signature_ref_index_at(index1); |
|
1157 |
recur2 = cp2->signature_ref_index_at(index2); |
|
1158 |
match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
1159 |
if (match) { |
|
1160 |
return true; |
|
1161 |
} |
|
1162 |
} |
|
1163 |
} break; |
|
1164 |
||
1165 |
case JVM_CONSTANT_StringIndex: |
|
1166 |
{ |
|
1167 |
int recur1 = string_index_at(index1); |
|
1168 |
int recur2 = cp2->string_index_at(index2); |
|
1169 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
1170 |
if (match) { |
|
1171 |
return true; |
|
1172 |
} |
|
1173 |
} break; |
|
1174 |
||
1175 |
case JVM_CONSTANT_UnresolvedClass: |
|
1176 |
{ |
|
25325 | 1177 |
Symbol* k1 = klass_name_at(index1); |
1178 |
Symbol* k2 = cp2->klass_name_at(index2); |
|
1 | 1179 |
if (k1 == k2) { |
1180 |
return true; |
|
1181 |
} |
|
1182 |
} break; |
|
1183 |
||
5882 | 1184 |
case JVM_CONSTANT_MethodType: |
1185 |
{ |
|
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1186 |
int k1 = method_type_index_at(index1); |
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1187 |
int k2 = cp2->method_type_index_at(index2); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1188 |
bool match = compare_entry_to(k1, cp2, k2, CHECK_false); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1189 |
if (match) { |
5882 | 1190 |
return true; |
1191 |
} |
|
1192 |
} break; |
|
1193 |
||
1194 |
case JVM_CONSTANT_MethodHandle: |
|
1195 |
{ |
|
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1196 |
int k1 = method_handle_ref_kind_at(index1); |
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1197 |
int k2 = cp2->method_handle_ref_kind_at(index2); |
5882 | 1198 |
if (k1 == k2) { |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1199 |
int i1 = method_handle_index_at(index1); |
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1200 |
int i2 = cp2->method_handle_index_at(index2); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1201 |
bool match = compare_entry_to(i1, cp2, i2, CHECK_false); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1202 |
if (match) { |
5882 | 1203 |
return true; |
1204 |
} |
|
1205 |
} |
|
1206 |
} break; |
|
1207 |
||
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1208 |
case JVM_CONSTANT_InvokeDynamic: |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1209 |
{ |
17077
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1210 |
int k1 = invoke_dynamic_name_and_type_ref_index_at(index1); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1211 |
int k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1212 |
int i1 = invoke_dynamic_bootstrap_specifier_index(index1); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1213 |
int i2 = cp2->invoke_dynamic_bootstrap_specifier_index(index2); |
17833 | 1214 |
// separate statements and variables because CHECK_false is used |
1215 |
bool match_entry = compare_entry_to(k1, cp2, k2, CHECK_false); |
|
1216 |
bool match_operand = compare_operand_to(i1, cp2, i2, CHECK_false); |
|
1217 |
return (match_entry && match_operand); |
|
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1218 |
} break; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1219 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1220 |
case JVM_CONSTANT_String: |
1 | 1221 |
{ |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1222 |
Symbol* s1 = unresolved_string_at(index1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1223 |
Symbol* s2 = cp2->unresolved_string_at(index2); |
1 | 1224 |
if (s1 == s2) { |
1225 |
return true; |
|
1226 |
} |
|
1227 |
} break; |
|
1228 |
||
1229 |
case JVM_CONSTANT_Utf8: |
|
1230 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1231 |
Symbol* s1 = symbol_at(index1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1232 |
Symbol* s2 = cp2->symbol_at(index2); |
1 | 1233 |
if (s1 == s2) { |
1234 |
return true; |
|
1235 |
} |
|
1236 |
} break; |
|
1237 |
||
1238 |
// Invalid is used as the tag for the second constant pool entry |
|
1239 |
// occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should |
|
1240 |
// not be seen by itself. |
|
1241 |
case JVM_CONSTANT_Invalid: // fall through |
|
1242 |
||
1243 |
default: |
|
1244 |
ShouldNotReachHere(); |
|
1245 |
break; |
|
1246 |
} |
|
1247 |
||
1248 |
return false; |
|
1249 |
} // end compare_entry_to() |
|
1250 |
||
1251 |
||
17077
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1252 |
// Resize the operands array with delta_len and delta_size. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1253 |
// Used in RedefineClasses for CP merge. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1254 |
void ConstantPool::resize_operands(int delta_len, int delta_size, TRAPS) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1255 |
int old_len = operand_array_length(operands()); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1256 |
int new_len = old_len + delta_len; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1257 |
int min_len = (delta_len > 0) ? old_len : new_len; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1258 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1259 |
int old_size = operands()->length(); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1260 |
int new_size = old_size + delta_size; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1261 |
int min_size = (delta_size > 0) ? old_size : new_size; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1262 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1263 |
ClassLoaderData* loader_data = pool_holder()->class_loader_data(); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1264 |
Array<u2>* new_ops = MetadataFactory::new_array<u2>(loader_data, new_size, CHECK); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1265 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1266 |
// Set index in the resized array for existing elements only |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1267 |
for (int idx = 0; idx < min_len; idx++) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1268 |
int offset = operand_offset_at(idx); // offset in original array |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1269 |
operand_offset_at_put(new_ops, idx, offset + 2*delta_len); // offset in resized array |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1270 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1271 |
// Copy the bootstrap specifiers only |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1272 |
Copy::conjoint_memory_atomic(operands()->adr_at(2*old_len), |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1273 |
new_ops->adr_at(2*new_len), |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1274 |
(min_size - 2*min_len) * sizeof(u2)); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1275 |
// Explicitly deallocate old operands array. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1276 |
// Note, it is not needed for 7u backport. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1277 |
if ( operands() != NULL) { // the safety check |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1278 |
MetadataFactory::free_array<u2>(loader_data, operands()); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1279 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1280 |
set_operands(new_ops); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1281 |
} // end resize_operands() |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1282 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1283 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1284 |
// Extend the operands array with the length and size of the ext_cp operands. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1285 |
// Used in RedefineClasses for CP merge. |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1286 |
void ConstantPool::extend_operands(const constantPoolHandle& ext_cp, TRAPS) { |
17077
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1287 |
int delta_len = operand_array_length(ext_cp->operands()); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1288 |
if (delta_len == 0) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1289 |
return; // nothing to do |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1290 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1291 |
int delta_size = ext_cp->operands()->length(); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1292 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1293 |
assert(delta_len > 0 && delta_size > 0, "extended operands array must be bigger"); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1294 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1295 |
if (operand_array_length(operands()) == 0) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1296 |
ClassLoaderData* loader_data = pool_holder()->class_loader_data(); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1297 |
Array<u2>* new_ops = MetadataFactory::new_array<u2>(loader_data, delta_size, CHECK); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1298 |
// The first element index defines the offset of second part |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1299 |
operand_offset_at_put(new_ops, 0, 2*delta_len); // offset in new array |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1300 |
set_operands(new_ops); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1301 |
} else { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1302 |
resize_operands(delta_len, delta_size, CHECK); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1303 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1304 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1305 |
} // end extend_operands() |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1306 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1307 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1308 |
// Shrink the operands array to a smaller array with new_len length. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1309 |
// Used in RedefineClasses for CP merge. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1310 |
void ConstantPool::shrink_operands(int new_len, TRAPS) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1311 |
int old_len = operand_array_length(operands()); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1312 |
if (new_len == old_len) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1313 |
return; // nothing to do |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1314 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1315 |
assert(new_len < old_len, "shrunken operands array must be smaller"); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1316 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1317 |
int free_base = operand_next_offset_at(new_len - 1); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1318 |
int delta_len = new_len - old_len; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1319 |
int delta_size = 2*delta_len + free_base - operands()->length(); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1320 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1321 |
resize_operands(delta_len, delta_size, CHECK); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1322 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1323 |
} // end shrink_operands() |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1324 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1325 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1326 |
void ConstantPool::copy_operands(const constantPoolHandle& from_cp, |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1327 |
const constantPoolHandle& to_cp, |
15433
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1328 |
TRAPS) { |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1329 |
|
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1330 |
int from_oplen = operand_array_length(from_cp->operands()); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1331 |
int old_oplen = operand_array_length(to_cp->operands()); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1332 |
if (from_oplen != 0) { |
14385 | 1333 |
ClassLoaderData* loader_data = to_cp->pool_holder()->class_loader_data(); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1334 |
// append my operands to the target's operands array |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1335 |
if (old_oplen == 0) { |
14385 | 1336 |
// Can't just reuse from_cp's operand list because of deallocation issues |
1337 |
int len = from_cp->operands()->length(); |
|
1338 |
Array<u2>* new_ops = MetadataFactory::new_array<u2>(loader_data, len, CHECK); |
|
1339 |
Copy::conjoint_memory_atomic( |
|
1340 |
from_cp->operands()->adr_at(0), new_ops->adr_at(0), len * sizeof(u2)); |
|
1341 |
to_cp->set_operands(new_ops); |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1342 |
} else { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1343 |
int old_len = to_cp->operands()->length(); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1344 |
int from_len = from_cp->operands()->length(); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1345 |
int old_off = old_oplen * sizeof(u2); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1346 |
int from_off = from_oplen * sizeof(u2); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1347 |
// Use the metaspace for the destination constant pool |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1348 |
Array<u2>* new_operands = MetadataFactory::new_array<u2>(loader_data, old_len + from_len, CHECK); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1349 |
int fillp = 0, len = 0; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1350 |
// first part of dest |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1351 |
Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(0), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1352 |
new_operands->adr_at(fillp), |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1353 |
(len = old_off) * sizeof(u2)); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1354 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1355 |
// first part of src |
15445
3a166138739c
8006546: JSR 292: typos in the ConstantPool::copy_cp_impl()
sspitsyn
parents:
15438
diff
changeset
|
1356 |
Copy::conjoint_memory_atomic(from_cp->operands()->adr_at(0), |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1357 |
new_operands->adr_at(fillp), |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1358 |
(len = from_off) * sizeof(u2)); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1359 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1360 |
// second part of dest |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1361 |
Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(old_off), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1362 |
new_operands->adr_at(fillp), |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1363 |
(len = old_len - old_off) * sizeof(u2)); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1364 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1365 |
// second part of src |
15445
3a166138739c
8006546: JSR 292: typos in the ConstantPool::copy_cp_impl()
sspitsyn
parents:
15438
diff
changeset
|
1366 |
Copy::conjoint_memory_atomic(from_cp->operands()->adr_at(from_off), |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1367 |
new_operands->adr_at(fillp), |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1368 |
(len = from_len - from_off) * sizeof(u2)); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1369 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1370 |
assert(fillp == new_operands->length(), ""); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1371 |
|
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1372 |
// Adjust indexes in the first part of the copied operands array. |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1373 |
for (int j = 0; j < from_oplen; j++) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1374 |
int offset = operand_offset_at(new_operands, old_oplen + j); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1375 |
assert(offset == operand_offset_at(from_cp->operands(), j), "correct copy"); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1376 |
offset += old_len; // every new tuple is preceded by old_len extra u2's |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1377 |
operand_offset_at_put(new_operands, old_oplen + j, offset); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1378 |
} |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1379 |
|
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1380 |
// replace target operands array with combined array |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1381 |
to_cp->set_operands(new_operands); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1382 |
} |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1383 |
} |
15433
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1384 |
} // end copy_operands() |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1385 |
|
15433
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1386 |
|
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1387 |
// Copy this constant pool's entries at start_i to end_i (inclusive) |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1388 |
// to the constant pool to_cp's entries starting at to_i. A total of |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1389 |
// (end_i - start_i) + 1 entries are copied. |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1390 |
void ConstantPool::copy_cp_to_impl(const constantPoolHandle& from_cp, int start_i, int end_i, |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1391 |
const constantPoolHandle& to_cp, int to_i, TRAPS) { |
15433
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1392 |
|
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1393 |
|
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1394 |
int dest_i = to_i; // leave original alone for debug purposes |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1395 |
|
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1396 |
for (int src_i = start_i; src_i <= end_i; /* see loop bottom */ ) { |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1397 |
copy_entry_to(from_cp, src_i, to_cp, dest_i, CHECK); |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1398 |
|
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1399 |
switch (from_cp->tag_at(src_i).value()) { |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1400 |
case JVM_CONSTANT_Double: |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1401 |
case JVM_CONSTANT_Long: |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1402 |
// double and long take two constant pool entries |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1403 |
src_i += 2; |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1404 |
dest_i += 2; |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1405 |
break; |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1406 |
|
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1407 |
default: |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1408 |
// all others take one constant pool entry |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1409 |
src_i++; |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1410 |
dest_i++; |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1411 |
break; |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1412 |
} |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1413 |
} |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1414 |
copy_operands(from_cp, to_cp, CHECK); |
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1415 |
|
0f53fd973576
8005128: JSR 292: the mlvm redefineClassInBootstrap test crashes in ConstantPool::compare_entry_to
sspitsyn
parents:
15430
diff
changeset
|
1416 |
} // end copy_cp_to_impl() |
1 | 1417 |
|
1418 |
||
1419 |
// Copy this constant pool's entry at from_i to the constant pool |
|
1420 |
// to_cp's entry at to_i. |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1421 |
void ConstantPool::copy_entry_to(const constantPoolHandle& from_cp, int from_i, |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1422 |
const constantPoolHandle& to_cp, int to_i, |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1423 |
TRAPS) { |
1 | 1424 |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1425 |
int tag = from_cp->tag_at(from_i).value(); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1426 |
switch (tag) { |
1 | 1427 |
case JVM_CONSTANT_ClassIndex: |
1428 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1429 |
jint ki = from_cp->klass_index_at(from_i); |
1 | 1430 |
to_cp->klass_index_at_put(to_i, ki); |
1431 |
} break; |
|
1432 |
||
1433 |
case JVM_CONSTANT_Double: |
|
1434 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1435 |
jdouble d = from_cp->double_at(from_i); |
1 | 1436 |
to_cp->double_at_put(to_i, d); |
1437 |
// double takes two constant pool entries so init second entry's tag |
|
1438 |
to_cp->tag_at_put(to_i + 1, JVM_CONSTANT_Invalid); |
|
1439 |
} break; |
|
1440 |
||
1441 |
case JVM_CONSTANT_Fieldref: |
|
1442 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1443 |
int class_index = from_cp->uncached_klass_ref_index_at(from_i); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1444 |
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i); |
1 | 1445 |
to_cp->field_at_put(to_i, class_index, name_and_type_index); |
1446 |
} break; |
|
1447 |
||
1448 |
case JVM_CONSTANT_Float: |
|
1449 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1450 |
jfloat f = from_cp->float_at(from_i); |
1 | 1451 |
to_cp->float_at_put(to_i, f); |
1452 |
} break; |
|
1453 |
||
1454 |
case JVM_CONSTANT_Integer: |
|
1455 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1456 |
jint i = from_cp->int_at(from_i); |
1 | 1457 |
to_cp->int_at_put(to_i, i); |
1458 |
} break; |
|
1459 |
||
1460 |
case JVM_CONSTANT_InterfaceMethodref: |
|
1461 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1462 |
int class_index = from_cp->uncached_klass_ref_index_at(from_i); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1463 |
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i); |
1 | 1464 |
to_cp->interface_method_at_put(to_i, class_index, name_and_type_index); |
1465 |
} break; |
|
1466 |
||
1467 |
case JVM_CONSTANT_Long: |
|
1468 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1469 |
jlong l = from_cp->long_at(from_i); |
1 | 1470 |
to_cp->long_at_put(to_i, l); |
1471 |
// long takes two constant pool entries so init second entry's tag |
|
1472 |
to_cp->tag_at_put(to_i + 1, JVM_CONSTANT_Invalid); |
|
1473 |
} break; |
|
1474 |
||
1475 |
case JVM_CONSTANT_Methodref: |
|
1476 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1477 |
int class_index = from_cp->uncached_klass_ref_index_at(from_i); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1478 |
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i); |
1 | 1479 |
to_cp->method_at_put(to_i, class_index, name_and_type_index); |
1480 |
} break; |
|
1481 |
||
1482 |
case JVM_CONSTANT_NameAndType: |
|
1483 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1484 |
int name_ref_index = from_cp->name_ref_index_at(from_i); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1485 |
int signature_ref_index = from_cp->signature_ref_index_at(from_i); |
1 | 1486 |
to_cp->name_and_type_at_put(to_i, name_ref_index, signature_ref_index); |
1487 |
} break; |
|
1488 |
||
1489 |
case JVM_CONSTANT_StringIndex: |
|
1490 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1491 |
jint si = from_cp->string_index_at(from_i); |
1 | 1492 |
to_cp->string_index_at_put(to_i, si); |
1493 |
} break; |
|
1494 |
||
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
1495 |
case JVM_CONSTANT_Class: |
1 | 1496 |
case JVM_CONSTANT_UnresolvedClass: |
23175
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
22750
diff
changeset
|
1497 |
case JVM_CONSTANT_UnresolvedClassInError: |
1 | 1498 |
{ |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
1499 |
// Revert to JVM_CONSTANT_ClassIndex |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
1500 |
int name_index = from_cp->klass_slot_at(from_i).name_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
1501 |
assert(from_cp->tag_at(name_index).is_symbol(), "sanity"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
1502 |
to_cp->klass_index_at_put(to_i, name_index); |
1 | 1503 |
} break; |
1504 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1505 |
case JVM_CONSTANT_String: |
1 | 1506 |
{ |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1507 |
Symbol* s = from_cp->unresolved_string_at(from_i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1508 |
to_cp->unresolved_string_at_put(to_i, s); |
1 | 1509 |
} break; |
1510 |
||
1511 |
case JVM_CONSTANT_Utf8: |
|
1512 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1513 |
Symbol* s = from_cp->symbol_at(from_i); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1514 |
// Need to increase refcount, the old one will be thrown away and deferenced |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1515 |
s->increment_refcount(); |
1 | 1516 |
to_cp->symbol_at_put(to_i, s); |
1517 |
} break; |
|
1518 |
||
5882 | 1519 |
case JVM_CONSTANT_MethodType: |
20672
9340852feeef
8025185: MethodHandleInError and MethodTypeInError not handled in ConstantPool::compare_entry_to and copy_entry_to
coleenp
parents:
20282
diff
changeset
|
1520 |
case JVM_CONSTANT_MethodTypeInError: |
5882 | 1521 |
{ |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1522 |
jint k = from_cp->method_type_index_at(from_i); |
5882 | 1523 |
to_cp->method_type_index_at_put(to_i, k); |
1524 |
} break; |
|
1525 |
||
1526 |
case JVM_CONSTANT_MethodHandle: |
|
20672
9340852feeef
8025185: MethodHandleInError and MethodTypeInError not handled in ConstantPool::compare_entry_to and copy_entry_to
coleenp
parents:
20282
diff
changeset
|
1527 |
case JVM_CONSTANT_MethodHandleInError: |
5882 | 1528 |
{ |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1529 |
int k1 = from_cp->method_handle_ref_kind_at(from_i); |
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1530 |
int k2 = from_cp->method_handle_index_at(from_i); |
5882 | 1531 |
to_cp->method_handle_index_at_put(to_i, k1, k2); |
1532 |
} break; |
|
1533 |
||
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1534 |
case JVM_CONSTANT_InvokeDynamic: |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1535 |
{ |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1536 |
int k1 = from_cp->invoke_dynamic_bootstrap_specifier_index(from_i); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1537 |
int k2 = from_cp->invoke_dynamic_name_and_type_ref_index_at(from_i); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1538 |
k1 += operand_array_length(to_cp->operands()); // to_cp might already have operands |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1539 |
to_cp->invoke_dynamic_at_put(to_i, k1, k2); |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1540 |
} break; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1541 |
|
1 | 1542 |
// Invalid is used as the tag for the second constant pool entry |
1543 |
// occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should |
|
1544 |
// not be seen by itself. |
|
1545 |
case JVM_CONSTANT_Invalid: // fall through |
|
1546 |
||
1547 |
default: |
|
1548 |
{ |
|
1549 |
ShouldNotReachHere(); |
|
1550 |
} break; |
|
1551 |
} |
|
1552 |
} // end copy_entry_to() |
|
1553 |
||
1554 |
// Search constant pool search_cp for an entry that matches this |
|
1555 |
// constant pool's entry at pattern_i. Returns the index of a |
|
1556 |
// matching entry or zero (0) if there is no matching entry. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1557 |
int ConstantPool::find_matching_entry(int pattern_i, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1558 |
const constantPoolHandle& search_cp, TRAPS) { |
1 | 1559 |
|
1560 |
// index zero (0) is not used |
|
1561 |
for (int i = 1; i < search_cp->length(); i++) { |
|
1562 |
bool found = compare_entry_to(pattern_i, search_cp, i, CHECK_0); |
|
1563 |
if (found) { |
|
1564 |
return i; |
|
1565 |
} |
|
1566 |
} |
|
1567 |
||
1568 |
return 0; // entry not found; return unused index zero (0) |
|
1569 |
} // end find_matching_entry() |
|
1570 |
||
1571 |
||
17077
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1572 |
// Compare this constant pool's bootstrap specifier at idx1 to the constant pool |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1573 |
// cp2's bootstrap specifier at idx2. |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1574 |
bool ConstantPool::compare_operand_to(int idx1, const constantPoolHandle& cp2, int idx2, TRAPS) { |
17077
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1575 |
int k1 = operand_bootstrap_method_ref_index_at(idx1); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1576 |
int k2 = cp2->operand_bootstrap_method_ref_index_at(idx2); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1577 |
bool match = compare_entry_to(k1, cp2, k2, CHECK_false); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1578 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1579 |
if (!match) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1580 |
return false; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1581 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1582 |
int argc = operand_argument_count_at(idx1); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1583 |
if (argc == cp2->operand_argument_count_at(idx2)) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1584 |
for (int j = 0; j < argc; j++) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1585 |
k1 = operand_argument_index_at(idx1, j); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1586 |
k2 = cp2->operand_argument_index_at(idx2, j); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1587 |
match = compare_entry_to(k1, cp2, k2, CHECK_false); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1588 |
if (!match) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1589 |
return false; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1590 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1591 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1592 |
return true; // got through loop; all elements equal |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1593 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1594 |
return false; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1595 |
} // end compare_operand_to() |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1596 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1597 |
// Search constant pool search_cp for a bootstrap specifier that matches |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1598 |
// this constant pool's bootstrap specifier at pattern_i index. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1599 |
// Return the index of a matching bootstrap specifier or (-1) if there is no match. |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1600 |
int ConstantPool::find_matching_operand(int pattern_i, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33148
diff
changeset
|
1601 |
const constantPoolHandle& search_cp, int search_len, TRAPS) { |
17077
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1602 |
for (int i = 0; i < search_len; i++) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1603 |
bool found = compare_operand_to(pattern_i, search_cp, i, CHECK_(-1)); |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1604 |
if (found) { |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1605 |
return i; |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1606 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1607 |
} |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1608 |
return -1; // bootstrap specifier not found; return unused index (-1) |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1609 |
} // end find_matching_operand() |
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1610 |
|
8607f7c33310
8007037: JSR 292: the VM_RedefineClasses::append_entry() should do cross-checks with indy operands
sspitsyn
parents:
16670
diff
changeset
|
1611 |
|
1 | 1612 |
#ifndef PRODUCT |
1613 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1614 |
const char* ConstantPool::printable_name_at(int which) { |
1 | 1615 |
|
1616 |
constantTag tag = tag_at(which); |
|
1617 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1618 |
if (tag.is_string()) { |
1 | 1619 |
return string_at_noresolve(which); |
1620 |
} else if (tag.is_klass() || tag.is_unresolved_klass()) { |
|
1621 |
return klass_name_at(which)->as_C_string(); |
|
1622 |
} else if (tag.is_symbol()) { |
|
1623 |
return symbol_at(which)->as_C_string(); |
|
1624 |
} |
|
1625 |
return ""; |
|
1626 |
} |
|
1627 |
||
1628 |
#endif // PRODUCT |
|
1629 |
||
1630 |
||
1631 |
// JVMTI GetConstantPool support |
|
1632 |
||
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16383
diff
changeset
|
1633 |
// For debugging of constant pool |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16383
diff
changeset
|
1634 |
const bool debug_cpool = false; |
1 | 1635 |
|
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16383
diff
changeset
|
1636 |
#define DBG(code) do { if (debug_cpool) { (code); } } while(0) |
1 | 1637 |
|
1638 |
static void print_cpool_bytes(jint cnt, u1 *bytes) { |
|
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16383
diff
changeset
|
1639 |
const char* WARN_MSG = "Must not be such entry!"; |
1 | 1640 |
jint size = 0; |
1641 |
u2 idx1, idx2; |
|
1642 |
||
1643 |
for (jint idx = 1; idx < cnt; idx++) { |
|
1644 |
jint ent_size = 0; |
|
1645 |
u1 tag = *bytes++; |
|
1646 |
size++; // count tag |
|
1647 |
||
1648 |
printf("const #%03d, tag: %02d ", idx, tag); |
|
1649 |
switch(tag) { |
|
1650 |
case JVM_CONSTANT_Invalid: { |
|
1651 |
printf("Invalid"); |
|
1652 |
break; |
|
1653 |
} |
|
1654 |
case JVM_CONSTANT_Unicode: { |
|
1655 |
printf("Unicode %s", WARN_MSG); |
|
1656 |
break; |
|
1657 |
} |
|
1658 |
case JVM_CONSTANT_Utf8: { |
|
1659 |
u2 len = Bytes::get_Java_u2(bytes); |
|
1660 |
char str[128]; |
|
1661 |
if (len > 127) { |
|
1662 |
len = 127; |
|
1663 |
} |
|
1664 |
strncpy(str, (char *) (bytes+2), len); |
|
1665 |
str[len] = '\0'; |
|
1666 |
printf("Utf8 \"%s\"", str); |
|
1667 |
ent_size = 2 + len; |
|
1668 |
break; |
|
1669 |
} |
|
1670 |
case JVM_CONSTANT_Integer: { |
|
1671 |
u4 val = Bytes::get_Java_u4(bytes); |
|
1672 |
printf("int %d", *(int *) &val); |
|
1673 |
ent_size = 4; |
|
1674 |
break; |
|
1675 |
} |
|
1676 |
case JVM_CONSTANT_Float: { |
|
1677 |
u4 val = Bytes::get_Java_u4(bytes); |
|
1678 |
printf("float %5.3ff", *(float *) &val); |
|
1679 |
ent_size = 4; |
|
1680 |
break; |
|
1681 |
} |
|
1682 |
case JVM_CONSTANT_Long: { |
|
1683 |
u8 val = Bytes::get_Java_u8(bytes); |
|
31592
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
31046
diff
changeset
|
1684 |
printf("long " INT64_FORMAT, (int64_t) *(jlong *) &val); |
1 | 1685 |
ent_size = 8; |
1686 |
idx++; // Long takes two cpool slots |
|
1687 |
break; |
|
1688 |
} |
|
1689 |
case JVM_CONSTANT_Double: { |
|
1690 |
u8 val = Bytes::get_Java_u8(bytes); |
|
1691 |
printf("double %5.3fd", *(jdouble *)&val); |
|
1692 |
ent_size = 8; |
|
1693 |
idx++; // Double takes two cpool slots |
|
1694 |
break; |
|
1695 |
} |
|
1696 |
case JVM_CONSTANT_Class: { |
|
1697 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1698 |
printf("class #%03d", idx1); |
|
1699 |
ent_size = 2; |
|
1700 |
break; |
|
1701 |
} |
|
1702 |
case JVM_CONSTANT_String: { |
|
1703 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1704 |
printf("String #%03d", idx1); |
|
1705 |
ent_size = 2; |
|
1706 |
break; |
|
1707 |
} |
|
1708 |
case JVM_CONSTANT_Fieldref: { |
|
1709 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1710 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1711 |
printf("Field #%03d, #%03d", (int) idx1, (int) idx2); |
|
1712 |
ent_size = 4; |
|
1713 |
break; |
|
1714 |
} |
|
1715 |
case JVM_CONSTANT_Methodref: { |
|
1716 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1717 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1718 |
printf("Method #%03d, #%03d", idx1, idx2); |
|
1719 |
ent_size = 4; |
|
1720 |
break; |
|
1721 |
} |
|
1722 |
case JVM_CONSTANT_InterfaceMethodref: { |
|
1723 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1724 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1725 |
printf("InterfMethod #%03d, #%03d", idx1, idx2); |
|
1726 |
ent_size = 4; |
|
1727 |
break; |
|
1728 |
} |
|
1729 |
case JVM_CONSTANT_NameAndType: { |
|
1730 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1731 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1732 |
printf("NameAndType #%03d, #%03d", idx1, idx2); |
|
1733 |
ent_size = 4; |
|
1734 |
break; |
|
1735 |
} |
|
1736 |
case JVM_CONSTANT_ClassIndex: { |
|
1737 |
printf("ClassIndex %s", WARN_MSG); |
|
1738 |
break; |
|
1739 |
} |
|
1740 |
case JVM_CONSTANT_UnresolvedClass: { |
|
1741 |
printf("UnresolvedClass: %s", WARN_MSG); |
|
1742 |
break; |
|
1743 |
} |
|
1744 |
case JVM_CONSTANT_UnresolvedClassInError: { |
|
1745 |
printf("UnresolvedClassInErr: %s", WARN_MSG); |
|
1746 |
break; |
|
1747 |
} |
|
1748 |
case JVM_CONSTANT_StringIndex: { |
|
1749 |
printf("StringIndex: %s", WARN_MSG); |
|
1750 |
break; |
|
1751 |
} |
|
1752 |
} |
|
1753 |
printf(";\n"); |
|
1754 |
bytes += ent_size; |
|
1755 |
size += ent_size; |
|
1756 |
} |
|
1757 |
printf("Cpool size: %d\n", size); |
|
1758 |
fflush(0); |
|
1759 |
return; |
|
1760 |
} /* end print_cpool_bytes */ |
|
1761 |
||
1762 |
||
1763 |
// Returns size of constant pool entry. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1764 |
jint ConstantPool::cpool_entry_size(jint idx) { |
1 | 1765 |
switch(tag_at(idx).value()) { |
1766 |
case JVM_CONSTANT_Invalid: |
|
1767 |
case JVM_CONSTANT_Unicode: |
|
1768 |
return 1; |
|
1769 |
||
1770 |
case JVM_CONSTANT_Utf8: |
|
1771 |
return 3 + symbol_at(idx)->utf8_length(); |
|
1772 |
||
1773 |
case JVM_CONSTANT_Class: |
|
1774 |
case JVM_CONSTANT_String: |
|
1775 |
case JVM_CONSTANT_ClassIndex: |
|
1776 |
case JVM_CONSTANT_UnresolvedClass: |
|
1777 |
case JVM_CONSTANT_UnresolvedClassInError: |
|
1778 |
case JVM_CONSTANT_StringIndex: |
|
5882 | 1779 |
case JVM_CONSTANT_MethodType: |
20070
90ee74be2445
8025088: Missing cases for JVM_CONSTANT_MethodHandleInError cause crash if debugger steps into error-tagged method handle
iklam
parents:
20066
diff
changeset
|
1780 |
case JVM_CONSTANT_MethodTypeInError: |
1 | 1781 |
return 3; |
1782 |
||
5882 | 1783 |
case JVM_CONSTANT_MethodHandle: |
20070
90ee74be2445
8025088: Missing cases for JVM_CONSTANT_MethodHandleInError cause crash if debugger steps into error-tagged method handle
iklam
parents:
20066
diff
changeset
|
1784 |
case JVM_CONSTANT_MethodHandleInError: |
5882 | 1785 |
return 4; //tag, ref_kind, ref_index |
1786 |
||
1 | 1787 |
case JVM_CONSTANT_Integer: |
1788 |
case JVM_CONSTANT_Float: |
|
1789 |
case JVM_CONSTANT_Fieldref: |
|
1790 |
case JVM_CONSTANT_Methodref: |
|
1791 |
case JVM_CONSTANT_InterfaceMethodref: |
|
1792 |
case JVM_CONSTANT_NameAndType: |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
1793 |
return 5; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
1794 |
|
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1795 |
case JVM_CONSTANT_InvokeDynamic: |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1796 |
// u1 tag, u2 bsm, u2 nt |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1797 |
return 5; |
1 | 1798 |
|
1799 |
case JVM_CONSTANT_Long: |
|
1800 |
case JVM_CONSTANT_Double: |
|
1801 |
return 9; |
|
1802 |
} |
|
1803 |
assert(false, "cpool_entry_size: Invalid constant pool entry tag"); |
|
1804 |
return 1; |
|
1805 |
} /* end cpool_entry_size */ |
|
1806 |
||
1807 |
||
1808 |
// SymbolHashMap is used to find a constant pool index from a string. |
|
1809 |
// This function fills in SymbolHashMaps, one for utf8s and one for |
|
1810 |
// class names, returns size of the cpool raw bytes. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1811 |
jint ConstantPool::hash_entries_to(SymbolHashMap *symmap, |
1 | 1812 |
SymbolHashMap *classmap) { |
1813 |
jint size = 0; |
|
1814 |
||
1815 |
for (u2 idx = 1; idx < length(); idx++) { |
|
1816 |
u2 tag = tag_at(idx).value(); |
|
1817 |
size += cpool_entry_size(idx); |
|
1818 |
||
1819 |
switch(tag) { |
|
1820 |
case JVM_CONSTANT_Utf8: { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1821 |
Symbol* sym = symbol_at(idx); |
1 | 1822 |
symmap->add_entry(sym, idx); |
1823 |
DBG(printf("adding symbol entry %s = %d\n", sym->as_utf8(), idx)); |
|
1824 |
break; |
|
1825 |
} |
|
1826 |
case JVM_CONSTANT_Class: |
|
1827 |
case JVM_CONSTANT_UnresolvedClass: |
|
1828 |
case JVM_CONSTANT_UnresolvedClassInError: { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1829 |
Symbol* sym = klass_name_at(idx); |
1 | 1830 |
classmap->add_entry(sym, idx); |
1831 |
DBG(printf("adding class entry %s = %d\n", sym->as_utf8(), idx)); |
|
1832 |
break; |
|
1833 |
} |
|
1834 |
case JVM_CONSTANT_Long: |
|
1835 |
case JVM_CONSTANT_Double: { |
|
1836 |
idx++; // Both Long and Double take two cpool slots |
|
1837 |
break; |
|
1838 |
} |
|
1839 |
} |
|
1840 |
} |
|
1841 |
return size; |
|
1842 |
} /* end hash_utf8_entries_to */ |
|
1843 |
||
1844 |
||
1845 |
// Copy cpool bytes. |
|
1846 |
// Returns: |
|
1847 |
// 0, in case of OutOfMemoryError |
|
1848 |
// -1, in case of internal error |
|
1849 |
// > 0, count of the raw cpool bytes that have been copied |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1850 |
int ConstantPool::copy_cpool_bytes(int cpool_size, |
1 | 1851 |
SymbolHashMap* tbl, |
1852 |
unsigned char *bytes) { |
|
1853 |
u2 idx1, idx2; |
|
1854 |
jint size = 0; |
|
1855 |
jint cnt = length(); |
|
1856 |
unsigned char *start_bytes = bytes; |
|
1857 |
||
1858 |
for (jint idx = 1; idx < cnt; idx++) { |
|
1859 |
u1 tag = tag_at(idx).value(); |
|
1860 |
jint ent_size = cpool_entry_size(idx); |
|
1861 |
||
1862 |
assert(size + ent_size <= cpool_size, "Size mismatch"); |
|
1863 |
||
1864 |
*bytes = tag; |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46560
diff
changeset
|
1865 |
DBG(printf("#%03hd tag=%03hd, ", (short)idx, (short)tag)); |
1 | 1866 |
switch(tag) { |
1867 |
case JVM_CONSTANT_Invalid: { |
|
1868 |
DBG(printf("JVM_CONSTANT_Invalid")); |
|
1869 |
break; |
|
1870 |
} |
|
1871 |
case JVM_CONSTANT_Unicode: { |
|
1872 |
assert(false, "Wrong constant pool tag: JVM_CONSTANT_Unicode"); |
|
1873 |
DBG(printf("JVM_CONSTANT_Unicode")); |
|
1874 |
break; |
|
1875 |
} |
|
1876 |
case JVM_CONSTANT_Utf8: { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1877 |
Symbol* sym = symbol_at(idx); |
1 | 1878 |
char* str = sym->as_utf8(); |
1879 |
// Warning! It's crashing on x86 with len = sym->utf8_length() |
|
1880 |
int len = (int) strlen(str); |
|
1881 |
Bytes::put_Java_u2((address) (bytes+1), (u2) len); |
|
1882 |
for (int i = 0; i < len; i++) { |
|
1883 |
bytes[3+i] = (u1) str[i]; |
|
1884 |
} |
|
1885 |
DBG(printf("JVM_CONSTANT_Utf8: %s ", str)); |
|
1886 |
break; |
|
1887 |
} |
|
1888 |
case JVM_CONSTANT_Integer: { |
|
1889 |
jint val = int_at(idx); |
|
1890 |
Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val); |
|
1891 |
break; |
|
1892 |
} |
|
1893 |
case JVM_CONSTANT_Float: { |
|
1894 |
jfloat val = float_at(idx); |
|
1895 |
Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val); |
|
1896 |
break; |
|
1897 |
} |
|
1898 |
case JVM_CONSTANT_Long: { |
|
1899 |
jlong val = long_at(idx); |
|
1900 |
Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val); |
|
1901 |
idx++; // Long takes two cpool slots |
|
1902 |
break; |
|
1903 |
} |
|
1904 |
case JVM_CONSTANT_Double: { |
|
1905 |
jdouble val = double_at(idx); |
|
1906 |
Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val); |
|
1907 |
idx++; // Double takes two cpool slots |
|
1908 |
break; |
|
1909 |
} |
|
1910 |
case JVM_CONSTANT_Class: |
|
1911 |
case JVM_CONSTANT_UnresolvedClass: |
|
1912 |
case JVM_CONSTANT_UnresolvedClassInError: { |
|
1913 |
*bytes = JVM_CONSTANT_Class; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1914 |
Symbol* sym = klass_name_at(idx); |
1 | 1915 |
idx1 = tbl->symbol_to_value(sym); |
1916 |
assert(idx1 != 0, "Have not found a hashtable entry"); |
|
1917 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1918 |
DBG(printf("JVM_CONSTANT_Class: idx=#%03hd, %s", idx1, sym->as_utf8())); |
|
1919 |
break; |
|
1920 |
} |
|
1921 |
case JVM_CONSTANT_String: { |
|
1922 |
*bytes = JVM_CONSTANT_String; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1923 |
Symbol* sym = unresolved_string_at(idx); |
1 | 1924 |
idx1 = tbl->symbol_to_value(sym); |
1925 |
assert(idx1 != 0, "Have not found a hashtable entry"); |
|
1926 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16383
diff
changeset
|
1927 |
DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, sym->as_utf8())); |
1 | 1928 |
break; |
1929 |
} |
|
1930 |
case JVM_CONSTANT_Fieldref: |
|
1931 |
case JVM_CONSTANT_Methodref: |
|
1932 |
case JVM_CONSTANT_InterfaceMethodref: { |
|
1933 |
idx1 = uncached_klass_ref_index_at(idx); |
|
1934 |
idx2 = uncached_name_and_type_ref_index_at(idx); |
|
1935 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1936 |
Bytes::put_Java_u2((address) (bytes+3), idx2); |
|
1937 |
DBG(printf("JVM_CONSTANT_Methodref: %hd %hd", idx1, idx2)); |
|
1938 |
break; |
|
1939 |
} |
|
1940 |
case JVM_CONSTANT_NameAndType: { |
|
1941 |
idx1 = name_ref_index_at(idx); |
|
1942 |
idx2 = signature_ref_index_at(idx); |
|
1943 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1944 |
Bytes::put_Java_u2((address) (bytes+3), idx2); |
|
1945 |
DBG(printf("JVM_CONSTANT_NameAndType: %hd %hd", idx1, idx2)); |
|
1946 |
break; |
|
1947 |
} |
|
1948 |
case JVM_CONSTANT_ClassIndex: { |
|
1949 |
*bytes = JVM_CONSTANT_Class; |
|
1950 |
idx1 = klass_index_at(idx); |
|
1951 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1952 |
DBG(printf("JVM_CONSTANT_ClassIndex: %hd", idx1)); |
|
1953 |
break; |
|
1954 |
} |
|
1955 |
case JVM_CONSTANT_StringIndex: { |
|
1956 |
*bytes = JVM_CONSTANT_String; |
|
1957 |
idx1 = string_index_at(idx); |
|
1958 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1959 |
DBG(printf("JVM_CONSTANT_StringIndex: %hd", idx1)); |
|
1960 |
break; |
|
1961 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1962 |
case JVM_CONSTANT_MethodHandle: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1963 |
case JVM_CONSTANT_MethodHandleInError: { |
5882 | 1964 |
*bytes = JVM_CONSTANT_MethodHandle; |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1965 |
int kind = method_handle_ref_kind_at(idx); |
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1966 |
idx1 = method_handle_index_at(idx); |
5882 | 1967 |
*(bytes+1) = (unsigned char) kind; |
1968 |
Bytes::put_Java_u2((address) (bytes+2), idx1); |
|
1969 |
DBG(printf("JVM_CONSTANT_MethodHandle: %d %hd", kind, idx1)); |
|
1970 |
break; |
|
1971 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1972 |
case JVM_CONSTANT_MethodType: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1973 |
case JVM_CONSTANT_MethodTypeInError: { |
5882 | 1974 |
*bytes = JVM_CONSTANT_MethodType; |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
1975 |
idx1 = method_type_index_at(idx); |
5882 | 1976 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
1977 |
DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1)); |
|
1978 |
break; |
|
1979 |
} |
|
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1980 |
case JVM_CONSTANT_InvokeDynamic: { |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1981 |
*bytes = tag; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1982 |
idx1 = extract_low_short_from_int(*int_at_addr(idx)); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1983 |
idx2 = extract_high_short_from_int(*int_at_addr(idx)); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1984 |
assert(idx2 == invoke_dynamic_name_and_type_ref_index_at(idx), "correct half of u4"); |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1985 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1986 |
Bytes::put_Java_u2((address) (bytes+3), idx2); |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1987 |
DBG(printf("JVM_CONSTANT_InvokeDynamic: %hd %hd", idx1, idx2)); |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1988 |
break; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1989 |
} |
1 | 1990 |
} |
1991 |
DBG(printf("\n")); |
|
1992 |
bytes += ent_size; |
|
1993 |
size += ent_size; |
|
1994 |
} |
|
1995 |
assert(size == cpool_size, "Size mismatch"); |
|
1996 |
||
1997 |
// Keep temorarily for debugging until it's stable. |
|
1998 |
DBG(print_cpool_bytes(cnt, start_bytes)); |
|
1999 |
return (int)(bytes - start_bytes); |
|
2000 |
} /* end copy_cpool_bytes */ |
|
2001 |
||
16670
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16383
diff
changeset
|
2002 |
#undef DBG |
4af09aff4237
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
16383
diff
changeset
|
2003 |
|
1 | 2004 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2005 |
void ConstantPool::set_on_stack(const bool value) { |
15430
7c35f12cf1e5
8006040: NPG: on_stack processing wastes space in ConstantPool
coleenp
parents:
15229
diff
changeset
|
2006 |
if (value) { |
29576
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
2007 |
// Only record if it's not already set. |
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
2008 |
if (!on_stack()) { |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2009 |
assert(!is_shared(), "should always be set for shared constant pools"); |
29576
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
2010 |
_flags |= _on_stack; |
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
2011 |
MetadataOnStackMark::record(this); |
27247
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
25624
diff
changeset
|
2012 |
} |
15430
7c35f12cf1e5
8006040: NPG: on_stack processing wastes space in ConstantPool
coleenp
parents:
15229
diff
changeset
|
2013 |
} else { |
27247
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
25624
diff
changeset
|
2014 |
// Clearing is done single-threadedly. |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2015 |
if (!is_shared()) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2016 |
_flags &= ~_on_stack; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2017 |
} |
15430
7c35f12cf1e5
8006040: NPG: on_stack processing wastes space in ConstantPool
coleenp
parents:
15229
diff
changeset
|
2018 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2019 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2020 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2021 |
// JSR 292 support for patching constant pool oops after the class is linked and |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2022 |
// the oop array for resolved references are created. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2023 |
// We can't do this during classfile parsing, which is how the other indexes are |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2024 |
// patched. The other patches are applied early for some error checking |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2025 |
// so only defer the pseudo_strings. |
24322 | 2026 |
void ConstantPool::patch_resolved_references(GrowableArray<Handle>* cp_patches) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2027 |
for (int index = 1; index < cp_patches->length(); index++) { // Index 0 is unused |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2028 |
Handle patch = cp_patches->at(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2029 |
if (patch.not_null()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2030 |
assert (tag_at(index).is_string(), "should only be string left"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2031 |
// Patching a string means pre-resolving it. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2032 |
// The spelling in the constant pool is ignored. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2033 |
// The constant reference may be any object whatever. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2034 |
// If it is not a real interned string, the constant is referred |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2035 |
// to as a "pseudo-string", and must be presented to the CP |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2036 |
// explicitly, because it may require scavenging. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2037 |
int obj_index = cp_to_object_index(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2038 |
pseudo_string_at_put(index, obj_index, patch()); |
28741
1f10b1bd612d
8008678: JSR 292: constant pool reconstitution must support pseudo strings
sspitsyn
parents:
27680
diff
changeset
|
2039 |
DEBUG_ONLY(cp_patches->at_put(index, Handle());) |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2040 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2041 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2042 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2043 |
// Ensure that all the patches have been used. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2044 |
for (int index = 0; index < cp_patches->length(); index++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2045 |
assert(cp_patches->at(index).is_null(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
2046 |
"Unused constant pool patch at %d in class file %s", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
2047 |
index, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
2048 |
pool_holder()->external_name()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2049 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2050 |
#endif // ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2051 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2052 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2053 |
#ifndef PRODUCT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2054 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2055 |
// CompileTheWorld support. Preload all classes loaded references in the passed in constantpool |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2056 |
void ConstantPool::preload_and_initialize_all_classes(ConstantPool* obj, TRAPS) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2057 |
guarantee(obj->is_constantPool(), "object must be constant pool"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2058 |
constantPoolHandle cp(THREAD, (ConstantPool*)obj); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2059 |
guarantee(cp->pool_holder() != NULL, "must be fully loaded"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2060 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2061 |
for (int i = 0; i< cp->length(); i++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2062 |
if (cp->tag_at(i).is_unresolved_klass()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2063 |
// This will force loading of the class |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2064 |
Klass* klass = cp->klass_at(i, CHECK); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
2065 |
if (klass->is_instance_klass()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2066 |
// Force initialization of class |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2067 |
InstanceKlass::cast(klass)->initialize(CHECK); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2068 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2069 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2070 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2071 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2072 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2073 |
#endif |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2074 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2075 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2076 |
// Printing |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2077 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2078 |
void ConstantPool::print_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2079 |
assert(is_constantPool(), "must be constantPool"); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24337
diff
changeset
|
2080 |
st->print_cr("%s", internal_name()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2081 |
if (flags() != 0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2082 |
st->print(" - flags: 0x%x", flags()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2083 |
if (has_preresolution()) st->print(" has_preresolution"); |
15430
7c35f12cf1e5
8006040: NPG: on_stack processing wastes space in ConstantPool
coleenp
parents:
15229
diff
changeset
|
2084 |
if (on_stack()) st->print(" on_stack"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2085 |
st->cr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2086 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2087 |
if (pool_holder() != NULL) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
2088 |
st->print_cr(" - holder: " INTPTR_FORMAT, p2i(pool_holder())); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2089 |
} |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
2090 |
st->print_cr(" - cache: " INTPTR_FORMAT, p2i(cache())); |
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
2091 |
st->print_cr(" - resolved_references: " INTPTR_FORMAT, p2i(resolved_references())); |
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
2092 |
st->print_cr(" - reference_map: " INTPTR_FORMAT, p2i(reference_map())); |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2093 |
st->print_cr(" - resolved_klasses: " INTPTR_FORMAT, p2i(resolved_klasses())); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2094 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2095 |
for (int index = 1; index < length(); index++) { // Index 0 is unused |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2096 |
((ConstantPool*)this)->print_entry_on(index, st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2097 |
switch (tag_at(index).value()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2098 |
case JVM_CONSTANT_Long : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2099 |
case JVM_CONSTANT_Double : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2100 |
index++; // Skip entry following eigth-byte constant |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2101 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2102 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2103 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2104 |
st->cr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2105 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2106 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2107 |
// Print one constant pool entry |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2108 |
void ConstantPool::print_entry_on(const int index, outputStream* st) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2109 |
EXCEPTION_MARK; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2110 |
st->print(" - %3d : ", index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2111 |
tag_at(index).print_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2112 |
st->print(" : "); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2113 |
switch (tag_at(index).value()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2114 |
case JVM_CONSTANT_Class : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2115 |
{ Klass* k = klass_at(index, CATCH); |
16383
57cb9d398a11
8009593: [parfait] Null pointer deference in hotspot/src/share/vm/oops/constantPool.cpp
morris
parents:
15799
diff
changeset
|
2116 |
guarantee(k != NULL, "need klass"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2117 |
k->print_value_on(st); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
2118 |
st->print(" {" PTR_FORMAT "}", p2i(k)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2119 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2120 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2121 |
case JVM_CONSTANT_Fieldref : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2122 |
case JVM_CONSTANT_Methodref : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2123 |
case JVM_CONSTANT_InterfaceMethodref : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2124 |
st->print("klass_index=%d", uncached_klass_ref_index_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2125 |
st->print(" name_and_type_index=%d", uncached_name_and_type_ref_index_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2126 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2127 |
case JVM_CONSTANT_String : |
15799 | 2128 |
if (is_pseudo_string_at(index)) { |
2129 |
oop anObj = pseudo_string_at(index); |
|
2130 |
anObj->print_value_on(st); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
2131 |
st->print(" {" PTR_FORMAT "}", p2i(anObj)); |
15799 | 2132 |
} else { |
2133 |
unresolved_string_at(index)->print_value_on(st); |
|
2134 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2135 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2136 |
case JVM_CONSTANT_Integer : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2137 |
st->print("%d", int_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2138 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2139 |
case JVM_CONSTANT_Float : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2140 |
st->print("%f", float_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2141 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2142 |
case JVM_CONSTANT_Long : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2143 |
st->print_jlong(long_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2144 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2145 |
case JVM_CONSTANT_Double : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2146 |
st->print("%lf", double_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2147 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2148 |
case JVM_CONSTANT_NameAndType : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2149 |
st->print("name_index=%d", name_ref_index_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2150 |
st->print(" signature_index=%d", signature_ref_index_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2151 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2152 |
case JVM_CONSTANT_Utf8 : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2153 |
symbol_at(index)->print_value_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2154 |
break; |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2155 |
case JVM_CONSTANT_ClassIndex: { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2156 |
int name_index = *int_at_addr(index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2157 |
st->print("klass_index=%d ", name_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2158 |
symbol_at(name_index)->print_value_on(st); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2159 |
} |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2160 |
break; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2161 |
case JVM_CONSTANT_UnresolvedClass : // fall-through |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2162 |
case JVM_CONSTANT_UnresolvedClassInError: { |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2163 |
CPKlassSlot kslot = klass_slot_at(index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2164 |
int resolved_klass_index = kslot.resolved_klass_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2165 |
int name_index = kslot.name_index(); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2166 |
assert(tag_at(name_index).is_symbol(), "sanity"); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2167 |
|
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2168 |
Klass* klass = resolved_klasses()->at(resolved_klass_index); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2169 |
if (klass != NULL) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2170 |
klass->print_value_on(st); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2171 |
} else { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2172 |
symbol_at(name_index)->print_value_on(st); |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2173 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2174 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2175 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2176 |
case JVM_CONSTANT_MethodHandle : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2177 |
case JVM_CONSTANT_MethodHandleInError : |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
2178 |
st->print("ref_kind=%d", method_handle_ref_kind_at(index)); |
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
2179 |
st->print(" ref_index=%d", method_handle_index_at(index)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2180 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2181 |
case JVM_CONSTANT_MethodType : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2182 |
case JVM_CONSTANT_MethodTypeInError : |
37475
0da78fa10d78
8148772: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents:
37451
diff
changeset
|
2183 |
st->print("signature_index=%d", method_type_index_at(index)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2184 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2185 |
case JVM_CONSTANT_InvokeDynamic : |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2186 |
{ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2187 |
st->print("bootstrap_method_index=%d", invoke_dynamic_bootstrap_method_ref_index_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2188 |
st->print(" name_and_type_index=%d", invoke_dynamic_name_and_type_ref_index_at(index)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2189 |
int argc = invoke_dynamic_argument_count_at(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2190 |
if (argc > 0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2191 |
for (int arg_i = 0; arg_i < argc; arg_i++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2192 |
int arg = invoke_dynamic_argument_index_at(index, arg_i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2193 |
st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2194 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2195 |
st->print("}"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2196 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2197 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2198 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2199 |
default: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2200 |
ShouldNotReachHere(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2201 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2202 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2203 |
st->cr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2204 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2205 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2206 |
void ConstantPool::print_value_on(outputStream* st) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2207 |
assert(is_constantPool(), "must be constantPool"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2208 |
st->print("constant pool [%d]", length()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2209 |
if (has_preresolution()) st->print("/preresolution"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2210 |
if (operands() != NULL) st->print("/operands[%d]", operands()->length()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2211 |
print_address_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2212 |
st->print(" for "); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2213 |
pool_holder()->print_value_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2214 |
if (pool_holder() != NULL) { |
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
2215 |
bool extra = (pool_holder()->constants() != this); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2216 |
if (extra) st->print(" (extra)"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2217 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2218 |
if (cache() != NULL) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
2219 |
st->print(" cache=" PTR_FORMAT, p2i(cache())); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2220 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2221 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2222 |
|
15437 | 2223 |
#if INCLUDE_SERVICES |
2224 |
// Size Statistics |
|
2225 |
void ConstantPool::collect_statistics(KlassSizeStats *sz) const { |
|
2226 |
sz->_cp_all_bytes += (sz->_cp_bytes = sz->count(this)); |
|
2227 |
sz->_cp_all_bytes += (sz->_cp_tags_bytes = sz->count_array(tags())); |
|
2228 |
sz->_cp_all_bytes += (sz->_cp_cache_bytes = sz->count(cache())); |
|
2229 |
sz->_cp_all_bytes += (sz->_cp_operands_bytes = sz->count_array(operands())); |
|
2230 |
sz->_cp_all_bytes += (sz->_cp_refmap_bytes = sz->count_array(reference_map())); |
|
2231 |
||
2232 |
sz->_ro_bytes += sz->_cp_operands_bytes + sz->_cp_tags_bytes + |
|
2233 |
sz->_cp_refmap_bytes; |
|
2234 |
sz->_rw_bytes += sz->_cp_bytes + sz->_cp_cache_bytes; |
|
2235 |
} |
|
2236 |
#endif // INCLUDE_SERVICES |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2237 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2238 |
// Verification |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2239 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2240 |
void ConstantPool::verify_on(outputStream* st) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2241 |
guarantee(is_constantPool(), "object must be constant pool"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2242 |
for (int i = 0; i< length(); i++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2243 |
constantTag tag = tag_at(i); |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2244 |
if (tag.is_klass() || tag.is_unresolved_klass()) { |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2245 |
guarantee(klass_name_at(i)->refcount() != 0, "should have nonzero reference count"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2246 |
} else if (tag.is_symbol()) { |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2247 |
CPSlot entry = slot_at(i); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2248 |
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2249 |
} else if (tag.is_string()) { |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46329
diff
changeset
|
2250 |
CPSlot entry = slot_at(i); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2251 |
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2252 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2253 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2254 |
if (cache() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2255 |
// Note: cache() can be NULL before a class is completely setup or |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2256 |
// in temporary constant pools used during constant pool merging |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2257 |
guarantee(cache()->is_constantPoolCache(), "should be constant pool cache"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2258 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2259 |
if (pool_holder() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2260 |
// Note: pool_holder() can be NULL in temporary constant pools |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2261 |
// used during constant pool merging |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2262 |
guarantee(pool_holder()->is_klass(), "should be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2263 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2264 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2265 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2266 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
2267 |
void SymbolHashMap::add_entry(Symbol* sym, u2 value) { |
1 | 2268 |
char *str = sym->as_utf8(); |
2269 |
unsigned int hash = compute_hash(str, sym->utf8_length()); |
|
2270 |
unsigned int index = hash % table_size(); |
|
2271 |
||
2272 |
// check if already in map |
|
2273 |
// we prefer the first entry since it is more likely to be what was used in |
|
2274 |
// the class file |
|
2275 |
for (SymbolHashMapEntry *en = bucket(index); en != NULL; en = en->next()) { |
|
2276 |
assert(en->symbol() != NULL, "SymbolHashMapEntry symbol is NULL"); |
|
2277 |
if (en->hash() == hash && en->symbol() == sym) { |
|
2278 |
return; // already there |
|
2279 |
} |
|
2280 |
} |
|
2281 |
||
2282 |
SymbolHashMapEntry* entry = new SymbolHashMapEntry(hash, sym, value); |
|
2283 |
entry->set_next(bucket(index)); |
|
2284 |
_buckets[index].set_entry(entry); |
|
2285 |
assert(entry->symbol() != NULL, "SymbolHashMapEntry symbol is NULL"); |
|
2286 |
} |
|
2287 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
2288 |
SymbolHashMapEntry* SymbolHashMap::find_entry(Symbol* sym) { |
1 | 2289 |
assert(sym != NULL, "SymbolHashMap::find_entry - symbol is NULL"); |
2290 |
char *str = sym->as_utf8(); |
|
2291 |
int len = sym->utf8_length(); |
|
2292 |
unsigned int hash = SymbolHashMap::compute_hash(str, len); |
|
2293 |
unsigned int index = hash % table_size(); |
|
2294 |
for (SymbolHashMapEntry *en = bucket(index); en != NULL; en = en->next()) { |
|
2295 |
assert(en->symbol() != NULL, "SymbolHashMapEntry symbol is NULL"); |
|
2296 |
if (en->hash() == hash && en->symbol() == sym) { |
|
2297 |
return en; |
|
2298 |
} |
|
2299 |
} |
|
2300 |
return NULL; |
|
2301 |
} |