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