annotate src/share/vm/oops/constantPoolOop.cpp @ 1972:f95d63e2154a

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