src/share/vm/oops/constantPoolOop.hpp

Tue, 08 Feb 2011 12:33:19 +0100

author
stefank
date
Tue, 08 Feb 2011 12:33:19 +0100
changeset 2534
e5383553fd4e
parent 2497
3582bf76420e
child 2508
b92c45f2bc75
permissions
-rw-r--r--

7014851: Remove unused parallel compaction code
Summary: Removed.
Reviewed-by: jcoomes, brutisso

duke@435 1 /*
jrose@1934 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP
stefank@2314 26 #define SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP
stefank@2314 27
stefank@2314 28 #include "oops/arrayOop.hpp"
stefank@2314 29 #include "oops/cpCacheOop.hpp"
coleenp@2497 30 #include "oops/symbol.hpp"
stefank@2314 31 #include "oops/typeArrayOop.hpp"
stefank@2314 32 #include "utilities/constantTag.hpp"
stefank@2314 33 #ifdef TARGET_ARCH_x86
stefank@2314 34 # include "bytes_x86.hpp"
stefank@2314 35 #endif
stefank@2314 36 #ifdef TARGET_ARCH_sparc
stefank@2314 37 # include "bytes_sparc.hpp"
stefank@2314 38 #endif
stefank@2314 39 #ifdef TARGET_ARCH_zero
stefank@2314 40 # include "bytes_zero.hpp"
stefank@2314 41 #endif
stefank@2314 42
duke@435 43 // A constantPool is an array containing class constants as described in the
duke@435 44 // class file.
duke@435 45 //
duke@435 46 // Most of the constant pool entries are written during class parsing, which
duke@435 47 // is safe. For klass and string types, the constant pool entry is
duke@435 48 // modified when the entry is resolved. If a klass or string constant pool
duke@435 49 // entry is read without a lock, only the resolved state guarantees that
duke@435 50 // the entry in the constant pool is a klass or String object and
coleenp@2497 51 // not a Symbol*.
duke@435 52
duke@435 53 class SymbolHashMap;
duke@435 54
coleenp@2497 55 class CPSlot VALUE_OBJ_CLASS_SPEC {
coleenp@2497 56 intptr_t _ptr;
coleenp@2497 57 public:
coleenp@2497 58 CPSlot(intptr_t ptr): _ptr(ptr) {}
coleenp@2497 59 CPSlot(void* ptr): _ptr((intptr_t)ptr) {}
coleenp@2497 60 CPSlot(oop ptr): _ptr((intptr_t)ptr) {}
coleenp@2497 61 CPSlot(Symbol* ptr): _ptr((intptr_t)ptr | 1) {}
coleenp@2497 62
coleenp@2497 63 intptr_t value() { return _ptr; }
coleenp@2497 64 bool is_oop() { return (_ptr & 1) == 0; }
coleenp@2497 65 bool is_metadata() { return (_ptr & 1) == 1; }
coleenp@2497 66
coleenp@2497 67 oop get_oop() {
coleenp@2497 68 assert(is_oop(), "bad call");
coleenp@2497 69 return oop(_ptr);
coleenp@2497 70 }
coleenp@2497 71 Symbol* get_symbol() {
coleenp@2497 72 assert(is_metadata(), "bad call");
coleenp@2497 73 return (Symbol*)(_ptr & ~1);
coleenp@2497 74 }
coleenp@2497 75 };
coleenp@2497 76
coleenp@548 77 class constantPoolOopDesc : public oopDesc {
duke@435 78 friend class VMStructs;
duke@435 79 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast
duke@435 80 private:
duke@435 81 typeArrayOop _tags; // the tag array describing the constant pool's contents
duke@435 82 constantPoolCacheOop _cache; // the cache holding interpreter runtime information
duke@435 83 klassOop _pool_holder; // the corresponding class
jrose@2268 84 typeArrayOop _operands; // for variable-sized (InvokeDynamic) nodes, usually empty
jrose@866 85 int _flags; // a few header bits to describe contents for GC
coleenp@548 86 int _length; // number of elements in the array
jmasa@953 87 volatile bool _is_conc_safe; // if true, safe for concurrent
jmasa@953 88 // GC processing
duke@435 89 // only set to non-zero if constant pool is merged by RedefineClasses
duke@435 90 int _orig_length;
duke@435 91
duke@435 92 void set_tags(typeArrayOop tags) { oop_store_without_check((oop*)&_tags, tags); }
duke@435 93 void tag_at_put(int which, jbyte t) { tags()->byte_at_put(which, t); }
duke@435 94 void release_tag_at_put(int which, jbyte t) { tags()->release_byte_at_put(which, t); }
duke@435 95
jrose@2268 96 void set_operands(typeArrayOop operands) { oop_store_without_check((oop*)&_operands, operands); }
jrose@2268 97
jrose@866 98 enum FlagBit {
jrose@1161 99 FB_has_invokedynamic = 1,
jrose@866 100 FB_has_pseudo_string = 2
jrose@866 101 };
jrose@866 102
jrose@866 103 int flags() const { return _flags; }
jrose@866 104 void set_flags(int f) { _flags = f; }
jrose@866 105 bool flag_at(FlagBit fb) const { return (_flags & (1 << (int)fb)) != 0; }
jrose@866 106 void set_flag_at(FlagBit fb);
jrose@866 107 // no clear_flag_at function; they only increase
jrose@866 108
duke@435 109 private:
duke@435 110 intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(constantPoolOopDesc)); }
duke@435 111 oop* tags_addr() { return (oop*)&_tags; }
duke@435 112 oop* cache_addr() { return (oop*)&_cache; }
jrose@2268 113 oop* operands_addr() { return (oop*)&_operands; }
duke@435 114
coleenp@2497 115 CPSlot slot_at(int which) {
coleenp@2497 116 assert(is_within_bounds(which), "index out of bounds");
coleenp@2497 117 // There's a transitional value of zero when converting from
coleenp@2497 118 // Symbol->0->Klass for G1 when resolving classes and strings.
coleenp@2497 119 // wait for the value to be non-zero (this is temporary)
coleenp@2497 120 volatile intptr_t adr = (intptr_t)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which));
coleenp@2497 121 if (adr == 0 && which != 0) {
coleenp@2497 122 constantTag t = tag_at(which);
coleenp@2497 123 if (t.is_unresolved_klass() || t.is_klass() ||
coleenp@2497 124 t.is_unresolved_string() || t.is_string()) {
coleenp@2497 125 while ((adr = (intptr_t)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))) == 0);
coleenp@2497 126 }
coleenp@2497 127 }
coleenp@2497 128 return CPSlot(adr);
coleenp@2497 129 }
coleenp@2497 130
coleenp@2497 131 void slot_at_put(int which, CPSlot s) const {
coleenp@2497 132 assert(is_within_bounds(which), "index out of bounds");
coleenp@2497 133 *(intptr_t*)&base()[which] = s.value();
coleenp@2497 134 }
coleenp@2497 135 oop* obj_at_addr_raw(int which) const {
duke@435 136 assert(is_within_bounds(which), "index out of bounds");
duke@435 137 return (oop*) &base()[which];
duke@435 138 }
duke@435 139
coleenp@2497 140 void obj_at_put_without_check(int which, oop o) {
coleenp@2497 141 assert(is_within_bounds(which), "index out of bounds");
coleenp@2497 142 oop_store_without_check((volatile oop *)obj_at_addr_raw(which), o);
coleenp@2497 143 }
coleenp@2497 144
coleenp@2497 145 void obj_at_put(int which, oop o) const {
coleenp@2497 146 assert(is_within_bounds(which), "index out of bounds");
coleenp@2497 147 oop_store((volatile oop*)obj_at_addr_raw(which), o);
coleenp@2497 148 }
coleenp@2497 149
duke@435 150 jint* int_at_addr(int which) const {
duke@435 151 assert(is_within_bounds(which), "index out of bounds");
duke@435 152 return (jint*) &base()[which];
duke@435 153 }
duke@435 154
duke@435 155 jlong* long_at_addr(int which) const {
duke@435 156 assert(is_within_bounds(which), "index out of bounds");
duke@435 157 return (jlong*) &base()[which];
duke@435 158 }
duke@435 159
duke@435 160 jfloat* float_at_addr(int which) const {
duke@435 161 assert(is_within_bounds(which), "index out of bounds");
duke@435 162 return (jfloat*) &base()[which];
duke@435 163 }
duke@435 164
duke@435 165 jdouble* double_at_addr(int which) const {
duke@435 166 assert(is_within_bounds(which), "index out of bounds");
duke@435 167 return (jdouble*) &base()[which];
duke@435 168 }
duke@435 169
duke@435 170 public:
duke@435 171 typeArrayOop tags() const { return _tags; }
jrose@2268 172 typeArrayOop operands() const { return _operands; }
duke@435 173
jrose@866 174 bool has_pseudo_string() const { return flag_at(FB_has_pseudo_string); }
jrose@1161 175 bool has_invokedynamic() const { return flag_at(FB_has_invokedynamic); }
jrose@866 176 void set_pseudo_string() { set_flag_at(FB_has_pseudo_string); }
jrose@1161 177 void set_invokedynamic() { set_flag_at(FB_has_invokedynamic); }
jrose@866 178
duke@435 179 // Klass holding pool
duke@435 180 klassOop pool_holder() const { return _pool_holder; }
duke@435 181 void set_pool_holder(klassOop k) { oop_store_without_check((oop*)&_pool_holder, (oop) k); }
duke@435 182 oop* pool_holder_addr() { return (oop*)&_pool_holder; }
duke@435 183
duke@435 184 // Interpreter runtime support
duke@435 185 constantPoolCacheOop cache() const { return _cache; }
duke@435 186 void set_cache(constantPoolCacheOop cache){ oop_store((oop*)&_cache, cache); }
duke@435 187
duke@435 188 // Assembly code support
duke@435 189 static int tags_offset_in_bytes() { return offset_of(constantPoolOopDesc, _tags); }
duke@435 190 static int cache_offset_in_bytes() { return offset_of(constantPoolOopDesc, _cache); }
jrose@2268 191 static int operands_offset_in_bytes() { return offset_of(constantPoolOopDesc, _operands); }
duke@435 192 static int pool_holder_offset_in_bytes() { return offset_of(constantPoolOopDesc, _pool_holder); }
duke@435 193
duke@435 194 // Storing constants
duke@435 195
duke@435 196 void klass_at_put(int which, klassOop k) {
coleenp@2497 197 // Overwrite the old index with a GC friendly value so
coleenp@2497 198 // that if G1 looks during the transition during oop_store it won't
coleenp@2497 199 // assert the symbol is not an oop.
coleenp@2497 200 *obj_at_addr_raw(which) = NULL;
coleenp@2497 201 assert(k != NULL, "resolved class shouldn't be null");
coleenp@2497 202 obj_at_put_without_check(which, k);
duke@435 203 // The interpreter assumes when the tag is stored, the klass is resolved
coleenp@2497 204 // and the klassOop is a klass rather than a Symbol*, so we need
duke@435 205 // hardware store ordering here.
duke@435 206 release_tag_at_put(which, JVM_CONSTANT_Class);
duke@435 207 if (UseConcMarkSweepGC) {
duke@435 208 // In case the earlier card-mark was consumed by a concurrent
duke@435 209 // marking thread before the tag was updated, redirty the card.
coleenp@2497 210 obj_at_put_without_check(which, k);
duke@435 211 }
duke@435 212 }
duke@435 213
duke@435 214 // For temporary use while constructing constant pool
duke@435 215 void klass_index_at_put(int which, int name_index) {
duke@435 216 tag_at_put(which, JVM_CONSTANT_ClassIndex);
duke@435 217 *int_at_addr(which) = name_index;
duke@435 218 }
duke@435 219
duke@435 220 // Temporary until actual use
coleenp@2497 221 void unresolved_klass_at_put(int which, Symbol* s) {
duke@435 222 release_tag_at_put(which, JVM_CONSTANT_UnresolvedClass);
coleenp@2497 223 slot_at_put(which, s);
duke@435 224 }
duke@435 225
jrose@1957 226 void method_handle_index_at_put(int which, int ref_kind, int ref_index) {
jrose@1957 227 tag_at_put(which, JVM_CONSTANT_MethodHandle);
jrose@1957 228 *int_at_addr(which) = ((jint) ref_index<<16) | ref_kind;
jrose@1957 229 }
jrose@1957 230
jrose@1957 231 void method_type_index_at_put(int which, int ref_index) {
jrose@1957 232 tag_at_put(which, JVM_CONSTANT_MethodType);
jrose@1957 233 *int_at_addr(which) = ref_index;
jrose@1957 234 }
jrose@1957 235
jrose@2353 236 void invoke_dynamic_at_put(int which, int bootstrap_specifier_index, int name_and_type_index) {
jrose@2015 237 tag_at_put(which, JVM_CONSTANT_InvokeDynamic);
jrose@2353 238 *int_at_addr(which) = ((jint) name_and_type_index<<16) | bootstrap_specifier_index;
jrose@2015 239 }
jrose@2353 240
jrose@2353 241 void invoke_dynamic_trans_at_put(int which, int bootstrap_method_index, int name_and_type_index) {
jrose@2353 242 tag_at_put(which, JVM_CONSTANT_InvokeDynamicTrans);
jrose@2353 243 *int_at_addr(which) = ((jint) name_and_type_index<<16) | bootstrap_method_index;
jrose@2353 244 assert(AllowTransitionalJSR292, "");
jrose@2268 245 }
jrose@2015 246
duke@435 247 // Temporary until actual use
coleenp@2497 248 void unresolved_string_at_put(int which, Symbol* s) {
duke@435 249 release_tag_at_put(which, JVM_CONSTANT_UnresolvedString);
coleenp@2497 250 slot_at_put(which, s);
duke@435 251 }
duke@435 252
duke@435 253 void int_at_put(int which, jint i) {
duke@435 254 tag_at_put(which, JVM_CONSTANT_Integer);
duke@435 255 *int_at_addr(which) = i;
duke@435 256 }
duke@435 257
duke@435 258 void long_at_put(int which, jlong l) {
duke@435 259 tag_at_put(which, JVM_CONSTANT_Long);
duke@435 260 // *long_at_addr(which) = l;
duke@435 261 Bytes::put_native_u8((address)long_at_addr(which), *((u8*) &l));
duke@435 262 }
duke@435 263
duke@435 264 void float_at_put(int which, jfloat f) {
duke@435 265 tag_at_put(which, JVM_CONSTANT_Float);
duke@435 266 *float_at_addr(which) = f;
duke@435 267 }
duke@435 268
duke@435 269 void double_at_put(int which, jdouble d) {
duke@435 270 tag_at_put(which, JVM_CONSTANT_Double);
duke@435 271 // *double_at_addr(which) = d;
duke@435 272 // u8 temp = *(u8*) &d;
duke@435 273 Bytes::put_native_u8((address) double_at_addr(which), *((u8*) &d));
duke@435 274 }
duke@435 275
coleenp@2497 276 Symbol** symbol_at_addr(int which) const {
coleenp@2497 277 assert(is_within_bounds(which), "index out of bounds");
coleenp@2497 278 return (Symbol**) &base()[which];
coleenp@2497 279 }
coleenp@2497 280
coleenp@2497 281 void symbol_at_put(int which, Symbol* s) {
coleenp@2497 282 assert(s->refcount() != 0, "should have nonzero refcount");
duke@435 283 tag_at_put(which, JVM_CONSTANT_Utf8);
coleenp@2497 284 slot_at_put(which, s);
duke@435 285 }
duke@435 286
duke@435 287 void string_at_put(int which, oop str) {
coleenp@2497 288 // Overwrite the old index with a GC friendly value so
coleenp@2497 289 // that if G1 looks during the transition during oop_store it won't
coleenp@2497 290 // assert the symbol is not an oop.
coleenp@2497 291 *obj_at_addr_raw(which) = NULL;
coleenp@2497 292 assert(str != NULL, "resolved string shouldn't be null");
coleenp@2497 293 obj_at_put(which, str);
duke@435 294 release_tag_at_put(which, JVM_CONSTANT_String);
duke@435 295 if (UseConcMarkSweepGC) {
duke@435 296 // In case the earlier card-mark was consumed by a concurrent
duke@435 297 // marking thread before the tag was updated, redirty the card.
coleenp@2497 298 obj_at_put_without_check(which, str);
duke@435 299 }
duke@435 300 }
duke@435 301
twisti@1573 302 void object_at_put(int which, oop str) {
coleenp@2497 303 obj_at_put(which, str);
twisti@1573 304 release_tag_at_put(which, JVM_CONSTANT_Object);
twisti@1573 305 if (UseConcMarkSweepGC) {
twisti@1573 306 // In case the earlier card-mark was consumed by a concurrent
twisti@1573 307 // marking thread before the tag was updated, redirty the card.
coleenp@2497 308 obj_at_put_without_check(which, str);
twisti@1573 309 }
twisti@1573 310 }
twisti@1573 311
duke@435 312 // For temporary use while constructing constant pool
duke@435 313 void string_index_at_put(int which, int string_index) {
duke@435 314 tag_at_put(which, JVM_CONSTANT_StringIndex);
duke@435 315 *int_at_addr(which) = string_index;
duke@435 316 }
duke@435 317
duke@435 318 void field_at_put(int which, int class_index, int name_and_type_index) {
duke@435 319 tag_at_put(which, JVM_CONSTANT_Fieldref);
duke@435 320 *int_at_addr(which) = ((jint) name_and_type_index<<16) | class_index;
duke@435 321 }
duke@435 322
duke@435 323 void method_at_put(int which, int class_index, int name_and_type_index) {
duke@435 324 tag_at_put(which, JVM_CONSTANT_Methodref);
duke@435 325 *int_at_addr(which) = ((jint) name_and_type_index<<16) | class_index;
duke@435 326 }
duke@435 327
duke@435 328 void interface_method_at_put(int which, int class_index, int name_and_type_index) {
duke@435 329 tag_at_put(which, JVM_CONSTANT_InterfaceMethodref);
duke@435 330 *int_at_addr(which) = ((jint) name_and_type_index<<16) | class_index; // Not so nice
duke@435 331 }
duke@435 332
duke@435 333 void name_and_type_at_put(int which, int name_index, int signature_index) {
duke@435 334 tag_at_put(which, JVM_CONSTANT_NameAndType);
duke@435 335 *int_at_addr(which) = ((jint) signature_index<<16) | name_index; // Not so nice
duke@435 336 }
duke@435 337
duke@435 338 // Tag query
duke@435 339
duke@435 340 constantTag tag_at(int which) const { return (constantTag)tags()->byte_at_acquire(which); }
duke@435 341
duke@435 342 // Whether the entry is a pointer that must be GC'd.
duke@435 343 bool is_pointer_entry(int which) {
duke@435 344 constantTag tag = tag_at(which);
duke@435 345 return tag.is_klass() ||
twisti@1573 346 tag.is_string() ||
twisti@1573 347 tag.is_object();
duke@435 348 }
duke@435 349
coleenp@2497 350 // Whether the entry points to an object for ldc (resolved or not)
coleenp@2497 351 bool is_object_entry(int which) {
coleenp@2497 352 constantTag tag = tag_at(which);
coleenp@2497 353 return is_pointer_entry(which) ||
coleenp@2497 354 tag.is_unresolved_klass() ||
coleenp@2497 355 tag.is_unresolved_string() ||
coleenp@2497 356 tag.is_symbol();
coleenp@2497 357 }
coleenp@2497 358
duke@435 359 // Fetching constants
duke@435 360
duke@435 361 klassOop klass_at(int which, TRAPS) {
duke@435 362 constantPoolHandle h_this(THREAD, this);
duke@435 363 return klass_at_impl(h_this, which, CHECK_NULL);
duke@435 364 }
duke@435 365
coleenp@2497 366 Symbol* klass_name_at(int which); // Returns the name, w/o resolving.
duke@435 367
duke@435 368 klassOop resolved_klass_at(int which) { // Used by Compiler
duke@435 369 guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
duke@435 370 // Must do an acquire here in case another thread resolved the klass
duke@435 371 // behind our back, lest we later load stale values thru the oop.
coleenp@2497 372 return klassOop(CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_oop());
duke@435 373 }
duke@435 374
duke@435 375 // This method should only be used with a cpool lock or during parsing or gc
coleenp@2497 376 Symbol* unresolved_klass_at(int which) { // Temporary until actual use
coleenp@2497 377 Symbol* s = CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
duke@435 378 // check that the klass is still unresolved.
duke@435 379 assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool");
duke@435 380 return s;
duke@435 381 }
duke@435 382
duke@435 383 // RedefineClasses() API support:
coleenp@2497 384 Symbol* klass_at_noresolve(int which) { return klass_name_at(which); }
duke@435 385
duke@435 386 jint int_at(int which) {
duke@435 387 assert(tag_at(which).is_int(), "Corrupted constant pool");
duke@435 388 return *int_at_addr(which);
duke@435 389 }
duke@435 390
duke@435 391 jlong long_at(int which) {
duke@435 392 assert(tag_at(which).is_long(), "Corrupted constant pool");
duke@435 393 // return *long_at_addr(which);
duke@435 394 u8 tmp = Bytes::get_native_u8((address)&base()[which]);
duke@435 395 return *((jlong*)&tmp);
duke@435 396 }
duke@435 397
duke@435 398 jfloat float_at(int which) {
duke@435 399 assert(tag_at(which).is_float(), "Corrupted constant pool");
duke@435 400 return *float_at_addr(which);
duke@435 401 }
duke@435 402
duke@435 403 jdouble double_at(int which) {
duke@435 404 assert(tag_at(which).is_double(), "Corrupted constant pool");
duke@435 405 u8 tmp = Bytes::get_native_u8((address)&base()[which]);
duke@435 406 return *((jdouble*)&tmp);
duke@435 407 }
duke@435 408
coleenp@2497 409 Symbol* symbol_at(int which) {
duke@435 410 assert(tag_at(which).is_utf8(), "Corrupted constant pool");
coleenp@2497 411 return slot_at(which).get_symbol();
duke@435 412 }
duke@435 413
duke@435 414 oop string_at(int which, TRAPS) {
duke@435 415 constantPoolHandle h_this(THREAD, this);
duke@435 416 return string_at_impl(h_this, which, CHECK_NULL);
duke@435 417 }
duke@435 418
twisti@1573 419 oop object_at(int which) {
twisti@1573 420 assert(tag_at(which).is_object(), "Corrupted constant pool");
coleenp@2497 421 return slot_at(which).get_oop();
twisti@1573 422 }
twisti@1573 423
jrose@866 424 // A "pseudo-string" is an non-string oop that has found is way into
jrose@866 425 // a String entry.
jrose@866 426 // Under AnonymousClasses this can happen if the user patches a live
jrose@866 427 // object into a CONSTANT_String entry of an anonymous class.
jrose@866 428 // Method oops internally created for method handles may also
jrose@866 429 // use pseudo-strings to link themselves to related metaobjects.
jrose@866 430
jrose@866 431 bool is_pseudo_string_at(int which);
jrose@866 432
jrose@866 433 oop pseudo_string_at(int which) {
jrose@866 434 assert(tag_at(which).is_string(), "Corrupted constant pool");
coleenp@2497 435 return slot_at(which).get_oop();
jrose@866 436 }
jrose@866 437
jrose@866 438 void pseudo_string_at_put(int which, oop x) {
jrose@866 439 assert(AnonymousClasses, "");
jrose@866 440 set_pseudo_string(); // mark header
jrose@866 441 assert(tag_at(which).is_string() || tag_at(which).is_unresolved_string(), "Corrupted constant pool");
jrose@866 442 string_at_put(which, x); // this works just fine
jrose@866 443 }
jrose@866 444
duke@435 445 // only called when we are sure a string entry is already resolved (via an
duke@435 446 // earlier string_at call.
duke@435 447 oop resolved_string_at(int which) {
duke@435 448 assert(tag_at(which).is_string(), "Corrupted constant pool");
duke@435 449 // Must do an acquire here in case another thread resolved the klass
duke@435 450 // behind our back, lest we later load stale values thru the oop.
coleenp@2497 451 return CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_oop();
duke@435 452 }
duke@435 453
duke@435 454 // This method should only be used with a cpool lock or during parsing or gc
coleenp@2497 455 Symbol* unresolved_string_at(int which) { // Temporary until actual use
coleenp@2497 456 Symbol* s = CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
duke@435 457 // check that the string is still unresolved.
duke@435 458 assert(tag_at(which).is_unresolved_string(), "Corrupted constant pool");
duke@435 459 return s;
duke@435 460 }
duke@435 461
duke@435 462 // Returns an UTF8 for a CONSTANT_String entry at a given index.
duke@435 463 // UTF8 char* representation was chosen to avoid conversion of
coleenp@2497 464 // java_lang_Strings at resolved entries into Symbol*s
duke@435 465 // or vice versa.
jrose@866 466 // Caller is responsible for checking for pseudo-strings.
duke@435 467 char* string_at_noresolve(int which);
duke@435 468
duke@435 469 jint name_and_type_at(int which) {
duke@435 470 assert(tag_at(which).is_name_and_type(), "Corrupted constant pool");
duke@435 471 return *int_at_addr(which);
duke@435 472 }
duke@435 473
jrose@1957 474 int method_handle_ref_kind_at(int which) {
jrose@1957 475 assert(tag_at(which).is_method_handle(), "Corrupted constant pool");
jrose@1957 476 return extract_low_short_from_int(*int_at_addr(which)); // mask out unwanted ref_index bits
jrose@1957 477 }
jrose@1957 478 int method_handle_index_at(int which) {
jrose@1957 479 assert(tag_at(which).is_method_handle(), "Corrupted constant pool");
jrose@1957 480 return extract_high_short_from_int(*int_at_addr(which)); // shift out unwanted ref_kind bits
jrose@1957 481 }
jrose@1957 482 int method_type_index_at(int which) {
jrose@1957 483 assert(tag_at(which).is_method_type(), "Corrupted constant pool");
jrose@1957 484 return *int_at_addr(which);
jrose@1957 485 }
jrose@1957 486 // Derived queries:
coleenp@2497 487 Symbol* method_handle_name_ref_at(int which) {
jrose@1957 488 int member = method_handle_index_at(which);
jrose@1957 489 return impl_name_ref_at(member, true);
jrose@1957 490 }
coleenp@2497 491 Symbol* method_handle_signature_ref_at(int which) {
jrose@1957 492 int member = method_handle_index_at(which);
jrose@1957 493 return impl_signature_ref_at(member, true);
jrose@1957 494 }
jrose@1957 495 int method_handle_klass_index_at(int which) {
jrose@1957 496 int member = method_handle_index_at(which);
jrose@1957 497 return impl_klass_ref_index_at(member, true);
jrose@1957 498 }
coleenp@2497 499 Symbol* method_type_signature_at(int which) {
jrose@1957 500 int sym = method_type_index_at(which);
jrose@1957 501 return symbol_at(sym);
jrose@1957 502 }
jrose@2268 503
jrose@2353 504 int invoke_dynamic_name_and_type_ref_index_at(int which) {
jrose@2353 505 assert(tag_at(which).is_invoke_dynamic(), "Corrupted constant pool");
jrose@2353 506 return extract_high_short_from_int(*int_at_addr(which));
jrose@2268 507 }
jrose@2353 508 int invoke_dynamic_bootstrap_specifier_index(int which) {
jrose@2353 509 assert(tag_at(which).value() == JVM_CONSTANT_InvokeDynamic, "Corrupted constant pool");
jrose@2353 510 return extract_low_short_from_int(*int_at_addr(which));
jrose@2268 511 }
jrose@2353 512 int invoke_dynamic_operand_base(int which) {
jrose@2353 513 int bootstrap_specifier_index = invoke_dynamic_bootstrap_specifier_index(which);
jrose@2353 514 return operand_offset_at(operands(), bootstrap_specifier_index);
jrose@2268 515 }
jrose@2353 516 // The first part of the operands array consists of an index into the second part.
jrose@2353 517 // Extract a 32-bit index value from the first part.
jrose@2353 518 static int operand_offset_at(typeArrayOop operands, int bootstrap_specifier_index) {
jrose@2353 519 int n = (bootstrap_specifier_index * 2);
jrose@2353 520 assert(n >= 0 && n+2 <= operands->length(), "oob");
jrose@2353 521 // The first 32-bit index points to the beginning of the second part
jrose@2353 522 // of the operands array. Make sure this index is in the first part.
jrose@2353 523 DEBUG_ONLY(int second_part = build_int_from_shorts(operands->short_at(0),
jrose@2353 524 operands->short_at(1)));
jrose@2353 525 assert(second_part == 0 || n+2 <= second_part, "oob (2)");
jrose@2353 526 int offset = build_int_from_shorts(operands->short_at(n+0),
jrose@2353 527 operands->short_at(n+1));
jrose@2353 528 // The offset itself must point into the second part of the array.
jrose@2353 529 assert(offset == 0 || offset >= second_part && offset <= operands->length(), "oob (3)");
jrose@2353 530 return offset;
jrose@2268 531 }
jrose@2353 532 static void operand_offset_at_put(typeArrayOop operands, int bootstrap_specifier_index, int offset) {
jrose@2353 533 int n = bootstrap_specifier_index * 2;
jrose@2353 534 assert(n >= 0 && n+2 <= operands->length(), "oob");
jrose@2353 535 operands->short_at_put(n+0, extract_low_short_from_int(offset));
jrose@2353 536 operands->short_at_put(n+1, extract_high_short_from_int(offset));
jrose@2268 537 }
jrose@2353 538 static int operand_array_length(typeArrayOop operands) {
jrose@2353 539 if (operands == NULL || operands->length() == 0) return 0;
jrose@2353 540 int second_part = operand_offset_at(operands, 0);
jrose@2353 541 return (second_part / 2);
jrose@2268 542 }
jrose@2268 543
jrose@2353 544 #ifdef ASSERT
jrose@2353 545 // operand tuples fit together exactly, end to end
jrose@2353 546 static int operand_limit_at(typeArrayOop operands, int bootstrap_specifier_index) {
jrose@2353 547 int nextidx = bootstrap_specifier_index + 1;
jrose@2353 548 if (nextidx == operand_array_length(operands))
jrose@2353 549 return operands->length();
jrose@2353 550 else
jrose@2353 551 return operand_offset_at(operands, nextidx);
jrose@2353 552 }
jrose@2353 553 int invoke_dynamic_operand_limit(int which) {
jrose@2353 554 int bootstrap_specifier_index = invoke_dynamic_bootstrap_specifier_index(which);
jrose@2353 555 return operand_limit_at(operands(), bootstrap_specifier_index);
jrose@2353 556 }
jrose@2353 557 #endif //ASSERT
jrose@2353 558
jrose@2353 559 // layout of InvokeDynamic bootstrap method specifier (in second part of operands array):
jrose@2268 560 enum {
jrose@2268 561 _indy_bsm_offset = 0, // CONSTANT_MethodHandle bsm
jrose@2353 562 _indy_argc_offset = 1, // u2 argc
jrose@2353 563 _indy_argv_offset = 2 // u2 argv[argc]
jrose@2268 564 };
jrose@2015 565 int invoke_dynamic_bootstrap_method_ref_index_at(int which) {
jrose@2015 566 assert(tag_at(which).is_invoke_dynamic(), "Corrupted constant pool");
jrose@2353 567 if (tag_at(which).value() == JVM_CONSTANT_InvokeDynamicTrans)
jrose@2353 568 return extract_low_short_from_int(*int_at_addr(which));
jrose@2353 569 int op_base = invoke_dynamic_operand_base(which);
jrose@2353 570 return operands()->short_at(op_base + _indy_bsm_offset);
jrose@2268 571 }
jrose@2268 572 int invoke_dynamic_argument_count_at(int which) {
jrose@2268 573 assert(tag_at(which).is_invoke_dynamic(), "Corrupted constant pool");
jrose@2353 574 if (tag_at(which).value() == JVM_CONSTANT_InvokeDynamicTrans)
jrose@2353 575 return 0;
jrose@2353 576 int op_base = invoke_dynamic_operand_base(which);
jrose@2353 577 int argc = operands()->short_at(op_base + _indy_argc_offset);
jrose@2353 578 DEBUG_ONLY(int end_offset = op_base + _indy_argv_offset + argc;
jrose@2353 579 int next_offset = invoke_dynamic_operand_limit(which));
jrose@2353 580 assert(end_offset == next_offset, "matched ending");
jrose@2268 581 return argc;
jrose@2268 582 }
jrose@2268 583 int invoke_dynamic_argument_index_at(int which, int j) {
jrose@2353 584 int op_base = invoke_dynamic_operand_base(which);
jrose@2353 585 DEBUG_ONLY(int argc = operands()->short_at(op_base + _indy_argc_offset));
jrose@2353 586 assert((uint)j < (uint)argc, "oob");
jrose@2353 587 return operands()->short_at(op_base + _indy_argv_offset + j);
jrose@2015 588 }
jrose@1957 589
jrose@1161 590 // The following methods (name/signature/klass_ref_at, klass_ref_at_noresolve,
jrose@1494 591 // name_and_type_ref_index_at) all expect to be passed indices obtained
jrose@2265 592 // directly from the bytecode.
jrose@1494 593 // If the indices are meant to refer to fields or methods, they are
jrose@2265 594 // actually rewritten constant pool cache indices.
jrose@1494 595 // The routine remap_instruction_operand_from_cache manages the adjustment
jrose@1494 596 // of these values back to constant pool indices.
jrose@1161 597
jrose@1494 598 // There are also "uncached" versions which do not adjust the operand index; see below.
duke@435 599
jrose@2265 600 // FIXME: Consider renaming these with a prefix "cached_" to make the distinction clear.
jrose@2265 601 // In a few cases (the verifier) there are uses before a cpcache has been built,
jrose@2265 602 // which are handled by a dynamic check in remap_instruction_operand_from_cache.
jrose@2265 603 // FIXME: Remove the dynamic check, and adjust all callers to specify the correct mode.
jrose@2265 604
duke@435 605 // Lookup for entries consisting of (klass_index, name_and_type index)
duke@435 606 klassOop klass_ref_at(int which, TRAPS);
coleenp@2497 607 Symbol* klass_ref_at_noresolve(int which);
coleenp@2497 608 Symbol* name_ref_at(int which) { return impl_name_ref_at(which, false); }
coleenp@2497 609 Symbol* signature_ref_at(int which) { return impl_signature_ref_at(which, false); }
duke@435 610
jrose@1161 611 int klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, false); }
jrose@1161 612 int name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, false); }
duke@435 613
duke@435 614 // Lookup for entries consisting of (name_index, signature_index)
jrose@1161 615 int name_ref_index_at(int which_nt); // == low-order jshort of name_and_type_at(which_nt)
jrose@1161 616 int signature_ref_index_at(int which_nt); // == high-order jshort of name_and_type_at(which_nt)
duke@435 617
duke@435 618 BasicType basic_type_for_signature_at(int which);
duke@435 619
duke@435 620 // Resolve string constants (to prevent allocation during compilation)
duke@435 621 void resolve_string_constants(TRAPS) {
duke@435 622 constantPoolHandle h_this(THREAD, this);
duke@435 623 resolve_string_constants_impl(h_this, CHECK);
duke@435 624 }
duke@435 625
jrose@2268 626 private:
jrose@2268 627 enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
jrose@2268 628 public:
jrose@2268 629
jrose@1957 630 // Resolve late bound constants.
jrose@1957 631 oop resolve_constant_at(int index, TRAPS) {
jrose@1957 632 constantPoolHandle h_this(THREAD, this);
jrose@2268 633 return resolve_constant_at_impl(h_this, index, _no_index_sentinel, THREAD);
jrose@1957 634 }
jrose@1957 635
jrose@1957 636 oop resolve_cached_constant_at(int cache_index, TRAPS) {
jrose@1957 637 constantPoolHandle h_this(THREAD, this);
jrose@2268 638 return resolve_constant_at_impl(h_this, _no_index_sentinel, cache_index, THREAD);
jrose@2268 639 }
jrose@2268 640
jrose@2268 641 oop resolve_possibly_cached_constant_at(int pool_index, TRAPS) {
jrose@2268 642 constantPoolHandle h_this(THREAD, this);
jrose@2268 643 return resolve_constant_at_impl(h_this, pool_index, _possible_index_sentinel, THREAD);
jrose@1957 644 }
jrose@1957 645
duke@435 646 // Klass name matches name at offset
duke@435 647 bool klass_name_at_matches(instanceKlassHandle k, int which);
duke@435 648
duke@435 649 // Sizing
coleenp@548 650 int length() const { return _length; }
coleenp@548 651 void set_length(int length) { _length = length; }
coleenp@548 652
coleenp@548 653 // Tells whether index is within bounds.
coleenp@548 654 bool is_within_bounds(int index) const {
coleenp@548 655 return 0 <= index && index < length();
coleenp@548 656 }
coleenp@548 657
duke@435 658 static int header_size() { return sizeof(constantPoolOopDesc)/HeapWordSize; }
duke@435 659 static int object_size(int length) { return align_object_size(header_size() + length); }
duke@435 660 int object_size() { return object_size(length()); }
duke@435 661
jmasa@953 662 bool is_conc_safe() { return _is_conc_safe; }
jmasa@953 663 void set_is_conc_safe(bool v) { _is_conc_safe = v; }
jmasa@953 664
duke@435 665 friend class constantPoolKlass;
duke@435 666 friend class ClassFileParser;
duke@435 667 friend class SystemDictionary;
duke@435 668
duke@435 669 // Used by compiler to prevent classloading.
duke@435 670 static klassOop klass_at_if_loaded (constantPoolHandle this_oop, int which);
duke@435 671 static klassOop klass_ref_at_if_loaded (constantPoolHandle this_oop, int which);
duke@435 672 // Same as above - but does LinkResolving.
duke@435 673 static klassOop klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int which, TRAPS);
duke@435 674
duke@435 675 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
jrose@2265 676 // future by other Java code. These take constant pool indices rather than
duke@435 677 // constant pool cache indices as do the peer methods above.
coleenp@2497 678 Symbol* uncached_klass_ref_at_noresolve(int which);
coleenp@2497 679 Symbol* uncached_name_ref_at(int which) { return impl_name_ref_at(which, true); }
coleenp@2497 680 Symbol* uncached_signature_ref_at(int which) { return impl_signature_ref_at(which, true); }
jrose@1161 681 int uncached_klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, true); }
jrose@1161 682 int uncached_name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, true); }
duke@435 683
duke@435 684 // Sharing
duke@435 685 int pre_resolve_shared_klasses(TRAPS);
coleenp@2497 686 void shared_symbols_iterate(SymbolClosure* closure0);
duke@435 687 void shared_tags_iterate(OopClosure* closure0);
duke@435 688 void shared_strings_iterate(OopClosure* closure0);
duke@435 689
duke@435 690 // Debugging
duke@435 691 const char* printable_name_at(int which) PRODUCT_RETURN0;
duke@435 692
jrose@1920 693 #ifdef ASSERT
jrose@1920 694 enum { CPCACHE_INDEX_TAG = 0x10000 }; // helps keep CP cache indices distinct from CP indices
jrose@1957 695 #else
jrose@1957 696 enum { CPCACHE_INDEX_TAG = 0 }; // in product mode, this zero value is a no-op
jrose@1920 697 #endif //ASSERT
jrose@1920 698
duke@435 699 private:
duke@435 700
coleenp@2497 701 Symbol* impl_name_ref_at(int which, bool uncached);
coleenp@2497 702 Symbol* impl_signature_ref_at(int which, bool uncached);
jrose@1161 703 int impl_klass_ref_index_at(int which, bool uncached);
jrose@1161 704 int impl_name_and_type_ref_index_at(int which, bool uncached);
jrose@1161 705
jrose@1920 706 int remap_instruction_operand_from_cache(int operand); // operand must be biased by CPCACHE_INDEX_TAG
duke@435 707
duke@435 708 // Used while constructing constant pool (only by ClassFileParser)
duke@435 709 jint klass_index_at(int which) {
duke@435 710 assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
duke@435 711 return *int_at_addr(which);
duke@435 712 }
duke@435 713
duke@435 714 jint string_index_at(int which) {
duke@435 715 assert(tag_at(which).is_string_index(), "Corrupted constant pool");
duke@435 716 return *int_at_addr(which);
duke@435 717 }
duke@435 718
duke@435 719 // Performs the LinkResolver checks
duke@435 720 static void verify_constant_pool_resolve(constantPoolHandle this_oop, KlassHandle klass, TRAPS);
duke@435 721
duke@435 722 // Implementation of methods that needs an exposed 'this' pointer, in order to
duke@435 723 // handle GC while executing the method
duke@435 724 static klassOop klass_at_impl(constantPoolHandle this_oop, int which, TRAPS);
duke@435 725 static oop string_at_impl(constantPoolHandle this_oop, int which, TRAPS);
duke@435 726
duke@435 727 // Resolve string constants (to prevent allocation during compilation)
duke@435 728 static void resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS);
duke@435 729
jrose@1957 730 static oop resolve_constant_at_impl(constantPoolHandle this_oop, int index, int cache_index, TRAPS);
jrose@1957 731
duke@435 732 public:
duke@435 733 // Merging constantPoolOop support:
duke@435 734 bool compare_entry_to(int index1, constantPoolHandle cp2, int index2, TRAPS);
jrose@2353 735 void copy_cp_to(int start_i, int end_i, constantPoolHandle to_cp, int to_i, TRAPS) {
jrose@2353 736 constantPoolHandle h_this(THREAD, this);
jrose@2353 737 copy_cp_to_impl(h_this, start_i, end_i, to_cp, to_i, THREAD);
jrose@2353 738 }
jrose@2353 739 static void copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i, constantPoolHandle to_cp, int to_i, TRAPS);
jrose@2353 740 static void copy_entry_to(constantPoolHandle from_cp, int from_i, constantPoolHandle to_cp, int to_i, TRAPS);
duke@435 741 int find_matching_entry(int pattern_i, constantPoolHandle search_cp, TRAPS);
duke@435 742 int orig_length() const { return _orig_length; }
duke@435 743 void set_orig_length(int orig_length) { _orig_length = orig_length; }
duke@435 744
coleenp@2497 745 // Decrease ref counts of symbols that are in the constant pool
coleenp@2497 746 // when the holder class is unloaded
coleenp@2497 747 void unreference_symbols();
duke@435 748
duke@435 749 // JVMTI accesss - GetConstantPool, RetransformClasses, ...
duke@435 750 friend class JvmtiConstantPoolReconstituter;
duke@435 751
duke@435 752 private:
duke@435 753 jint cpool_entry_size(jint idx);
duke@435 754 jint hash_entries_to(SymbolHashMap *symmap, SymbolHashMap *classmap);
duke@435 755
duke@435 756 // Copy cpool bytes into byte array.
duke@435 757 // Returns:
duke@435 758 // int > 0, count of the raw cpool bytes that have been copied
duke@435 759 // 0, OutOfMemory error
duke@435 760 // -1, Internal error
duke@435 761 int copy_cpool_bytes(int cpool_size,
duke@435 762 SymbolHashMap* tbl,
duke@435 763 unsigned char *bytes);
duke@435 764 };
duke@435 765
duke@435 766 class SymbolHashMapEntry : public CHeapObj {
duke@435 767 private:
duke@435 768 unsigned int _hash; // 32-bit hash for item
duke@435 769 SymbolHashMapEntry* _next; // Next element in the linked list for this bucket
coleenp@2497 770 Symbol* _symbol; // 1-st part of the mapping: symbol => value
duke@435 771 u2 _value; // 2-nd part of the mapping: symbol => value
duke@435 772
duke@435 773 public:
duke@435 774 unsigned int hash() const { return _hash; }
duke@435 775 void set_hash(unsigned int hash) { _hash = hash; }
duke@435 776
duke@435 777 SymbolHashMapEntry* next() const { return _next; }
duke@435 778 void set_next(SymbolHashMapEntry* next) { _next = next; }
duke@435 779
coleenp@2497 780 Symbol* symbol() const { return _symbol; }
coleenp@2497 781 void set_symbol(Symbol* sym) { _symbol = sym; }
duke@435 782
duke@435 783 u2 value() const { return _value; }
duke@435 784 void set_value(u2 value) { _value = value; }
duke@435 785
coleenp@2497 786 SymbolHashMapEntry(unsigned int hash, Symbol* symbol, u2 value)
duke@435 787 : _hash(hash), _symbol(symbol), _value(value), _next(NULL) {}
duke@435 788
duke@435 789 }; // End SymbolHashMapEntry class
duke@435 790
duke@435 791
duke@435 792 class SymbolHashMapBucket : public CHeapObj {
duke@435 793
duke@435 794 private:
duke@435 795 SymbolHashMapEntry* _entry;
duke@435 796
duke@435 797 public:
duke@435 798 SymbolHashMapEntry* entry() const { return _entry; }
duke@435 799 void set_entry(SymbolHashMapEntry* entry) { _entry = entry; }
duke@435 800 void clear() { _entry = NULL; }
duke@435 801
duke@435 802 }; // End SymbolHashMapBucket class
duke@435 803
duke@435 804
duke@435 805 class SymbolHashMap: public CHeapObj {
duke@435 806
duke@435 807 private:
duke@435 808 // Default number of entries in the table
duke@435 809 enum SymbolHashMap_Constants {
duke@435 810 _Def_HashMap_Size = 256
duke@435 811 };
duke@435 812
duke@435 813 int _table_size;
duke@435 814 SymbolHashMapBucket* _buckets;
duke@435 815
duke@435 816 void initialize_table(int table_size) {
duke@435 817 _table_size = table_size;
duke@435 818 _buckets = NEW_C_HEAP_ARRAY(SymbolHashMapBucket, table_size);
duke@435 819 for (int index = 0; index < table_size; index++) {
duke@435 820 _buckets[index].clear();
duke@435 821 }
duke@435 822 }
duke@435 823
duke@435 824 public:
duke@435 825
duke@435 826 int table_size() const { return _table_size; }
duke@435 827
duke@435 828 SymbolHashMap() { initialize_table(_Def_HashMap_Size); }
duke@435 829 SymbolHashMap(int table_size) { initialize_table(table_size); }
duke@435 830
duke@435 831 // hash P(31) from Kernighan & Ritchie
duke@435 832 static unsigned int compute_hash(const char* str, int len) {
duke@435 833 unsigned int hash = 0;
duke@435 834 while (len-- > 0) {
duke@435 835 hash = 31*hash + (unsigned) *str;
duke@435 836 str++;
duke@435 837 }
duke@435 838 return hash;
duke@435 839 }
duke@435 840
duke@435 841 SymbolHashMapEntry* bucket(int i) {
duke@435 842 return _buckets[i].entry();
duke@435 843 }
duke@435 844
coleenp@2497 845 void add_entry(Symbol* sym, u2 value);
coleenp@2497 846 SymbolHashMapEntry* find_entry(Symbol* sym);
duke@435 847
coleenp@2497 848 u2 symbol_to_value(Symbol* sym) {
duke@435 849 SymbolHashMapEntry *entry = find_entry(sym);
duke@435 850 return (entry == NULL) ? 0 : entry->value();
duke@435 851 }
duke@435 852
duke@435 853 ~SymbolHashMap() {
duke@435 854 SymbolHashMapEntry* next;
duke@435 855 for (int i = 0; i < _table_size; i++) {
duke@435 856 for (SymbolHashMapEntry* cur = bucket(i); cur != NULL; cur = next) {
duke@435 857 next = cur->next();
duke@435 858 delete(cur);
duke@435 859 }
duke@435 860 }
duke@435 861 delete _buckets;
duke@435 862 }
duke@435 863 }; // End SymbolHashMap class
stefank@2314 864
stefank@2314 865 #endif // SHARE_VM_OOPS_CONSTANTPOOLOOP_HPP

mercurial