annotate src/share/vm/oops/constantPoolOop.cpp @ 4155:394404b2d9bd

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