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