comparison src/share/vm/oops/constantPool.hpp @ 8104:f16e75e0cf11

8000797: NPG: is_pseudo_string_at() doesn't work Summary: Zero Symbol* for constant pool strings to indicate pseudo_strings (objects that aren't strings). Clean up JVM_CONSTANT_Object and unused flags. Reviewed-by: sspitsyn, jrose
author coleenp
date Fri, 22 Feb 2013 08:36:42 -0500
parents 0d26ce8e9251
children 5fc51c1ecdeb 15a99ca4ee34
comparison
equal deleted inserted replaced
8103:5ed317b25e23 8104:f16e75e0cf11
95 // object index to original constant pool index 95 // object index to original constant pool index
96 jobject _resolved_references; 96 jobject _resolved_references;
97 Array<u2>* _reference_map; 97 Array<u2>* _reference_map;
98 98
99 enum { 99 enum {
100 _has_invokedynamic = 1, // Flags 100 _has_preresolution = 1, // Flags
101 _has_pseudo_string = 2, 101 _on_stack = 2
102 _has_preresolution = 4,
103 _on_stack = 8
104 }; 102 };
105 103
106 int _flags; // old fashioned bit twiddling 104 int _flags; // old fashioned bit twiddling
107 int _length; // number of elements in the array 105 int _length; // number of elements in the array
108 106
172 170
173 bool is_constantPool() const volatile { return true; } 171 bool is_constantPool() const volatile { return true; }
174 172
175 Array<u1>* tags() const { return _tags; } 173 Array<u1>* tags() const { return _tags; }
176 Array<u2>* operands() const { return _operands; } 174 Array<u2>* operands() const { return _operands; }
177
178 bool has_invokedynamic() const { return (_flags & _has_invokedynamic) != 0; }
179 void set_has_invokedynamic() { _flags |= _has_invokedynamic; }
180
181 bool has_pseudo_string() const { return (_flags & _has_pseudo_string) != 0; }
182 void set_has_pseudo_string() { _flags |= _has_pseudo_string; }
183 175
184 bool has_preresolution() const { return (_flags & _has_preresolution) != 0; } 176 bool has_preresolution() const { return (_flags & _has_preresolution) != 0; }
185 void set_has_preresolution() { _flags |= _has_preresolution; } 177 void set_has_preresolution() { _flags |= _has_preresolution; }
186 178
187 // Redefine classes support. If a method refering to this constant pool 179 // Redefine classes support. If a method refering to this constant pool
322 314
323 void string_at_put(int which, int obj_index, oop str) { 315 void string_at_put(int which, int obj_index, oop str) {
324 resolved_references()->obj_at_put(obj_index, str); 316 resolved_references()->obj_at_put(obj_index, str);
325 } 317 }
326 318
327 void set_object_tag_at(int which) {
328 release_tag_at_put(which, JVM_CONSTANT_Object);
329 }
330
331 void object_at_put(int which, oop obj) {
332 resolved_references()->obj_at_put(cp_to_object_index(which), obj);
333 }
334
335 // For temporary use while constructing constant pool 319 // For temporary use while constructing constant pool
336 void string_index_at_put(int which, int string_index) { 320 void string_index_at_put(int which, int string_index) {
337 tag_at_put(which, JVM_CONSTANT_StringIndex); 321 tag_at_put(which, JVM_CONSTANT_StringIndex);
338 *int_at_addr(which) = string_index; 322 *int_at_addr(which) = string_index;
339 } 323 }
427 } 411 }
428 412
429 // Version that can be used before string oop array is created. 413 // Version that can be used before string oop array is created.
430 oop uncached_string_at(int which, TRAPS); 414 oop uncached_string_at(int which, TRAPS);
431 415
432 oop object_at(int which) {
433 assert(tag_at(which).is_object(), "Corrupted constant pool");
434 int obj_index = cp_to_object_index(which);
435 return resolved_references()->obj_at(obj_index);
436 }
437
438 // A "pseudo-string" is an non-string oop that has found is way into 416 // A "pseudo-string" is an non-string oop that has found is way into
439 // a String entry. 417 // a String entry.
440 // Under EnableInvokeDynamic this can happen if the user patches a live 418 // Under EnableInvokeDynamic this can happen if the user patches a live
441 // object into a CONSTANT_String entry of an anonymous class. 419 // object into a CONSTANT_String entry of an anonymous class.
442 // Method oops internally created for method handles may also 420 // Method oops internally created for method handles may also
452 assert(unresolved_string_at(which) == NULL, "shouldn't have symbol"); 430 assert(unresolved_string_at(which) == NULL, "shouldn't have symbol");
453 oop s = resolved_references()->obj_at(obj_index); 431 oop s = resolved_references()->obj_at(obj_index);
454 return s; 432 return s;
455 } 433 }
456 434
435 oop pseudo_string_at(int which) {
436 assert(tag_at(which).is_string(), "Corrupted constant pool");
437 assert(unresolved_string_at(which) == NULL, "shouldn't have symbol");
438 int obj_index = cp_to_object_index(which);
439 oop s = resolved_references()->obj_at(obj_index);
440 return s;
441 }
442
457 void pseudo_string_at_put(int which, int obj_index, oop x) { 443 void pseudo_string_at_put(int which, int obj_index, oop x) {
458 assert(EnableInvokeDynamic, ""); 444 assert(EnableInvokeDynamic, "");
459 set_has_pseudo_string(); // mark header
460 assert(tag_at(which).is_string(), "Corrupted constant pool"); 445 assert(tag_at(which).is_string(), "Corrupted constant pool");
446 unresolved_string_at_put(which, NULL); // indicates patched string
461 string_at_put(which, obj_index, x); // this works just fine 447 string_at_put(which, obj_index, x); // this works just fine
462 } 448 }
463 449
464 // only called when we are sure a string entry is already resolved (via an 450 // only called when we are sure a string entry is already resolved (via an
465 // earlier string_at call. 451 // earlier string_at call.