author | never |
Fri, 18 Mar 2011 16:00:34 -0700 | |
changeset 8725 | 8c1e3dd5fe1b |
parent 8651 | 81b517a9249f |
child 9116 | 9bc44be338d6 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8651
diff
changeset
|
2 |
* Copyright (c) 1997, 2011, 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" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "classfile/symbolTable.hpp" |
|
28 |
#include "classfile/systemDictionary.hpp" |
|
29 |
#include "classfile/vmSymbols.hpp" |
|
30 |
#include "interpreter/linkResolver.hpp" |
|
31 |
#include "memory/oopFactory.hpp" |
|
32 |
#include "memory/universe.inline.hpp" |
|
33 |
#include "oops/constantPoolOop.hpp" |
|
34 |
#include "oops/instanceKlass.hpp" |
|
35 |
#include "oops/objArrayKlass.hpp" |
|
36 |
#include "oops/oop.inline.hpp" |
|
37 |
#include "runtime/fieldType.hpp" |
|
38 |
#include "runtime/init.hpp" |
|
39 |
#include "runtime/signature.hpp" |
|
40 |
#include "runtime/vframe.hpp" |
|
1 | 41 |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
42 |
void constantPoolOopDesc::set_flag_at(FlagBit fb) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
43 |
const int MAX_STATE_CHANGES = 2; |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
44 |
for (int i = MAX_STATE_CHANGES + 10; i > 0; i--) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
45 |
int oflags = _flags; |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
46 |
int nflags = oflags | (1 << (int)fb); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
47 |
if (Atomic::cmpxchg(nflags, &_flags, oflags) == oflags) |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
48 |
return; |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
49 |
} |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
50 |
assert(false, "failed to cmpxchg flags"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
51 |
_flags |= (1 << (int)fb); // better than nothing |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
52 |
} |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
53 |
|
1 | 54 |
klassOop constantPoolOopDesc::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
55 |
// A resolved constantPool entry will contain a klassOop, otherwise a Symbol*. |
1 | 56 |
// It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and |
57 |
// tag is not updated atomicly. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
58 |
CPSlot entry = this_oop->slot_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
59 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
60 |
assert(entry.get_oop()->is_klass(), "must be"); |
1 | 61 |
// Already resolved - return entry. |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
62 |
return (klassOop)entry.get_oop(); |
1 | 63 |
} |
64 |
||
65 |
// Acquire lock on constant oop while doing update. After we get the lock, we check if another object |
|
66 |
// already has updated the object |
|
67 |
assert(THREAD->is_Java_thread(), "must be a Java thread"); |
|
68 |
bool do_resolve = false; |
|
69 |
bool in_error = false; |
|
70 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
71 |
Symbol* name = NULL; |
1 | 72 |
Handle loader; |
73 |
{ ObjectLocker ol(this_oop, THREAD); |
|
74 |
||
75 |
if (this_oop->tag_at(which).is_unresolved_klass()) { |
|
76 |
if (this_oop->tag_at(which).is_unresolved_klass_in_error()) { |
|
77 |
in_error = true; |
|
78 |
} else { |
|
79 |
do_resolve = true; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
80 |
name = this_oop->unresolved_klass_at(which); |
1 | 81 |
loader = Handle(THREAD, instanceKlass::cast(this_oop->pool_holder())->class_loader()); |
82 |
} |
|
83 |
} |
|
84 |
} // unlocking constantPool |
|
85 |
||
86 |
||
87 |
// The original attempt to resolve this constant pool entry failed so find the |
|
88 |
// original error and throw it again (JVMS 5.4.3). |
|
89 |
if (in_error) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
90 |
Symbol* error = SystemDictionary::find_resolution_error(this_oop, which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
91 |
guarantee(error != (Symbol*)NULL, "tag mismatch with resolution error table"); |
1 | 92 |
ResourceMark rm; |
93 |
// exception text will be the class name |
|
94 |
const char* className = this_oop->unresolved_klass_at(which)->as_C_string(); |
|
95 |
THROW_MSG_0(error, className); |
|
96 |
} |
|
97 |
||
98 |
if (do_resolve) { |
|
99 |
// this_oop must be unlocked during resolve_or_fail |
|
100 |
oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain(); |
|
101 |
Handle h_prot (THREAD, protection_domain); |
|
102 |
klassOop k_oop = SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD); |
|
103 |
KlassHandle k; |
|
104 |
if (!HAS_PENDING_EXCEPTION) { |
|
105 |
k = KlassHandle(THREAD, k_oop); |
|
106 |
// Do access check for klasses |
|
107 |
verify_constant_pool_resolve(this_oop, k, THREAD); |
|
108 |
} |
|
109 |
||
110 |
// Failed to resolve class. We must record the errors so that subsequent attempts |
|
111 |
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3). |
|
112 |
if (HAS_PENDING_EXCEPTION) { |
|
113 |
ResourceMark rm; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
114 |
Symbol* error = PENDING_EXCEPTION->klass()->klass_part()->name(); |
1 | 115 |
|
116 |
bool throw_orig_error = false; |
|
117 |
{ |
|
118 |
ObjectLocker ol (this_oop, THREAD); |
|
119 |
||
120 |
// some other thread has beaten us and has resolved the class. |
|
121 |
if (this_oop->tag_at(which).is_klass()) { |
|
122 |
CLEAR_PENDING_EXCEPTION; |
|
123 |
entry = this_oop->resolved_klass_at(which); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
124 |
return (klassOop)entry.get_oop(); |
1 | 125 |
} |
126 |
||
127 |
if (!PENDING_EXCEPTION-> |
|
4571 | 128 |
is_a(SystemDictionary::LinkageError_klass())) { |
1 | 129 |
// Just throw the exception and don't prevent these classes from |
130 |
// being loaded due to virtual machine errors like StackOverflow |
|
131 |
// and OutOfMemoryError, etc, or if the thread was hit by stop() |
|
132 |
// Needs clarification to section 5.4.3 of the VM spec (see 6308271) |
|
133 |
} |
|
134 |
else if (!this_oop->tag_at(which).is_unresolved_klass_in_error()) { |
|
135 |
SystemDictionary::add_resolution_error(this_oop, which, error); |
|
136 |
this_oop->tag_at_put(which, JVM_CONSTANT_UnresolvedClassInError); |
|
137 |
} else { |
|
138 |
// some other thread has put the class in error state. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
139 |
error = SystemDictionary::find_resolution_error(this_oop, which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
140 |
assert(error != NULL, "checking"); |
1 | 141 |
throw_orig_error = true; |
142 |
} |
|
143 |
} // unlocked |
|
144 |
||
145 |
if (throw_orig_error) { |
|
146 |
CLEAR_PENDING_EXCEPTION; |
|
147 |
ResourceMark rm; |
|
148 |
const char* className = this_oop->unresolved_klass_at(which)->as_C_string(); |
|
149 |
THROW_MSG_0(error, className); |
|
150 |
} |
|
151 |
||
152 |
return 0; |
|
153 |
} |
|
154 |
||
155 |
if (TraceClassResolution && !k()->klass_part()->oop_is_array()) { |
|
156 |
// skip resolving the constant pool so that this code get's |
|
157 |
// called the next time some bytecodes refer to this class. |
|
158 |
ResourceMark rm; |
|
159 |
int line_number = -1; |
|
160 |
const char * source_file = NULL; |
|
161 |
if (JavaThread::current()->has_last_Java_frame()) { |
|
162 |
// try to identify the method which called this function. |
|
163 |
vframeStream vfst(JavaThread::current()); |
|
164 |
if (!vfst.at_end()) { |
|
165 |
line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
166 |
Symbol* s = instanceKlass::cast(vfst.method()->method_holder())->source_file_name(); |
1 | 167 |
if (s != NULL) { |
168 |
source_file = s->as_C_string(); |
|
169 |
} |
|
170 |
} |
|
171 |
} |
|
172 |
if (k() != this_oop->pool_holder()) { |
|
173 |
// only print something if the classes are different |
|
174 |
if (source_file != NULL) { |
|
175 |
tty->print("RESOLVE %s %s %s:%d\n", |
|
176 |
instanceKlass::cast(this_oop->pool_holder())->external_name(), |
|
177 |
instanceKlass::cast(k())->external_name(), source_file, line_number); |
|
178 |
} else { |
|
179 |
tty->print("RESOLVE %s %s\n", |
|
180 |
instanceKlass::cast(this_oop->pool_holder())->external_name(), |
|
181 |
instanceKlass::cast(k())->external_name()); |
|
182 |
} |
|
183 |
} |
|
184 |
return k(); |
|
185 |
} else { |
|
186 |
ObjectLocker ol (this_oop, THREAD); |
|
187 |
// Only updated constant pool - if it is resolved. |
|
188 |
do_resolve = this_oop->tag_at(which).is_unresolved_klass(); |
|
189 |
if (do_resolve) { |
|
190 |
this_oop->klass_at_put(which, k()); |
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
entry = this_oop->resolved_klass_at(which); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
196 |
assert(entry.is_oop() && entry.get_oop()->is_klass(), "must be resolved at this point"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
197 |
return (klassOop)entry.get_oop(); |
1 | 198 |
} |
199 |
||
200 |
||
201 |
// Does not update constantPoolOop - to avoid any exception throwing. Used |
|
202 |
// by compiler and exception handling. Also used to avoid classloads for |
|
203 |
// instanceof operations. Returns NULL if the class has not been loaded or |
|
204 |
// if the verification of constant pool failed |
|
205 |
klassOop constantPoolOopDesc::klass_at_if_loaded(constantPoolHandle this_oop, int which) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
206 |
CPSlot entry = this_oop->slot_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
207 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
208 |
assert(entry.get_oop()->is_klass(), "must be"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
209 |
return (klassOop)entry.get_oop(); |
1 | 210 |
} else { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
211 |
assert(entry.is_metadata(), "must be either symbol or klass"); |
1 | 212 |
Thread *thread = Thread::current(); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
213 |
Symbol* name = entry.get_symbol(); |
1 | 214 |
oop loader = instanceKlass::cast(this_oop->pool_holder())->class_loader(); |
215 |
oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain(); |
|
216 |
Handle h_prot (thread, protection_domain); |
|
217 |
Handle h_loader (thread, loader); |
|
218 |
klassOop k = SystemDictionary::find(name, h_loader, h_prot, thread); |
|
219 |
||
220 |
if (k != NULL) { |
|
221 |
// Make sure that resolving is legal |
|
222 |
EXCEPTION_MARK; |
|
223 |
KlassHandle klass(THREAD, k); |
|
224 |
// return NULL if verification fails |
|
225 |
verify_constant_pool_resolve(this_oop, klass, THREAD); |
|
226 |
if (HAS_PENDING_EXCEPTION) { |
|
227 |
CLEAR_PENDING_EXCEPTION; |
|
228 |
return NULL; |
|
229 |
} |
|
230 |
return klass(); |
|
231 |
} else { |
|
232 |
return k; |
|
233 |
} |
|
234 |
} |
|
235 |
} |
|
236 |
||
237 |
||
238 |
klassOop constantPoolOopDesc::klass_ref_at_if_loaded(constantPoolHandle this_oop, int which) { |
|
239 |
return klass_at_if_loaded(this_oop, this_oop->klass_ref_index_at(which)); |
|
240 |
} |
|
241 |
||
242 |
||
243 |
// This is an interface for the compiler that allows accessing non-resolved entries |
|
244 |
// in the constant pool - but still performs the validations tests. Must be used |
|
245 |
// in a pre-parse of the compiler - to determine what it can do and not do. |
|
246 |
// Note: We cannot update the ConstantPool from the vm_thread. |
|
247 |
klassOop constantPoolOopDesc::klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int index, TRAPS) { |
|
248 |
int which = this_oop->klass_ref_index_at(index); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
249 |
CPSlot entry = this_oop->slot_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
250 |
if (entry.is_oop()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
251 |
assert(entry.get_oop()->is_klass(), "must be"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
252 |
return (klassOop)entry.get_oop(); |
1 | 253 |
} else { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
254 |
assert(entry.is_metadata(), "must be either symbol or klass"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
255 |
Symbol* name = entry.get_symbol(); |
1 | 256 |
oop loader = instanceKlass::cast(this_oop->pool_holder())->class_loader(); |
257 |
oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain(); |
|
258 |
Handle h_loader(THREAD, loader); |
|
259 |
Handle h_prot (THREAD, protection_domain); |
|
260 |
KlassHandle k(THREAD, SystemDictionary::find(name, h_loader, h_prot, THREAD)); |
|
261 |
||
262 |
// Do access check for klasses |
|
263 |
if( k.not_null() ) verify_constant_pool_resolve(this_oop, k, CHECK_NULL); |
|
264 |
return k(); |
|
265 |
} |
|
266 |
} |
|
267 |
||
268 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
269 |
Symbol* constantPoolOopDesc::impl_name_ref_at(int which, bool uncached) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
270 |
int name_index = name_ref_index_at(impl_name_and_type_ref_index_at(which, uncached)); |
1 | 271 |
return symbol_at(name_index); |
272 |
} |
|
273 |
||
274 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
275 |
Symbol* constantPoolOopDesc::impl_signature_ref_at(int which, bool uncached) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
276 |
int signature_index = signature_ref_index_at(impl_name_and_type_ref_index_at(which, uncached)); |
1 | 277 |
return symbol_at(signature_index); |
278 |
} |
|
279 |
||
280 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
281 |
int constantPoolOopDesc::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
|
282 |
int i = which; |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
283 |
if (!uncached && cache() != NULL) { |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
284 |
if (constantPoolCacheOopDesc::is_secondary_index(which)) { |
7111
ac1a0346bc0f
6981788: GC map generator sometimes picks up the wrong kind of instruction operand
jrose
parents:
6463
diff
changeset
|
285 |
// Invokedynamic index. |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
286 |
int pool_index = cache()->main_entry_at(which)->constant_pool_index(); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
287 |
if (!AllowTransitionalJSR292 || tag_at(pool_index).is_invoke_dynamic()) |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
288 |
pool_index = invoke_dynamic_name_and_type_ref_index_at(pool_index); |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
289 |
assert(tag_at(pool_index).is_name_and_type(), ""); |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
290 |
return pool_index; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
291 |
} |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
292 |
// change byte-ordering and go via cache |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
293 |
i = remap_instruction_operand_from_cache(which); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
294 |
} else { |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
295 |
if (AllowTransitionalJSR292 && tag_at(which).is_name_and_type()) |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
296 |
// invokedynamic index is a simple name-and-type |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
297 |
return which; |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
298 |
if (tag_at(which).is_invoke_dynamic()) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
299 |
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
|
300 |
assert(tag_at(pool_index).is_name_and_type(), ""); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
301 |
return pool_index; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
302 |
} |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
303 |
} |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
304 |
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
|
305 |
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
|
306 |
jint ref_index = *int_at_addr(i); |
1 | 307 |
return extract_high_short_from_int(ref_index); |
308 |
} |
|
309 |
||
310 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
311 |
int constantPoolOopDesc::impl_klass_ref_index_at(int which, bool uncached) { |
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
312 |
guarantee(!constantPoolCacheOopDesc::is_secondary_index(which), |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
313 |
"an invokedynamic instruction does not have a klass"); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
314 |
int i = which; |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
315 |
if (!uncached && cache() != NULL) { |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
316 |
// change byte-ordering and go via cache |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
317 |
i = remap_instruction_operand_from_cache(which); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
318 |
} |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
319 |
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
|
320 |
jint ref_index = *int_at_addr(i); |
1 | 321 |
return extract_low_short_from_int(ref_index); |
322 |
} |
|
323 |
||
324 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
325 |
|
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
326 |
int constantPoolOopDesc::remap_instruction_operand_from_cache(int operand) { |
5688 | 327 |
int cpc_index = operand; |
328 |
DEBUG_ONLY(cpc_index -= CPCACHE_INDEX_TAG); |
|
329 |
assert((int)(u2)cpc_index == cpc_index, "clean u2"); |
|
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
2860
diff
changeset
|
330 |
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
|
331 |
return member_index; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
332 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
333 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
334 |
|
1 | 335 |
void constantPoolOopDesc::verify_constant_pool_resolve(constantPoolHandle this_oop, KlassHandle k, TRAPS) { |
336 |
if (k->oop_is_instance() || k->oop_is_objArray()) { |
|
337 |
instanceKlassHandle holder (THREAD, this_oop->pool_holder()); |
|
338 |
klassOop elem_oop = k->oop_is_instance() ? k() : objArrayKlass::cast(k())->bottom_klass(); |
|
339 |
KlassHandle element (THREAD, elem_oop); |
|
340 |
||
341 |
// The element type could be a typeArray - we only need the access check if it is |
|
342 |
// an reference to another class |
|
343 |
if (element->oop_is_instance()) { |
|
344 |
LinkResolver::check_klass_accessability(holder, element, CHECK); |
|
345 |
} |
|
346 |
} |
|
347 |
} |
|
348 |
||
349 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
350 |
int constantPoolOopDesc::name_ref_index_at(int which_nt) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
351 |
jint ref_index = name_and_type_at(which_nt); |
1 | 352 |
return extract_low_short_from_int(ref_index); |
353 |
} |
|
354 |
||
355 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
356 |
int constantPoolOopDesc::signature_ref_index_at(int which_nt) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
357 |
jint ref_index = name_and_type_at(which_nt); |
1 | 358 |
return extract_high_short_from_int(ref_index); |
359 |
} |
|
360 |
||
361 |
||
362 |
klassOop constantPoolOopDesc::klass_ref_at(int which, TRAPS) { |
|
363 |
return klass_at(klass_ref_index_at(which), CHECK_NULL); |
|
364 |
} |
|
365 |
||
366 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
367 |
Symbol* constantPoolOopDesc::klass_name_at(int which) { |
1 | 368 |
assert(tag_at(which).is_unresolved_klass() || tag_at(which).is_klass(), |
369 |
"Corrupted constant pool"); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
370 |
// A resolved constantPool entry will contain a klassOop, otherwise a Symbol*. |
1 | 371 |
// It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and |
372 |
// tag is not updated atomicly. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
373 |
CPSlot entry = slot_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
374 |
if (entry.is_oop()) { |
1 | 375 |
// Already resolved - return entry's name. |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
376 |
assert(entry.get_oop()->is_klass(), "must be"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
377 |
return klassOop(entry.get_oop())->klass_part()->name(); |
1 | 378 |
} else { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
379 |
assert(entry.is_metadata(), "must be either symbol or klass"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
380 |
return entry.get_symbol(); |
1 | 381 |
} |
382 |
} |
|
383 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
384 |
Symbol* constantPoolOopDesc::klass_ref_at_noresolve(int which) { |
1 | 385 |
jint ref_index = klass_ref_index_at(which); |
386 |
return klass_at_noresolve(ref_index); |
|
387 |
} |
|
388 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
389 |
Symbol* constantPoolOopDesc::uncached_klass_ref_at_noresolve(int which) { |
5882 | 390 |
jint ref_index = uncached_klass_ref_index_at(which); |
391 |
return klass_at_noresolve(ref_index); |
|
392 |
} |
|
393 |
||
1 | 394 |
char* constantPoolOopDesc::string_at_noresolve(int which) { |
395 |
// Test entry type in case string is resolved while in here. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
396 |
CPSlot entry = slot_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
397 |
if (entry.is_metadata()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
398 |
return (entry.get_symbol())->as_C_string(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
399 |
} else if (java_lang_String::is_instance(entry.get_oop())) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
400 |
return java_lang_String::as_utf8_string(entry.get_oop()); |
1 | 401 |
} else { |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
402 |
return (char*)"<pseudo-string>"; |
1 | 403 |
} |
404 |
} |
|
405 |
||
406 |
||
407 |
BasicType constantPoolOopDesc::basic_type_for_signature_at(int which) { |
|
408 |
return FieldType::basic_type(symbol_at(which)); |
|
409 |
} |
|
410 |
||
411 |
||
412 |
void constantPoolOopDesc::resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS) { |
|
413 |
for (int index = 1; index < this_oop->length(); index++) { // Index 0 is unused |
|
414 |
if (this_oop->tag_at(index).is_unresolved_string()) { |
|
415 |
this_oop->string_at(index, CHECK); |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
||
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
420 |
// A resolved constant value in the CP cache is represented as a non-null |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
421 |
// value. As a special case, this value can be a 'systemObjArray' |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
422 |
// which masks an exception object to throw. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
423 |
// This allows a MethodHandle constant reference to throw a consistent |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
424 |
// exception every time, if it fails to resolve. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
425 |
static oop decode_exception_from_f1(oop result_oop, TRAPS) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
426 |
if (result_oop->klass() != Universe::systemObjArrayKlassObj()) |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
427 |
return result_oop; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
428 |
|
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
429 |
// Special cases here: Masked null, saved exception. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
430 |
objArrayOop sys_array = (objArrayOop) result_oop; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
431 |
assert(sys_array->length() == 1, "bad system array"); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
432 |
if (sys_array->length() == 1) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
433 |
THROW_OOP_(sys_array->obj_at(0), NULL); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
434 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
435 |
return NULL; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
436 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
437 |
|
5882 | 438 |
oop constantPoolOopDesc::resolve_constant_at_impl(constantPoolHandle this_oop, int index, int cache_index, TRAPS) { |
439 |
oop result_oop = NULL; |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
440 |
Handle throw_exception; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
441 |
|
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
442 |
if (cache_index == _possible_index_sentinel) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
443 |
// It is possible that this constant is one which is cached in the CP cache. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
444 |
// 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
|
445 |
assert(index > 0, "valid index"); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
446 |
constantPoolCacheOop cache = this_oop()->cache(); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
447 |
for (int i = 0, len = cache->length(); i < len; i++) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
448 |
ConstantPoolCacheEntry* cpc_entry = cache->entry_at(i); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
449 |
if (!cpc_entry->is_secondary_entry() && cpc_entry->constant_pool_index() == index) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
450 |
// Switch the query to use this CPC entry. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
451 |
cache_index = i; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
452 |
index = _no_index_sentinel; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
453 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
454 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
455 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
456 |
if (cache_index == _possible_index_sentinel) |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
457 |
cache_index = _no_index_sentinel; // not found |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
458 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
459 |
assert(cache_index == _no_index_sentinel || cache_index >= 0, ""); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
460 |
assert(index == _no_index_sentinel || index >= 0, ""); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
461 |
|
5882 | 462 |
if (cache_index >= 0) { |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
463 |
assert(index == _no_index_sentinel, "only one kind of index at a time"); |
5882 | 464 |
ConstantPoolCacheEntry* cpc_entry = this_oop->cache()->entry_at(cache_index); |
465 |
result_oop = cpc_entry->f1(); |
|
466 |
if (result_oop != NULL) { |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
467 |
return decode_exception_from_f1(result_oop, THREAD); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
468 |
// That was easy... |
5882 | 469 |
} |
470 |
index = cpc_entry->constant_pool_index(); |
|
471 |
} |
|
472 |
||
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
473 |
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
|
474 |
|
5882 | 475 |
int tag_value = this_oop->tag_at(index).value(); |
476 |
switch (tag_value) { |
|
477 |
||
478 |
case JVM_CONSTANT_UnresolvedClass: |
|
479 |
case JVM_CONSTANT_UnresolvedClassInError: |
|
480 |
case JVM_CONSTANT_Class: |
|
481 |
{ |
|
482 |
klassOop resolved = klass_at_impl(this_oop, index, CHECK_NULL); |
|
483 |
// ldc wants the java mirror. |
|
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
8651
diff
changeset
|
484 |
result_oop = resolved->java_mirror(); |
5882 | 485 |
break; |
486 |
} |
|
487 |
||
488 |
case JVM_CONSTANT_String: |
|
489 |
case JVM_CONSTANT_UnresolvedString: |
|
490 |
if (this_oop->is_pseudo_string_at(index)) { |
|
491 |
result_oop = this_oop->pseudo_string_at(index); |
|
492 |
break; |
|
493 |
} |
|
494 |
result_oop = string_at_impl(this_oop, index, CHECK_NULL); |
|
495 |
break; |
|
496 |
||
497 |
case JVM_CONSTANT_Object: |
|
498 |
result_oop = this_oop->object_at(index); |
|
499 |
break; |
|
500 |
||
501 |
case JVM_CONSTANT_MethodHandle: |
|
502 |
{ |
|
503 |
int ref_kind = this_oop->method_handle_ref_kind_at(index); |
|
504 |
int callee_index = this_oop->method_handle_klass_index_at(index); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
505 |
Symbol* name = this_oop->method_handle_name_ref_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
506 |
Symbol* signature = this_oop->method_handle_signature_ref_at(index); |
5882 | 507 |
if (PrintMiscellaneous) |
508 |
tty->print_cr("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s", |
|
509 |
ref_kind, index, this_oop->method_handle_index_at(index), |
|
510 |
callee_index, name->as_C_string(), signature->as_C_string()); |
|
511 |
KlassHandle callee; |
|
512 |
{ klassOop k = klass_at_impl(this_oop, callee_index, CHECK_NULL); |
|
513 |
callee = KlassHandle(THREAD, k); |
|
514 |
} |
|
515 |
KlassHandle klass(THREAD, this_oop->pool_holder()); |
|
516 |
Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind, |
|
517 |
callee, name, signature, |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
518 |
THREAD); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
519 |
if (HAS_PENDING_EXCEPTION) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
520 |
throw_exception = Handle(THREAD, PENDING_EXCEPTION); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
521 |
CLEAR_PENDING_EXCEPTION; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
522 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
523 |
} |
5882 | 524 |
result_oop = value(); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
525 |
assert(result_oop != NULL, ""); |
5882 | 526 |
break; |
527 |
} |
|
528 |
||
529 |
case JVM_CONSTANT_MethodType: |
|
530 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
531 |
Symbol* signature = this_oop->method_type_signature_at(index); |
5882 | 532 |
if (PrintMiscellaneous) |
533 |
tty->print_cr("resolve JVM_CONSTANT_MethodType [%d/%d] %s", |
|
534 |
index, this_oop->method_type_index_at(index), |
|
535 |
signature->as_C_string()); |
|
536 |
KlassHandle klass(THREAD, this_oop->pool_holder()); |
|
537 |
bool ignore_is_on_bcp = false; |
|
538 |
Handle value = SystemDictionary::find_method_handle_type(signature, |
|
539 |
klass, |
|
6463
f4362c8da849
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
6062
diff
changeset
|
540 |
false, |
5882 | 541 |
ignore_is_on_bcp, |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
542 |
THREAD); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
543 |
if (HAS_PENDING_EXCEPTION) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
544 |
throw_exception = Handle(THREAD, PENDING_EXCEPTION); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
545 |
CLEAR_PENDING_EXCEPTION; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
546 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
547 |
} |
5882 | 548 |
result_oop = value(); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
549 |
assert(result_oop != NULL, ""); |
5882 | 550 |
break; |
551 |
} |
|
552 |
||
553 |
case JVM_CONSTANT_Integer: |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
554 |
prim_value.i = this_oop->int_at(index); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
555 |
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
|
556 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
557 |
|
5882 | 558 |
case JVM_CONSTANT_Float: |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
559 |
prim_value.f = this_oop->float_at(index); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
560 |
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
|
561 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
562 |
|
5882 | 563 |
case JVM_CONSTANT_Long: |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
564 |
prim_value.j = this_oop->long_at(index); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
565 |
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
|
566 |
break; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
567 |
|
5882 | 568 |
case JVM_CONSTANT_Double: |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
569 |
prim_value.d = this_oop->double_at(index); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
570 |
result_oop = java_lang_boxing_object::create(T_DOUBLE, &prim_value, CHECK_NULL); |
5882 | 571 |
break; |
572 |
||
573 |
default: |
|
574 |
DEBUG_ONLY( tty->print_cr("*** %p: tag at CP[%d/%d] = %d", |
|
575 |
this_oop(), index, cache_index, tag_value) ); |
|
576 |
assert(false, "unexpected constant tag"); |
|
577 |
break; |
|
578 |
} |
|
579 |
||
580 |
if (cache_index >= 0) { |
|
581 |
// Cache the oop here also. |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
582 |
if (throw_exception.not_null()) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
583 |
objArrayOop sys_array = oopFactory::new_system_objArray(1, CHECK_NULL); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
584 |
sys_array->obj_at_put(0, throw_exception()); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
585 |
result_oop = sys_array; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
586 |
throw_exception = Handle(); // be tidy |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
587 |
} |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
588 |
Handle result_handle(THREAD, result_oop); |
5882 | 589 |
result_oop = NULL; // safety |
590 |
ObjectLocker ol(this_oop, THREAD); |
|
591 |
ConstantPoolCacheEntry* cpc_entry = this_oop->cache()->entry_at(cache_index); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
592 |
result_oop = cpc_entry->f1(); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
593 |
// Benign race condition: f1 may already be filled in while we were trying to lock. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
594 |
// 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
|
595 |
// 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
|
596 |
// result is used by all threads, and all future queries. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
597 |
// That result may be either a resolved constant or a failure exception. |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
598 |
if (result_oop == NULL) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
599 |
result_oop = result_handle(); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
600 |
cpc_entry->set_f1(result_oop); |
5882 | 601 |
} |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
602 |
return decode_exception_from_f1(result_oop, THREAD); |
5882 | 603 |
} else { |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
604 |
if (throw_exception.not_null()) { |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
605 |
THROW_HANDLE_(throw_exception, NULL); |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
606 |
} |
5882 | 607 |
return result_oop; |
608 |
} |
|
609 |
} |
|
610 |
||
1 | 611 |
oop constantPoolOopDesc::string_at_impl(constantPoolHandle this_oop, int which, TRAPS) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
612 |
oop str = NULL; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
613 |
CPSlot entry = this_oop->slot_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
614 |
if (entry.is_metadata()) { |
1 | 615 |
ObjectLocker ol(this_oop, THREAD); |
616 |
if (this_oop->tag_at(which).is_unresolved_string()) { |
|
617 |
// Intern string |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
618 |
Symbol* sym = this_oop->unresolved_string_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
619 |
str = StringTable::intern(sym, CHECK_(constantPoolOop(NULL))); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
620 |
this_oop->string_at_put(which, str); |
1 | 621 |
} else { |
622 |
// Another thread beat us and interned string, read string from constant pool |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
623 |
str = this_oop->resolved_string_at(which); |
1 | 624 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
625 |
} else { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
626 |
str = entry.get_oop(); |
1 | 627 |
} |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
628 |
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
|
629 |
return str; |
1 | 630 |
} |
631 |
||
632 |
||
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
633 |
bool constantPoolOopDesc::is_pseudo_string_at(int which) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
634 |
CPSlot entry = slot_at(which); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
635 |
if (entry.is_metadata()) |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
636 |
// Not yet resolved, but it will resolve to a string. |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
637 |
return false; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
638 |
else if (java_lang_String::is_instance(entry.get_oop())) |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
639 |
return false; // actually, it might be a non-interned or non-perm string |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
640 |
else |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
641 |
// truly pseudo |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
642 |
return true; |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
643 |
} |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
644 |
|
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
645 |
|
1 | 646 |
bool constantPoolOopDesc::klass_name_at_matches(instanceKlassHandle k, |
647 |
int which) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
648 |
// 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
|
649 |
Symbol* cp_name = klass_name_at(which); |
1 | 650 |
return (cp_name == k->name()); |
651 |
} |
|
652 |
||
653 |
||
654 |
int constantPoolOopDesc::pre_resolve_shared_klasses(TRAPS) { |
|
655 |
ResourceMark rm; |
|
656 |
int count = 0; |
|
657 |
for (int index = 1; index < tags()->length(); index++) { // Index 0 is unused |
|
658 |
if (tag_at(index).is_unresolved_string()) { |
|
659 |
// Intern string |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
660 |
Symbol* sym = unresolved_string_at(index); |
1 | 661 |
oop entry = StringTable::intern(sym, CHECK_(-1)); |
662 |
string_at_put(index, entry); |
|
663 |
} |
|
664 |
} |
|
665 |
return count; |
|
666 |
} |
|
667 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
668 |
// Iterate over symbols and decrement ones which are Symbol*s. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
669 |
// This is done during GC so do not need to lock constantPool unless we |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
670 |
// have per-thread safepoints. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
671 |
// Only decrement the UTF8 symbols. Unresolved classes and strings point to |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
672 |
// these symbols but didn't increment the reference count. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
673 |
void constantPoolOopDesc::unreference_symbols() { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
674 |
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
|
675 |
constantTag tag = tag_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
676 |
if (tag.is_symbol()) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
677 |
symbol_at(index)->decrement_refcount(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
678 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
679 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
680 |
} |
1 | 681 |
|
682 |
// Iterate over symbols which are used as class, field, method names and |
|
683 |
// signatures (in preparation for writing to the shared archive). |
|
684 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
685 |
void constantPoolOopDesc::shared_symbols_iterate(SymbolClosure* closure) { |
1 | 686 |
for (int index = 1; index < length(); index++) { // Index 0 is unused |
687 |
switch (tag_at(index).value()) { |
|
688 |
||
689 |
case JVM_CONSTANT_UnresolvedClass: |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
690 |
case JVM_CONSTANT_UnresolvedString: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
691 |
case JVM_CONSTANT_Utf8: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
692 |
assert(slot_at(index).is_metadata(), "must be symbol"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
693 |
closure->do_symbol(symbol_at_addr(index)); |
1 | 694 |
break; |
695 |
||
696 |
case JVM_CONSTANT_NameAndType: |
|
697 |
{ |
|
698 |
int i = *int_at_addr(index); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
699 |
closure->do_symbol(symbol_at_addr((unsigned)i >> 16)); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
700 |
closure->do_symbol(symbol_at_addr((unsigned)i & 0xffff)); |
1 | 701 |
} |
702 |
break; |
|
703 |
||
704 |
case JVM_CONSTANT_Class: |
|
705 |
case JVM_CONSTANT_InterfaceMethodref: |
|
706 |
case JVM_CONSTANT_Fieldref: |
|
707 |
case JVM_CONSTANT_Methodref: |
|
708 |
case JVM_CONSTANT_Integer: |
|
709 |
case JVM_CONSTANT_Float: |
|
710 |
// Do nothing! Not an oop. |
|
711 |
// These constant types do not reference symbols at this point. |
|
712 |
break; |
|
713 |
||
714 |
case JVM_CONSTANT_String: |
|
715 |
// Do nothing! Not a symbol. |
|
716 |
break; |
|
717 |
||
718 |
case JVM_CONSTANT_Long: |
|
719 |
case JVM_CONSTANT_Double: |
|
720 |
// Do nothing! Not an oop. (But takes two pool entries.) |
|
721 |
++index; |
|
722 |
break; |
|
723 |
||
724 |
default: |
|
725 |
ShouldNotReachHere(); |
|
726 |
break; |
|
727 |
} |
|
728 |
} |
|
729 |
} |
|
730 |
||
731 |
||
732 |
// Iterate over the [one] tags array (in preparation for writing to the |
|
733 |
// shared archive). |
|
734 |
||
735 |
void constantPoolOopDesc::shared_tags_iterate(OopClosure* closure) { |
|
736 |
closure->do_oop(tags_addr()); |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
737 |
closure->do_oop(operands_addr()); |
1 | 738 |
} |
739 |
||
740 |
||
741 |
// Iterate over String objects (in preparation for writing to the shared |
|
742 |
// archive). |
|
743 |
||
744 |
void constantPoolOopDesc::shared_strings_iterate(OopClosure* closure) { |
|
745 |
for (int index = 1; index < length(); index++) { // Index 0 is unused |
|
746 |
switch (tag_at(index).value()) { |
|
747 |
||
748 |
case JVM_CONSTANT_UnresolvedClass: |
|
749 |
case JVM_CONSTANT_NameAndType: |
|
750 |
// Do nothing! Not a String. |
|
751 |
break; |
|
752 |
||
753 |
case JVM_CONSTANT_Class: |
|
754 |
case JVM_CONSTANT_InterfaceMethodref: |
|
755 |
case JVM_CONSTANT_Fieldref: |
|
756 |
case JVM_CONSTANT_Methodref: |
|
757 |
case JVM_CONSTANT_Integer: |
|
758 |
case JVM_CONSTANT_Float: |
|
759 |
// Do nothing! Not an oop. |
|
760 |
// These constant types do not reference symbols at this point. |
|
761 |
break; |
|
762 |
||
763 |
case JVM_CONSTANT_String: |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
764 |
closure->do_oop(obj_at_addr_raw(index)); |
1 | 765 |
break; |
766 |
||
767 |
case JVM_CONSTANT_UnresolvedString: |
|
768 |
case JVM_CONSTANT_Utf8: |
|
769 |
// These constants are symbols, but unless these symbols are |
|
770 |
// actually to be used for something, we don't want to mark them. |
|
771 |
break; |
|
772 |
||
773 |
case JVM_CONSTANT_Long: |
|
774 |
case JVM_CONSTANT_Double: |
|
775 |
// Do nothing! Not an oop. (But takes two pool entries.) |
|
776 |
++index; |
|
777 |
break; |
|
778 |
||
779 |
default: |
|
780 |
ShouldNotReachHere(); |
|
781 |
break; |
|
782 |
} |
|
783 |
} |
|
784 |
} |
|
785 |
||
786 |
||
787 |
// Compare this constant pool's entry at index1 to the constant pool |
|
788 |
// cp2's entry at index2. |
|
789 |
bool constantPoolOopDesc::compare_entry_to(int index1, constantPoolHandle cp2, |
|
790 |
int index2, TRAPS) { |
|
791 |
||
792 |
jbyte t1 = tag_at(index1).value(); |
|
793 |
jbyte t2 = cp2->tag_at(index2).value(); |
|
794 |
||
795 |
||
796 |
// JVM_CONSTANT_UnresolvedClassInError is equal to JVM_CONSTANT_UnresolvedClass |
|
797 |
// when comparing |
|
798 |
if (t1 == JVM_CONSTANT_UnresolvedClassInError) { |
|
799 |
t1 = JVM_CONSTANT_UnresolvedClass; |
|
800 |
} |
|
801 |
if (t2 == JVM_CONSTANT_UnresolvedClassInError) { |
|
802 |
t2 = JVM_CONSTANT_UnresolvedClass; |
|
803 |
} |
|
804 |
||
805 |
if (t1 != t2) { |
|
806 |
// Not the same entry type so there is nothing else to check. Note |
|
807 |
// that this style of checking will consider resolved/unresolved |
|
808 |
// class pairs and resolved/unresolved string pairs as different. |
|
809 |
// From the constantPoolOop API point of view, this is correct |
|
810 |
// behavior. See constantPoolKlass::merge() to see how this plays |
|
811 |
// out in the context of constantPoolOop merging. |
|
812 |
return false; |
|
813 |
} |
|
814 |
||
815 |
switch (t1) { |
|
816 |
case JVM_CONSTANT_Class: |
|
817 |
{ |
|
818 |
klassOop k1 = klass_at(index1, CHECK_false); |
|
819 |
klassOop k2 = cp2->klass_at(index2, CHECK_false); |
|
820 |
if (k1 == k2) { |
|
821 |
return true; |
|
822 |
} |
|
823 |
} break; |
|
824 |
||
825 |
case JVM_CONSTANT_ClassIndex: |
|
826 |
{ |
|
827 |
int recur1 = klass_index_at(index1); |
|
828 |
int recur2 = cp2->klass_index_at(index2); |
|
829 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
830 |
if (match) { |
|
831 |
return true; |
|
832 |
} |
|
833 |
} break; |
|
834 |
||
835 |
case JVM_CONSTANT_Double: |
|
836 |
{ |
|
837 |
jdouble d1 = double_at(index1); |
|
838 |
jdouble d2 = cp2->double_at(index2); |
|
839 |
if (d1 == d2) { |
|
840 |
return true; |
|
841 |
} |
|
842 |
} break; |
|
843 |
||
844 |
case JVM_CONSTANT_Fieldref: |
|
845 |
case JVM_CONSTANT_InterfaceMethodref: |
|
846 |
case JVM_CONSTANT_Methodref: |
|
847 |
{ |
|
848 |
int recur1 = uncached_klass_ref_index_at(index1); |
|
849 |
int recur2 = cp2->uncached_klass_ref_index_at(index2); |
|
850 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
851 |
if (match) { |
|
852 |
recur1 = uncached_name_and_type_ref_index_at(index1); |
|
853 |
recur2 = cp2->uncached_name_and_type_ref_index_at(index2); |
|
854 |
match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
855 |
if (match) { |
|
856 |
return true; |
|
857 |
} |
|
858 |
} |
|
859 |
} break; |
|
860 |
||
861 |
case JVM_CONSTANT_Float: |
|
862 |
{ |
|
863 |
jfloat f1 = float_at(index1); |
|
864 |
jfloat f2 = cp2->float_at(index2); |
|
865 |
if (f1 == f2) { |
|
866 |
return true; |
|
867 |
} |
|
868 |
} break; |
|
869 |
||
870 |
case JVM_CONSTANT_Integer: |
|
871 |
{ |
|
872 |
jint i1 = int_at(index1); |
|
873 |
jint i2 = cp2->int_at(index2); |
|
874 |
if (i1 == i2) { |
|
875 |
return true; |
|
876 |
} |
|
877 |
} break; |
|
878 |
||
879 |
case JVM_CONSTANT_Long: |
|
880 |
{ |
|
881 |
jlong l1 = long_at(index1); |
|
882 |
jlong l2 = cp2->long_at(index2); |
|
883 |
if (l1 == l2) { |
|
884 |
return true; |
|
885 |
} |
|
886 |
} break; |
|
887 |
||
888 |
case JVM_CONSTANT_NameAndType: |
|
889 |
{ |
|
890 |
int recur1 = name_ref_index_at(index1); |
|
891 |
int recur2 = cp2->name_ref_index_at(index2); |
|
892 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
893 |
if (match) { |
|
894 |
recur1 = signature_ref_index_at(index1); |
|
895 |
recur2 = cp2->signature_ref_index_at(index2); |
|
896 |
match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
897 |
if (match) { |
|
898 |
return true; |
|
899 |
} |
|
900 |
} |
|
901 |
} break; |
|
902 |
||
903 |
case JVM_CONSTANT_String: |
|
904 |
{ |
|
905 |
oop s1 = string_at(index1, CHECK_false); |
|
906 |
oop s2 = cp2->string_at(index2, CHECK_false); |
|
907 |
if (s1 == s2) { |
|
908 |
return true; |
|
909 |
} |
|
910 |
} break; |
|
911 |
||
912 |
case JVM_CONSTANT_StringIndex: |
|
913 |
{ |
|
914 |
int recur1 = string_index_at(index1); |
|
915 |
int recur2 = cp2->string_index_at(index2); |
|
916 |
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false); |
|
917 |
if (match) { |
|
918 |
return true; |
|
919 |
} |
|
920 |
} break; |
|
921 |
||
922 |
case JVM_CONSTANT_UnresolvedClass: |
|
923 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
924 |
Symbol* k1 = unresolved_klass_at(index1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
925 |
Symbol* k2 = cp2->unresolved_klass_at(index2); |
1 | 926 |
if (k1 == k2) { |
927 |
return true; |
|
928 |
} |
|
929 |
} break; |
|
930 |
||
5882 | 931 |
case JVM_CONSTANT_MethodType: |
932 |
{ |
|
933 |
int k1 = method_type_index_at(index1); |
|
934 |
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
|
935 |
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
|
936 |
if (match) { |
5882 | 937 |
return true; |
938 |
} |
|
939 |
} break; |
|
940 |
||
941 |
case JVM_CONSTANT_MethodHandle: |
|
942 |
{ |
|
943 |
int k1 = method_handle_ref_kind_at(index1); |
|
944 |
int k2 = cp2->method_handle_ref_kind_at(index2); |
|
945 |
if (k1 == k2) { |
|
946 |
int i1 = method_handle_index_at(index1); |
|
947 |
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
|
948 |
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
|
949 |
if (match) { |
5882 | 950 |
return true; |
951 |
} |
|
952 |
} |
|
953 |
} break; |
|
954 |
||
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
955 |
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
|
956 |
case JVM_CONSTANT_InvokeDynamicTrans: |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
957 |
{ |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
958 |
int k1 = invoke_dynamic_bootstrap_method_ref_index_at(index1); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
959 |
int k2 = cp2->invoke_dynamic_bootstrap_method_ref_index_at(index2); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
960 |
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
|
961 |
if (!match) return false; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
962 |
k1 = invoke_dynamic_name_and_type_ref_index_at(index1); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
963 |
k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
964 |
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
|
965 |
if (!match) return false; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
966 |
int argc = invoke_dynamic_argument_count_at(index1); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
967 |
if (argc == cp2->invoke_dynamic_argument_count_at(index2)) { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
968 |
for (int j = 0; j < argc; j++) { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
969 |
k1 = invoke_dynamic_argument_index_at(index1, j); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
970 |
k2 = cp2->invoke_dynamic_argument_index_at(index2, j); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
971 |
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
|
972 |
if (!match) return false; |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
973 |
} |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
974 |
return true; // got through loop; all elements equal |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
975 |
} |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
976 |
} break; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
977 |
|
1 | 978 |
case JVM_CONSTANT_UnresolvedString: |
979 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
980 |
Symbol* s1 = unresolved_string_at(index1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
981 |
Symbol* s2 = cp2->unresolved_string_at(index2); |
1 | 982 |
if (s1 == s2) { |
983 |
return true; |
|
984 |
} |
|
985 |
} break; |
|
986 |
||
987 |
case JVM_CONSTANT_Utf8: |
|
988 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
989 |
Symbol* s1 = symbol_at(index1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
990 |
Symbol* s2 = cp2->symbol_at(index2); |
1 | 991 |
if (s1 == s2) { |
992 |
return true; |
|
993 |
} |
|
994 |
} break; |
|
995 |
||
996 |
// Invalid is used as the tag for the second constant pool entry |
|
997 |
// occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should |
|
998 |
// not be seen by itself. |
|
999 |
case JVM_CONSTANT_Invalid: // fall through |
|
1000 |
||
1001 |
default: |
|
1002 |
ShouldNotReachHere(); |
|
1003 |
break; |
|
1004 |
} |
|
1005 |
||
1006 |
return false; |
|
1007 |
} // end compare_entry_to() |
|
1008 |
||
1009 |
||
1010 |
// Copy this constant pool's entries at start_i to end_i (inclusive) |
|
1011 |
// to the constant pool to_cp's entries starting at to_i. A total of |
|
1012 |
// (end_i - start_i) + 1 entries are copied. |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1013 |
void constantPoolOopDesc::copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i, |
1 | 1014 |
constantPoolHandle to_cp, int to_i, TRAPS) { |
1015 |
||
1016 |
int dest_i = to_i; // leave original alone for debug purposes |
|
1017 |
||
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1018 |
for (int src_i = start_i; src_i <= end_i; /* see loop bottom */ ) { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1019 |
copy_entry_to(from_cp, src_i, to_cp, dest_i, CHECK); |
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
1020 |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1021 |
switch (from_cp->tag_at(src_i).value()) { |
1 | 1022 |
case JVM_CONSTANT_Double: |
1023 |
case JVM_CONSTANT_Long: |
|
1024 |
// double and long take two constant pool entries |
|
1025 |
src_i += 2; |
|
1026 |
dest_i += 2; |
|
1027 |
break; |
|
1028 |
||
1029 |
default: |
|
1030 |
// all others take one constant pool entry |
|
1031 |
src_i++; |
|
1032 |
dest_i++; |
|
1033 |
break; |
|
1034 |
} |
|
1035 |
} |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1036 |
|
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1037 |
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
|
1038 |
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
|
1039 |
if (from_oplen != 0) { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1040 |
// 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
|
1041 |
if (old_oplen == 0) { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1042 |
to_cp->set_operands(from_cp->operands()); // reuse; do not merge |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1043 |
} else { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1044 |
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
|
1045 |
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
|
1046 |
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
|
1047 |
int from_off = from_oplen * sizeof(u2); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1048 |
typeArrayHandle new_operands = oopFactory::new_permanent_shortArray(old_len + from_len, CHECK); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1049 |
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
|
1050 |
// first part of dest |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1051 |
Copy::conjoint_memory_atomic(to_cp->operands()->short_at_addr(0), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1052 |
new_operands->short_at_addr(fillp), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1053 |
(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
|
1054 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1055 |
// first part of src |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1056 |
Copy::conjoint_memory_atomic(to_cp->operands()->short_at_addr(0), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1057 |
new_operands->short_at_addr(fillp), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1058 |
(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
|
1059 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1060 |
// second part of dest |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1061 |
Copy::conjoint_memory_atomic(to_cp->operands()->short_at_addr(old_off), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1062 |
new_operands->short_at_addr(fillp), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1063 |
(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
|
1064 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1065 |
// second part of src |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1066 |
Copy::conjoint_memory_atomic(to_cp->operands()->short_at_addr(from_off), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1067 |
new_operands->short_at_addr(fillp), |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1068 |
(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
|
1069 |
fillp += len; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1070 |
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
|
1071 |
|
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1072 |
// 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
|
1073 |
for (int j = 0; j < from_oplen; j++) { |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1074 |
int offset = operand_offset_at(new_operands(), old_oplen + j); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1075 |
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
|
1076 |
offset += old_len; // every new tuple is preceded by old_len extra u2's |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1077 |
operand_offset_at_put(new_operands(), old_oplen + j, offset); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1078 |
} |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1079 |
|
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1080 |
// replace target operands array with combined array |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1081 |
to_cp->set_operands(new_operands()); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1082 |
} |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1083 |
} |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1084 |
|
1 | 1085 |
} // end copy_cp_to() |
1086 |
||
1087 |
||
1088 |
// Copy this constant pool's entry at from_i to the constant pool |
|
1089 |
// to_cp's entry at to_i. |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1090 |
void constantPoolOopDesc::copy_entry_to(constantPoolHandle from_cp, int from_i, |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1091 |
constantPoolHandle to_cp, int to_i, |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1092 |
TRAPS) { |
1 | 1093 |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1094 |
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
|
1095 |
switch (tag) { |
1 | 1096 |
case JVM_CONSTANT_Class: |
1097 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1098 |
klassOop k = from_cp->klass_at(from_i, CHECK); |
1 | 1099 |
to_cp->klass_at_put(to_i, k); |
1100 |
} break; |
|
1101 |
||
1102 |
case JVM_CONSTANT_ClassIndex: |
|
1103 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1104 |
jint ki = from_cp->klass_index_at(from_i); |
1 | 1105 |
to_cp->klass_index_at_put(to_i, ki); |
1106 |
} break; |
|
1107 |
||
1108 |
case JVM_CONSTANT_Double: |
|
1109 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1110 |
jdouble d = from_cp->double_at(from_i); |
1 | 1111 |
to_cp->double_at_put(to_i, d); |
1112 |
// double takes two constant pool entries so init second entry's tag |
|
1113 |
to_cp->tag_at_put(to_i + 1, JVM_CONSTANT_Invalid); |
|
1114 |
} break; |
|
1115 |
||
1116 |
case JVM_CONSTANT_Fieldref: |
|
1117 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1118 |
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
|
1119 |
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i); |
1 | 1120 |
to_cp->field_at_put(to_i, class_index, name_and_type_index); |
1121 |
} break; |
|
1122 |
||
1123 |
case JVM_CONSTANT_Float: |
|
1124 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1125 |
jfloat f = from_cp->float_at(from_i); |
1 | 1126 |
to_cp->float_at_put(to_i, f); |
1127 |
} break; |
|
1128 |
||
1129 |
case JVM_CONSTANT_Integer: |
|
1130 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1131 |
jint i = from_cp->int_at(from_i); |
1 | 1132 |
to_cp->int_at_put(to_i, i); |
1133 |
} break; |
|
1134 |
||
1135 |
case JVM_CONSTANT_InterfaceMethodref: |
|
1136 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1137 |
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
|
1138 |
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i); |
1 | 1139 |
to_cp->interface_method_at_put(to_i, class_index, name_and_type_index); |
1140 |
} break; |
|
1141 |
||
1142 |
case JVM_CONSTANT_Long: |
|
1143 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1144 |
jlong l = from_cp->long_at(from_i); |
1 | 1145 |
to_cp->long_at_put(to_i, l); |
1146 |
// long takes two constant pool entries so init second entry's tag |
|
1147 |
to_cp->tag_at_put(to_i + 1, JVM_CONSTANT_Invalid); |
|
1148 |
} break; |
|
1149 |
||
1150 |
case JVM_CONSTANT_Methodref: |
|
1151 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1152 |
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
|
1153 |
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i); |
1 | 1154 |
to_cp->method_at_put(to_i, class_index, name_and_type_index); |
1155 |
} break; |
|
1156 |
||
1157 |
case JVM_CONSTANT_NameAndType: |
|
1158 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1159 |
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
|
1160 |
int signature_ref_index = from_cp->signature_ref_index_at(from_i); |
1 | 1161 |
to_cp->name_and_type_at_put(to_i, name_ref_index, signature_ref_index); |
1162 |
} break; |
|
1163 |
||
1164 |
case JVM_CONSTANT_String: |
|
1165 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1166 |
oop s = from_cp->string_at(from_i, CHECK); |
1 | 1167 |
to_cp->string_at_put(to_i, s); |
1168 |
} break; |
|
1169 |
||
1170 |
case JVM_CONSTANT_StringIndex: |
|
1171 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1172 |
jint si = from_cp->string_index_at(from_i); |
1 | 1173 |
to_cp->string_index_at_put(to_i, si); |
1174 |
} break; |
|
1175 |
||
1176 |
case JVM_CONSTANT_UnresolvedClass: |
|
1177 |
{ |
|
8651
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1178 |
// Can be resolved after checking tag, so check the slot first. |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1179 |
CPSlot entry = from_cp->slot_at(from_i); |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1180 |
if (entry.is_oop()) { |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1181 |
assert(entry.get_oop()->is_klass(), "must be"); |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1182 |
// Already resolved |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1183 |
to_cp->klass_at_put(to_i, (klassOop)entry.get_oop()); |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1184 |
} else { |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1185 |
to_cp->unresolved_klass_at_put(to_i, entry.get_symbol()); |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1186 |
} |
1 | 1187 |
} break; |
1188 |
||
1189 |
case JVM_CONSTANT_UnresolvedClassInError: |
|
1190 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1191 |
Symbol* k = from_cp->unresolved_klass_at(from_i); |
1 | 1192 |
to_cp->unresolved_klass_at_put(to_i, k); |
1193 |
to_cp->tag_at_put(to_i, JVM_CONSTANT_UnresolvedClassInError); |
|
1194 |
} break; |
|
1195 |
||
1196 |
||
1197 |
case JVM_CONSTANT_UnresolvedString: |
|
1198 |
{ |
|
8651
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1199 |
// Can be resolved after checking tag, so check the slot first. |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1200 |
CPSlot entry = from_cp->slot_at(from_i); |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1201 |
if (entry.is_oop()) { |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1202 |
// Already resolved (either string or pseudo-string) |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1203 |
to_cp->string_at_put(to_i, entry.get_oop()); |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1204 |
} else { |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1205 |
to_cp->unresolved_string_at_put(to_i, entry.get_symbol()); |
81b517a9249f
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
coleenp
parents:
8076
diff
changeset
|
1206 |
} |
1 | 1207 |
} break; |
1208 |
||
1209 |
case JVM_CONSTANT_Utf8: |
|
1210 |
{ |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1211 |
Symbol* s = from_cp->symbol_at(from_i); |
1 | 1212 |
to_cp->symbol_at_put(to_i, s); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1213 |
// This constantPool has the same lifetime as the original, so don't |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1214 |
// increase reference counts for the copy. |
1 | 1215 |
} break; |
1216 |
||
5882 | 1217 |
case JVM_CONSTANT_MethodType: |
1218 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1219 |
jint k = from_cp->method_type_index_at(from_i); |
5882 | 1220 |
to_cp->method_type_index_at_put(to_i, k); |
1221 |
} break; |
|
1222 |
||
1223 |
case JVM_CONSTANT_MethodHandle: |
|
1224 |
{ |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1225 |
int k1 = from_cp->method_handle_ref_kind_at(from_i); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1226 |
int k2 = from_cp->method_handle_index_at(from_i); |
5882 | 1227 |
to_cp->method_handle_index_at_put(to_i, k1, k2); |
1228 |
} break; |
|
1229 |
||
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1230 |
case JVM_CONSTANT_InvokeDynamicTrans: |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1231 |
{ |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1232 |
int k1 = from_cp->invoke_dynamic_bootstrap_method_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
|
1233 |
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
|
1234 |
to_cp->invoke_dynamic_trans_at_put(to_i, k1, k2); |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1235 |
} break; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1236 |
|
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1237 |
case JVM_CONSTANT_InvokeDynamic: |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1238 |
{ |
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1239 |
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
|
1240 |
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
|
1241 |
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
|
1242 |
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
|
1243 |
} break; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1244 |
|
1 | 1245 |
// Invalid is used as the tag for the second constant pool entry |
1246 |
// occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should |
|
1247 |
// not be seen by itself. |
|
1248 |
case JVM_CONSTANT_Invalid: // fall through |
|
1249 |
||
1250 |
default: |
|
1251 |
{ |
|
1252 |
ShouldNotReachHere(); |
|
1253 |
} break; |
|
1254 |
} |
|
1255 |
} // end copy_entry_to() |
|
1256 |
||
1257 |
||
1258 |
// Search constant pool search_cp for an entry that matches this |
|
1259 |
// constant pool's entry at pattern_i. Returns the index of a |
|
1260 |
// matching entry or zero (0) if there is no matching entry. |
|
1261 |
int constantPoolOopDesc::find_matching_entry(int pattern_i, |
|
1262 |
constantPoolHandle search_cp, TRAPS) { |
|
1263 |
||
1264 |
// index zero (0) is not used |
|
1265 |
for (int i = 1; i < search_cp->length(); i++) { |
|
1266 |
bool found = compare_entry_to(pattern_i, search_cp, i, CHECK_0); |
|
1267 |
if (found) { |
|
1268 |
return i; |
|
1269 |
} |
|
1270 |
} |
|
1271 |
||
1272 |
return 0; // entry not found; return unused index zero (0) |
|
1273 |
} // end find_matching_entry() |
|
1274 |
||
1275 |
||
1276 |
#ifndef PRODUCT |
|
1277 |
||
1278 |
const char* constantPoolOopDesc::printable_name_at(int which) { |
|
1279 |
||
1280 |
constantTag tag = tag_at(which); |
|
1281 |
||
1282 |
if (tag.is_unresolved_string() || tag.is_string()) { |
|
1283 |
return string_at_noresolve(which); |
|
1284 |
} else if (tag.is_klass() || tag.is_unresolved_klass()) { |
|
1285 |
return klass_name_at(which)->as_C_string(); |
|
1286 |
} else if (tag.is_symbol()) { |
|
1287 |
return symbol_at(which)->as_C_string(); |
|
1288 |
} |
|
1289 |
return ""; |
|
1290 |
} |
|
1291 |
||
1292 |
#endif // PRODUCT |
|
1293 |
||
1294 |
||
1295 |
// JVMTI GetConstantPool support |
|
1296 |
||
1297 |
// For temporary use until code is stable. |
|
1298 |
#define DBG(code) |
|
1299 |
||
1300 |
static const char* WARN_MSG = "Must not be such entry!"; |
|
1301 |
||
1302 |
static void print_cpool_bytes(jint cnt, u1 *bytes) { |
|
1303 |
jint size = 0; |
|
1304 |
u2 idx1, idx2; |
|
1305 |
||
1306 |
for (jint idx = 1; idx < cnt; idx++) { |
|
1307 |
jint ent_size = 0; |
|
1308 |
u1 tag = *bytes++; |
|
1309 |
size++; // count tag |
|
1310 |
||
1311 |
printf("const #%03d, tag: %02d ", idx, tag); |
|
1312 |
switch(tag) { |
|
1313 |
case JVM_CONSTANT_Invalid: { |
|
1314 |
printf("Invalid"); |
|
1315 |
break; |
|
1316 |
} |
|
1317 |
case JVM_CONSTANT_Unicode: { |
|
1318 |
printf("Unicode %s", WARN_MSG); |
|
1319 |
break; |
|
1320 |
} |
|
1321 |
case JVM_CONSTANT_Utf8: { |
|
1322 |
u2 len = Bytes::get_Java_u2(bytes); |
|
1323 |
char str[128]; |
|
1324 |
if (len > 127) { |
|
1325 |
len = 127; |
|
1326 |
} |
|
1327 |
strncpy(str, (char *) (bytes+2), len); |
|
1328 |
str[len] = '\0'; |
|
1329 |
printf("Utf8 \"%s\"", str); |
|
1330 |
ent_size = 2 + len; |
|
1331 |
break; |
|
1332 |
} |
|
1333 |
case JVM_CONSTANT_Integer: { |
|
1334 |
u4 val = Bytes::get_Java_u4(bytes); |
|
1335 |
printf("int %d", *(int *) &val); |
|
1336 |
ent_size = 4; |
|
1337 |
break; |
|
1338 |
} |
|
1339 |
case JVM_CONSTANT_Float: { |
|
1340 |
u4 val = Bytes::get_Java_u4(bytes); |
|
1341 |
printf("float %5.3ff", *(float *) &val); |
|
1342 |
ent_size = 4; |
|
1343 |
break; |
|
1344 |
} |
|
1345 |
case JVM_CONSTANT_Long: { |
|
1346 |
u8 val = Bytes::get_Java_u8(bytes); |
|
1889
24b003a6fe46
6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
xlu
parents:
1550
diff
changeset
|
1347 |
printf("long "INT64_FORMAT, *(jlong *) &val); |
1 | 1348 |
ent_size = 8; |
1349 |
idx++; // Long takes two cpool slots |
|
1350 |
break; |
|
1351 |
} |
|
1352 |
case JVM_CONSTANT_Double: { |
|
1353 |
u8 val = Bytes::get_Java_u8(bytes); |
|
1354 |
printf("double %5.3fd", *(jdouble *)&val); |
|
1355 |
ent_size = 8; |
|
1356 |
idx++; // Double takes two cpool slots |
|
1357 |
break; |
|
1358 |
} |
|
1359 |
case JVM_CONSTANT_Class: { |
|
1360 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1361 |
printf("class #%03d", idx1); |
|
1362 |
ent_size = 2; |
|
1363 |
break; |
|
1364 |
} |
|
1365 |
case JVM_CONSTANT_String: { |
|
1366 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1367 |
printf("String #%03d", idx1); |
|
1368 |
ent_size = 2; |
|
1369 |
break; |
|
1370 |
} |
|
1371 |
case JVM_CONSTANT_Fieldref: { |
|
1372 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1373 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1374 |
printf("Field #%03d, #%03d", (int) idx1, (int) idx2); |
|
1375 |
ent_size = 4; |
|
1376 |
break; |
|
1377 |
} |
|
1378 |
case JVM_CONSTANT_Methodref: { |
|
1379 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1380 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1381 |
printf("Method #%03d, #%03d", idx1, idx2); |
|
1382 |
ent_size = 4; |
|
1383 |
break; |
|
1384 |
} |
|
1385 |
case JVM_CONSTANT_InterfaceMethodref: { |
|
1386 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1387 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1388 |
printf("InterfMethod #%03d, #%03d", idx1, idx2); |
|
1389 |
ent_size = 4; |
|
1390 |
break; |
|
1391 |
} |
|
1392 |
case JVM_CONSTANT_NameAndType: { |
|
1393 |
idx1 = Bytes::get_Java_u2(bytes); |
|
1394 |
idx2 = Bytes::get_Java_u2(bytes+2); |
|
1395 |
printf("NameAndType #%03d, #%03d", idx1, idx2); |
|
1396 |
ent_size = 4; |
|
1397 |
break; |
|
1398 |
} |
|
1399 |
case JVM_CONSTANT_ClassIndex: { |
|
1400 |
printf("ClassIndex %s", WARN_MSG); |
|
1401 |
break; |
|
1402 |
} |
|
1403 |
case JVM_CONSTANT_UnresolvedClass: { |
|
1404 |
printf("UnresolvedClass: %s", WARN_MSG); |
|
1405 |
break; |
|
1406 |
} |
|
1407 |
case JVM_CONSTANT_UnresolvedClassInError: { |
|
1408 |
printf("UnresolvedClassInErr: %s", WARN_MSG); |
|
1409 |
break; |
|
1410 |
} |
|
1411 |
case JVM_CONSTANT_StringIndex: { |
|
1412 |
printf("StringIndex: %s", WARN_MSG); |
|
1413 |
break; |
|
1414 |
} |
|
1415 |
case JVM_CONSTANT_UnresolvedString: { |
|
1416 |
printf("UnresolvedString: %s", WARN_MSG); |
|
1417 |
break; |
|
1418 |
} |
|
1419 |
} |
|
1420 |
printf(";\n"); |
|
1421 |
bytes += ent_size; |
|
1422 |
size += ent_size; |
|
1423 |
} |
|
1424 |
printf("Cpool size: %d\n", size); |
|
1425 |
fflush(0); |
|
1426 |
return; |
|
1427 |
} /* end print_cpool_bytes */ |
|
1428 |
||
1429 |
||
1430 |
// Returns size of constant pool entry. |
|
1431 |
jint constantPoolOopDesc::cpool_entry_size(jint idx) { |
|
1432 |
switch(tag_at(idx).value()) { |
|
1433 |
case JVM_CONSTANT_Invalid: |
|
1434 |
case JVM_CONSTANT_Unicode: |
|
1435 |
return 1; |
|
1436 |
||
1437 |
case JVM_CONSTANT_Utf8: |
|
1438 |
return 3 + symbol_at(idx)->utf8_length(); |
|
1439 |
||
1440 |
case JVM_CONSTANT_Class: |
|
1441 |
case JVM_CONSTANT_String: |
|
1442 |
case JVM_CONSTANT_ClassIndex: |
|
1443 |
case JVM_CONSTANT_UnresolvedClass: |
|
1444 |
case JVM_CONSTANT_UnresolvedClassInError: |
|
1445 |
case JVM_CONSTANT_StringIndex: |
|
1446 |
case JVM_CONSTANT_UnresolvedString: |
|
5882 | 1447 |
case JVM_CONSTANT_MethodType: |
1 | 1448 |
return 3; |
1449 |
||
5882 | 1450 |
case JVM_CONSTANT_MethodHandle: |
1451 |
return 4; //tag, ref_kind, ref_index |
|
1452 |
||
1 | 1453 |
case JVM_CONSTANT_Integer: |
1454 |
case JVM_CONSTANT_Float: |
|
1455 |
case JVM_CONSTANT_Fieldref: |
|
1456 |
case JVM_CONSTANT_Methodref: |
|
1457 |
case JVM_CONSTANT_InterfaceMethodref: |
|
1458 |
case JVM_CONSTANT_NameAndType: |
|
7114
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
1459 |
return 5; |
65d21c4c6337
6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents:
7111
diff
changeset
|
1460 |
|
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1461 |
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
|
1462 |
case JVM_CONSTANT_InvokeDynamicTrans: |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1463 |
// 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
|
1464 |
return 5; |
1 | 1465 |
|
1466 |
case JVM_CONSTANT_Long: |
|
1467 |
case JVM_CONSTANT_Double: |
|
1468 |
return 9; |
|
1469 |
} |
|
1470 |
assert(false, "cpool_entry_size: Invalid constant pool entry tag"); |
|
1471 |
return 1; |
|
1472 |
} /* end cpool_entry_size */ |
|
1473 |
||
1474 |
||
1475 |
// SymbolHashMap is used to find a constant pool index from a string. |
|
1476 |
// This function fills in SymbolHashMaps, one for utf8s and one for |
|
1477 |
// class names, returns size of the cpool raw bytes. |
|
1478 |
jint constantPoolOopDesc::hash_entries_to(SymbolHashMap *symmap, |
|
1479 |
SymbolHashMap *classmap) { |
|
1480 |
jint size = 0; |
|
1481 |
||
1482 |
for (u2 idx = 1; idx < length(); idx++) { |
|
1483 |
u2 tag = tag_at(idx).value(); |
|
1484 |
size += cpool_entry_size(idx); |
|
1485 |
||
1486 |
switch(tag) { |
|
1487 |
case JVM_CONSTANT_Utf8: { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1488 |
Symbol* sym = symbol_at(idx); |
1 | 1489 |
symmap->add_entry(sym, idx); |
1490 |
DBG(printf("adding symbol entry %s = %d\n", sym->as_utf8(), idx)); |
|
1491 |
break; |
|
1492 |
} |
|
1493 |
case JVM_CONSTANT_Class: |
|
1494 |
case JVM_CONSTANT_UnresolvedClass: |
|
1495 |
case JVM_CONSTANT_UnresolvedClassInError: { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1496 |
Symbol* sym = klass_name_at(idx); |
1 | 1497 |
classmap->add_entry(sym, idx); |
1498 |
DBG(printf("adding class entry %s = %d\n", sym->as_utf8(), idx)); |
|
1499 |
break; |
|
1500 |
} |
|
1501 |
case JVM_CONSTANT_Long: |
|
1502 |
case JVM_CONSTANT_Double: { |
|
1503 |
idx++; // Both Long and Double take two cpool slots |
|
1504 |
break; |
|
1505 |
} |
|
1506 |
} |
|
1507 |
} |
|
1508 |
return size; |
|
1509 |
} /* end hash_utf8_entries_to */ |
|
1510 |
||
1511 |
||
1512 |
// Copy cpool bytes. |
|
1513 |
// Returns: |
|
1514 |
// 0, in case of OutOfMemoryError |
|
1515 |
// -1, in case of internal error |
|
1516 |
// > 0, count of the raw cpool bytes that have been copied |
|
1517 |
int constantPoolOopDesc::copy_cpool_bytes(int cpool_size, |
|
1518 |
SymbolHashMap* tbl, |
|
1519 |
unsigned char *bytes) { |
|
1520 |
u2 idx1, idx2; |
|
1521 |
jint size = 0; |
|
1522 |
jint cnt = length(); |
|
1523 |
unsigned char *start_bytes = bytes; |
|
1524 |
||
1525 |
for (jint idx = 1; idx < cnt; idx++) { |
|
1526 |
u1 tag = tag_at(idx).value(); |
|
1527 |
jint ent_size = cpool_entry_size(idx); |
|
1528 |
||
1529 |
assert(size + ent_size <= cpool_size, "Size mismatch"); |
|
1530 |
||
1531 |
*bytes = tag; |
|
1532 |
DBG(printf("#%03hd tag=%03hd, ", idx, tag)); |
|
1533 |
switch(tag) { |
|
1534 |
case JVM_CONSTANT_Invalid: { |
|
1535 |
DBG(printf("JVM_CONSTANT_Invalid")); |
|
1536 |
break; |
|
1537 |
} |
|
1538 |
case JVM_CONSTANT_Unicode: { |
|
1539 |
assert(false, "Wrong constant pool tag: JVM_CONSTANT_Unicode"); |
|
1540 |
DBG(printf("JVM_CONSTANT_Unicode")); |
|
1541 |
break; |
|
1542 |
} |
|
1543 |
case JVM_CONSTANT_Utf8: { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1544 |
Symbol* sym = symbol_at(idx); |
1 | 1545 |
char* str = sym->as_utf8(); |
1546 |
// Warning! It's crashing on x86 with len = sym->utf8_length() |
|
1547 |
int len = (int) strlen(str); |
|
1548 |
Bytes::put_Java_u2((address) (bytes+1), (u2) len); |
|
1549 |
for (int i = 0; i < len; i++) { |
|
1550 |
bytes[3+i] = (u1) str[i]; |
|
1551 |
} |
|
1552 |
DBG(printf("JVM_CONSTANT_Utf8: %s ", str)); |
|
1553 |
break; |
|
1554 |
} |
|
1555 |
case JVM_CONSTANT_Integer: { |
|
1556 |
jint val = int_at(idx); |
|
1557 |
Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val); |
|
1558 |
break; |
|
1559 |
} |
|
1560 |
case JVM_CONSTANT_Float: { |
|
1561 |
jfloat val = float_at(idx); |
|
1562 |
Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val); |
|
1563 |
break; |
|
1564 |
} |
|
1565 |
case JVM_CONSTANT_Long: { |
|
1566 |
jlong val = long_at(idx); |
|
1567 |
Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val); |
|
1568 |
idx++; // Long takes two cpool slots |
|
1569 |
break; |
|
1570 |
} |
|
1571 |
case JVM_CONSTANT_Double: { |
|
1572 |
jdouble val = double_at(idx); |
|
1573 |
Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val); |
|
1574 |
idx++; // Double takes two cpool slots |
|
1575 |
break; |
|
1576 |
} |
|
1577 |
case JVM_CONSTANT_Class: |
|
1578 |
case JVM_CONSTANT_UnresolvedClass: |
|
1579 |
case JVM_CONSTANT_UnresolvedClassInError: { |
|
1580 |
*bytes = JVM_CONSTANT_Class; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1581 |
Symbol* sym = klass_name_at(idx); |
1 | 1582 |
idx1 = tbl->symbol_to_value(sym); |
1583 |
assert(idx1 != 0, "Have not found a hashtable entry"); |
|
1584 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1585 |
DBG(printf("JVM_CONSTANT_Class: idx=#%03hd, %s", idx1, sym->as_utf8())); |
|
1586 |
break; |
|
1587 |
} |
|
1588 |
case JVM_CONSTANT_String: { |
|
1589 |
unsigned int hash; |
|
1590 |
char *str = string_at_noresolve(idx); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1591 |
TempNewSymbol sym = SymbolTable::lookup_only(str, (int) strlen(str), hash); |
2860
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1592 |
if (sym == NULL) { |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1593 |
// sym can be NULL if string refers to incorrectly encoded JVM_CONSTANT_Utf8 |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1594 |
// this can happen with JVM TI; see CR 6839599 for more details |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1595 |
oop string = *(obj_at_addr_raw(idx)); |
2860
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1596 |
assert(java_lang_String::is_instance(string),"Not a String"); |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1597 |
DBG(printf("Error #%03hd tag=%03hd\n", idx, tag)); |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1598 |
idx1 = 0; |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1599 |
for (int j = 0; j < tbl->table_size() && idx1 == 0; j++) { |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1600 |
for (SymbolHashMapEntry* cur = tbl->bucket(j); cur != NULL; cur = cur->next()) { |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1601 |
int length; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1602 |
Symbol* s = cur->symbol(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1603 |
jchar* chars = s->as_unicode(length); |
2860
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1604 |
if (java_lang_String::equals(string, chars, length)) { |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1605 |
idx1 = cur->value(); |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1606 |
DBG(printf("Index found: %d\n",idx1)); |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1607 |
break; |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1608 |
} |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1609 |
} |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1610 |
} |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1611 |
} else { |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1612 |
idx1 = tbl->symbol_to_value(sym); |
cf13b84eb2f9
6839599: JVM crash while profiling Tomcat and Liferay
thurka
parents:
2570
diff
changeset
|
1613 |
} |
1 | 1614 |
assert(idx1 != 0, "Have not found a hashtable entry"); |
1615 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1616 |
DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, str)); |
|
1617 |
break; |
|
1618 |
} |
|
1619 |
case JVM_CONSTANT_UnresolvedString: { |
|
1620 |
*bytes = JVM_CONSTANT_String; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1621 |
Symbol* sym = unresolved_string_at(idx); |
1 | 1622 |
idx1 = tbl->symbol_to_value(sym); |
1623 |
assert(idx1 != 0, "Have not found a hashtable entry"); |
|
1624 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1625 |
DBG(char *str = sym->as_utf8()); |
|
1626 |
DBG(printf("JVM_CONSTANT_UnresolvedString: idx=#%03hd, %s", idx1, str)); |
|
1627 |
break; |
|
1628 |
} |
|
1629 |
case JVM_CONSTANT_Fieldref: |
|
1630 |
case JVM_CONSTANT_Methodref: |
|
1631 |
case JVM_CONSTANT_InterfaceMethodref: { |
|
1632 |
idx1 = uncached_klass_ref_index_at(idx); |
|
1633 |
idx2 = uncached_name_and_type_ref_index_at(idx); |
|
1634 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1635 |
Bytes::put_Java_u2((address) (bytes+3), idx2); |
|
1636 |
DBG(printf("JVM_CONSTANT_Methodref: %hd %hd", idx1, idx2)); |
|
1637 |
break; |
|
1638 |
} |
|
1639 |
case JVM_CONSTANT_NameAndType: { |
|
1640 |
idx1 = name_ref_index_at(idx); |
|
1641 |
idx2 = signature_ref_index_at(idx); |
|
1642 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1643 |
Bytes::put_Java_u2((address) (bytes+3), idx2); |
|
1644 |
DBG(printf("JVM_CONSTANT_NameAndType: %hd %hd", idx1, idx2)); |
|
1645 |
break; |
|
1646 |
} |
|
1647 |
case JVM_CONSTANT_ClassIndex: { |
|
1648 |
*bytes = JVM_CONSTANT_Class; |
|
1649 |
idx1 = klass_index_at(idx); |
|
1650 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1651 |
DBG(printf("JVM_CONSTANT_ClassIndex: %hd", idx1)); |
|
1652 |
break; |
|
1653 |
} |
|
1654 |
case JVM_CONSTANT_StringIndex: { |
|
1655 |
*bytes = JVM_CONSTANT_String; |
|
1656 |
idx1 = string_index_at(idx); |
|
1657 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1658 |
DBG(printf("JVM_CONSTANT_StringIndex: %hd", idx1)); |
|
1659 |
break; |
|
1660 |
} |
|
5882 | 1661 |
case JVM_CONSTANT_MethodHandle: { |
1662 |
*bytes = JVM_CONSTANT_MethodHandle; |
|
1663 |
int kind = method_handle_ref_kind_at(idx); |
|
1664 |
idx1 = method_handle_index_at(idx); |
|
1665 |
*(bytes+1) = (unsigned char) kind; |
|
1666 |
Bytes::put_Java_u2((address) (bytes+2), idx1); |
|
1667 |
DBG(printf("JVM_CONSTANT_MethodHandle: %d %hd", kind, idx1)); |
|
1668 |
break; |
|
1669 |
} |
|
1670 |
case JVM_CONSTANT_MethodType: { |
|
1671 |
*bytes = JVM_CONSTANT_MethodType; |
|
1672 |
idx1 = method_type_index_at(idx); |
|
1673 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
|
1674 |
DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1)); |
|
1675 |
break; |
|
1676 |
} |
|
7436
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1677 |
case JVM_CONSTANT_InvokeDynamicTrans: |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1678 |
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
|
1679 |
*bytes = tag; |
dbc43da3d512
7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute
jrose
parents:
7397
diff
changeset
|
1680 |
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
|
1681 |
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
|
1682 |
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
|
1683 |
Bytes::put_Java_u2((address) (bytes+1), idx1); |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1684 |
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
|
1685 |
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
|
1686 |
break; |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
1687 |
} |
1 | 1688 |
} |
1689 |
DBG(printf("\n")); |
|
1690 |
bytes += ent_size; |
|
1691 |
size += ent_size; |
|
1692 |
} |
|
1693 |
assert(size == cpool_size, "Size mismatch"); |
|
1694 |
||
1695 |
// Keep temorarily for debugging until it's stable. |
|
1696 |
DBG(print_cpool_bytes(cnt, start_bytes)); |
|
1697 |
return (int)(bytes - start_bytes); |
|
1698 |
} /* end copy_cpool_bytes */ |
|
1699 |
||
1700 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1701 |
void SymbolHashMap::add_entry(Symbol* sym, u2 value) { |
1 | 1702 |
char *str = sym->as_utf8(); |
1703 |
unsigned int hash = compute_hash(str, sym->utf8_length()); |
|
1704 |
unsigned int index = hash % table_size(); |
|
1705 |
||
1706 |
// check if already in map |
|
1707 |
// we prefer the first entry since it is more likely to be what was used in |
|
1708 |
// the class file |
|
1709 |
for (SymbolHashMapEntry *en = bucket(index); en != NULL; en = en->next()) { |
|
1710 |
assert(en->symbol() != NULL, "SymbolHashMapEntry symbol is NULL"); |
|
1711 |
if (en->hash() == hash && en->symbol() == sym) { |
|
1712 |
return; // already there |
|
1713 |
} |
|
1714 |
} |
|
1715 |
||
1716 |
SymbolHashMapEntry* entry = new SymbolHashMapEntry(hash, sym, value); |
|
1717 |
entry->set_next(bucket(index)); |
|
1718 |
_buckets[index].set_entry(entry); |
|
1719 |
assert(entry->symbol() != NULL, "SymbolHashMapEntry symbol is NULL"); |
|
1720 |
} |
|
1721 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7436
diff
changeset
|
1722 |
SymbolHashMapEntry* SymbolHashMap::find_entry(Symbol* sym) { |
1 | 1723 |
assert(sym != NULL, "SymbolHashMap::find_entry - symbol is NULL"); |
1724 |
char *str = sym->as_utf8(); |
|
1725 |
int len = sym->utf8_length(); |
|
1726 |
unsigned int hash = SymbolHashMap::compute_hash(str, len); |
|
1727 |
unsigned int index = hash % table_size(); |
|
1728 |
for (SymbolHashMapEntry *en = bucket(index); en != NULL; en = en->next()) { |
|
1729 |
assert(en->symbol() != NULL, "SymbolHashMapEntry symbol is NULL"); |
|
1730 |
if (en->hash() == hash && en->symbol() == sym) { |
|
1731 |
return en; |
|
1732 |
} |
|
1733 |
} |
|
1734 |
return NULL; |
|
1735 |
} |