Mercurial > hg > graal-compiler
comparison src/share/vm/oops/constantPool.hpp @ 8124:5fc51c1ecdeb
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 05 Mar 2013 23:44:54 +0100 |
parents | 3ac7d10a6572 f16e75e0cf11 |
children | 836a62f43af9 |
comparison
equal
deleted
inserted
replaced
7943:a413bcd552a4 | 8124:5fc51c1ecdeb |
---|---|
78 assert(is_resolved(), "bad call"); | 78 assert(is_resolved(), "bad call"); |
79 return (Klass*)_ptr; | 79 return (Klass*)_ptr; |
80 } | 80 } |
81 }; | 81 }; |
82 | 82 |
83 class KlassSizeStats; | |
83 class ConstantPool : public Metadata { | 84 class ConstantPool : public Metadata { |
84 friend class VMStructs; | 85 friend class VMStructs; |
85 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast | 86 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast |
86 friend class Universe; // For null constructor | 87 friend class Universe; // For null constructor |
87 private: | 88 private: |
93 // Array of resolved objects from the constant pool and map from resolved | 94 // Array of resolved objects from the constant pool and map from resolved |
94 // object index to original constant pool index | 95 // object index to original constant pool index |
95 jobject _resolved_references; | 96 jobject _resolved_references; |
96 Array<u2>* _reference_map; | 97 Array<u2>* _reference_map; |
97 | 98 |
98 int _flags; // a few header bits to describe contents for GC | 99 enum { |
100 _has_preresolution = 1, // Flags | |
101 _on_stack = 2 | |
102 }; | |
103 | |
104 int _flags; // old fashioned bit twiddling | |
99 int _length; // number of elements in the array | 105 int _length; // number of elements in the array |
100 | |
101 bool _on_stack; // Redefined method still executing refers to this constant pool. | |
102 | 106 |
103 union { | 107 union { |
104 // set for CDS to restore resolved references | 108 // set for CDS to restore resolved references |
105 int _resolved_reference_length; | 109 int _resolved_reference_length; |
106 // keeps version number for redefined classes (used in backtrace) | 110 // keeps version number for redefined classes (used in backtrace) |
113 void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); } | 117 void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); } |
114 void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); } | 118 void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); } |
115 | 119 |
116 void set_operands(Array<u2>* operands) { _operands = operands; } | 120 void set_operands(Array<u2>* operands) { _operands = operands; } |
117 | 121 |
118 enum FlagBit { | 122 int flags() const { return _flags; } |
119 FB_has_invokedynamic = 1, | 123 void set_flags(int f) { _flags = f; } |
120 FB_has_pseudo_string = 2, | |
121 FB_has_preresolution = 3 | |
122 }; | |
123 | |
124 int flags() const { return _flags; } | |
125 void set_flags(int f) { _flags = f; } | |
126 bool flag_at(FlagBit fb) const { return (_flags & (1 << (int)fb)) != 0; } | |
127 void set_flag_at(FlagBit fb); | |
128 // no clear_flag_at function; they only increase | |
129 | 124 |
130 private: | 125 private: |
131 intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(ConstantPool)); } | 126 intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(ConstantPool)); } |
132 | 127 |
133 CPSlot slot_at(int which) { | 128 CPSlot slot_at(int which) { |
176 bool is_constantPool() const volatile { return true; } | 171 bool is_constantPool() const volatile { return true; } |
177 | 172 |
178 Array<u1>* tags() const { return _tags; } | 173 Array<u1>* tags() const { return _tags; } |
179 Array<u2>* operands() const { return _operands; } | 174 Array<u2>* operands() const { return _operands; } |
180 | 175 |
181 bool has_pseudo_string() const { return flag_at(FB_has_pseudo_string); } | 176 bool has_preresolution() const { return (_flags & _has_preresolution) != 0; } |
182 bool has_invokedynamic() const { return flag_at(FB_has_invokedynamic); } | 177 void set_has_preresolution() { _flags |= _has_preresolution; } |
183 bool has_preresolution() const { return flag_at(FB_has_preresolution); } | |
184 void set_pseudo_string() { set_flag_at(FB_has_pseudo_string); } | |
185 void set_invokedynamic() { set_flag_at(FB_has_invokedynamic); } | |
186 void set_preresolution() { set_flag_at(FB_has_preresolution); } | |
187 | 178 |
188 // Redefine classes support. If a method refering to this constant pool | 179 // Redefine classes support. If a method refering to this constant pool |
189 // is on the executing stack, or as a handle in vm code, this constant pool | 180 // is on the executing stack, or as a handle in vm code, this constant pool |
190 // can't be removed from the set of previous versions saved in the instance | 181 // can't be removed from the set of previous versions saved in the instance |
191 // class. | 182 // class. |
192 bool on_stack() const { return _on_stack; } | 183 bool on_stack() const { return (_flags &_on_stack) != 0; } |
193 void set_on_stack(const bool value); | 184 void set_on_stack(const bool value); |
194 | 185 |
195 // Klass holding pool | 186 // Klass holding pool |
196 InstanceKlass* pool_holder() const { return _pool_holder; } | 187 InstanceKlass* pool_holder() const { return _pool_holder; } |
197 void set_pool_holder(InstanceKlass* k) { _pool_holder = k; } | 188 void set_pool_holder(InstanceKlass* k) { _pool_holder = k; } |
323 | 314 |
324 void string_at_put(int which, int obj_index, oop str) { | 315 void string_at_put(int which, int obj_index, oop str) { |
325 resolved_references()->obj_at_put(obj_index, str); | 316 resolved_references()->obj_at_put(obj_index, str); |
326 } | 317 } |
327 | 318 |
328 void set_object_tag_at(int which) { | |
329 release_tag_at_put(which, JVM_CONSTANT_Object); | |
330 } | |
331 | |
332 void object_at_put(int which, oop obj) { | |
333 resolved_references()->obj_at_put(cp_to_object_index(which), obj); | |
334 } | |
335 | |
336 // For temporary use while constructing constant pool | 319 // For temporary use while constructing constant pool |
337 void string_index_at_put(int which, int string_index) { | 320 void string_index_at_put(int which, int string_index) { |
338 tag_at_put(which, JVM_CONSTANT_StringIndex); | 321 tag_at_put(which, JVM_CONSTANT_StringIndex); |
339 *int_at_addr(which) = string_index; | 322 *int_at_addr(which) = string_index; |
340 } | 323 } |
428 } | 411 } |
429 | 412 |
430 // Version that can be used before string oop array is created. | 413 // Version that can be used before string oop array is created. |
431 oop uncached_string_at(int which, TRAPS); | 414 oop uncached_string_at(int which, TRAPS); |
432 | 415 |
433 oop object_at(int which) { | |
434 assert(tag_at(which).is_object(), "Corrupted constant pool"); | |
435 int obj_index = cp_to_object_index(which); | |
436 return resolved_references()->obj_at(obj_index); | |
437 } | |
438 | |
439 // 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 |
440 // a String entry. | 417 // a String entry. |
441 // Under EnableInvokeDynamic this can happen if the user patches a live | 418 // Under EnableInvokeDynamic this can happen if the user patches a live |
442 // object into a CONSTANT_String entry of an anonymous class. | 419 // object into a CONSTANT_String entry of an anonymous class. |
443 // Method oops internally created for method handles may also | 420 // Method oops internally created for method handles may also |
453 assert(unresolved_string_at(which) == NULL, "shouldn't have symbol"); | 430 assert(unresolved_string_at(which) == NULL, "shouldn't have symbol"); |
454 oop s = resolved_references()->obj_at(obj_index); | 431 oop s = resolved_references()->obj_at(obj_index); |
455 return s; | 432 return s; |
456 } | 433 } |
457 | 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 | |
458 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) { |
459 assert(EnableInvokeDynamic, ""); | 444 assert(EnableInvokeDynamic, ""); |
460 set_pseudo_string(); // mark header | |
461 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 | |
462 string_at_put(which, obj_index, x); // this works just fine | 447 string_at_put(which, obj_index, x); // this works just fine |
463 } | 448 } |
464 | 449 |
465 // 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 |
466 // earlier string_at call. | 451 // earlier string_at call. |
684 // Tells whether index is within bounds. | 669 // Tells whether index is within bounds. |
685 bool is_within_bounds(int index) const { | 670 bool is_within_bounds(int index) const { |
686 return 0 <= index && index < length(); | 671 return 0 <= index && index < length(); |
687 } | 672 } |
688 | 673 |
674 // Sizing (in words) | |
689 static int header_size() { return sizeof(ConstantPool)/HeapWordSize; } | 675 static int header_size() { return sizeof(ConstantPool)/HeapWordSize; } |
690 static int size(int length) { return align_object_size(header_size() + length); } | 676 static int size(int length) { return align_object_size(header_size() + length); } |
691 int size() const { return size(length()); } | 677 int size() const { return size(length()); } |
678 #if INCLUDE_SERVICES | |
679 void collect_statistics(KlassSizeStats *sz) const; | |
680 #endif | |
692 | 681 |
693 friend class ClassFileParser; | 682 friend class ClassFileParser; |
694 friend class SystemDictionary; | 683 friend class SystemDictionary; |
695 | 684 |
696 // Used by compiler to prevent classloading. | 685 // Used by compiler to prevent classloading. |
783 constantPoolHandle h_this(THREAD, this); | 772 constantPoolHandle h_this(THREAD, this); |
784 copy_cp_to_impl(h_this, start_i, end_i, to_cp, to_i, THREAD); | 773 copy_cp_to_impl(h_this, start_i, end_i, to_cp, to_i, THREAD); |
785 } | 774 } |
786 static void copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i, constantPoolHandle to_cp, int to_i, TRAPS); | 775 static void copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i, constantPoolHandle to_cp, int to_i, TRAPS); |
787 static void copy_entry_to(constantPoolHandle from_cp, int from_i, constantPoolHandle to_cp, int to_i, TRAPS); | 776 static void copy_entry_to(constantPoolHandle from_cp, int from_i, constantPoolHandle to_cp, int to_i, TRAPS); |
777 static void copy_operands(constantPoolHandle from_cp, constantPoolHandle to_cp, TRAPS); | |
788 int find_matching_entry(int pattern_i, constantPoolHandle search_cp, TRAPS); | 778 int find_matching_entry(int pattern_i, constantPoolHandle search_cp, TRAPS); |
789 int version() const { return _saved._version; } | 779 int version() const { return _saved._version; } |
790 void set_version(int version) { _saved._version = version; } | 780 void set_version(int version) { _saved._version = version; } |
791 void increment_and_save_version(int version) { | 781 void increment_and_save_version(int version) { |
792 _saved._version = version >= 0 ? (version + 1) : version; // keep overflow | 782 _saved._version = version >= 0 ? (version + 1) : version; // keep overflow |