91 Array<u2>* _operands; // for variable-sized (InvokeDynamic) nodes, usually empty
92
93 // Consider using an array of compressed klass pointers to
94 // save space on 64-bit platforms.
95 Array<Klass*>* _resolved_klasses;
96
97 u2 _major_version; // major version number of class file
98 u2 _minor_version; // minor version number of class file
99
100 // Constant pool index to the utf8 entry of the Generic signature,
101 // or 0 if none.
102 u2 _generic_signature_index;
103 // Constant pool index to the utf8 entry for the name of source file
104 // containing this klass, 0 if not specified.
105 u2 _source_file_name_index;
106
107 enum {
108 _has_preresolution = 1, // Flags
109 _on_stack = 2,
110 _is_shared = 4,
111 _has_dynamic_constant = 8
112 };
113
114 u2 _flags; // old fashioned bit twiddling
115
116 int _length; // number of elements in the array
117
118 union {
119 // set for CDS to restore resolved references
120 int _resolved_reference_length;
121 // keeps version number for redefined classes (used in backtrace)
122 int _version;
123 } _saved;
124
125 void set_tags(Array<u1>* tags) { _tags = tags; }
126 void tag_at_put(int cp_index, jbyte t) { tags()->at_put(cp_index, t); }
127 void release_tag_at_put(int cp_index, jbyte t) { tags()->release_at_put(cp_index, t); }
128
129 u1* tag_addr_at(int cp_index) const { return tags()->adr_at(cp_index); }
130
131 void set_operands(Array<u2>* operands) { _operands = operands; }
198 }
199 u2 source_file_name_index() const { return _source_file_name_index; }
200 void set_source_file_name_index(u2 sourcefile_index) { _source_file_name_index = sourcefile_index; }
201
202 void copy_fields(const ConstantPool* orig);
203
204 // Redefine classes support. If a method referring to this constant pool
205 // is on the executing stack, or as a handle in vm code, this constant pool
206 // can't be removed from the set of previous versions saved in the instance
207 // class.
208 bool on_stack() const;
209 bool is_maybe_on_stack() const;
210 void set_on_stack(const bool value);
211
212 // Faster than MetaspaceObj::is_shared() - used by set_on_stack()
213 bool is_shared() const { return (_flags & _is_shared) != 0; }
214
215 bool has_dynamic_constant() const { return (_flags & _has_dynamic_constant) != 0; }
216 void set_has_dynamic_constant() { _flags |= _has_dynamic_constant; }
217
218 // Klass holding pool
219 InstanceKlass* pool_holder() const { return _pool_holder; }
220 void set_pool_holder(InstanceKlass* k) { _pool_holder = k; }
221 InstanceKlass** pool_holder_addr() { return &_pool_holder; }
222
223 // Interpreter runtime support
224 ConstantPoolCache* cache() const { return _cache; }
225 void set_cache(ConstantPoolCache* cache){ _cache = cache; }
226
227 virtual void metaspace_pointers_do(MetaspaceClosure* iter);
228 virtual MetaspaceObj::Type type() const { return ConstantPoolType; }
229
230 // Create object cache in the constant pool
231 void initialize_resolved_references(ClassLoaderData* loader_data,
232 const intStack& reference_map,
233 int constant_pool_map_length,
234 TRAPS);
235
236 // resolved strings, methodHandles and callsite objects from the constant pool
237 objArrayOop resolved_references() const;
644
645 // Lookup for entries consisting of (klass_index, name_and_type index)
646 Klass* klass_ref_at(int which, Bytecodes::Code code, TRAPS);
647 Symbol* klass_ref_at_noresolve(int which, Bytecodes::Code code);
648 Symbol* name_ref_at(int which, Bytecodes::Code code) {
649 int name_index = name_ref_index_at(name_and_type_ref_index_at(which, code));
650 return symbol_at(name_index);
651 }
652 Symbol* signature_ref_at(int which, Bytecodes::Code code) {
653 int signature_index = signature_ref_index_at(name_and_type_ref_index_at(which, code));
654 return symbol_at(signature_index);
655 }
656
657 u2 klass_ref_index_at(int which, Bytecodes::Code code);
658 u2 name_and_type_ref_index_at(int which, Bytecodes::Code code);
659
660 constantTag tag_ref_at(int cp_cache_index, Bytecodes::Code code);
661
662 int to_cp_index(int which, Bytecodes::Code code);
663
664 // Lookup for entries consisting of (name_index, signature_index)
665 u2 name_ref_index_at(int cp_index); // == low-order jshort of name_and_type_at(cp_index)
666 u2 signature_ref_index_at(int cp_index); // == high-order jshort of name_and_type_at(cp_index)
667
668 BasicType basic_type_for_signature_at(int cp_index) const;
669
670 // Resolve string constants (to prevent allocation during compilation)
671 void resolve_string_constants(TRAPS) {
672 constantPoolHandle h_this(THREAD, this);
673 resolve_string_constants_impl(h_this, CHECK);
674 }
675
676 #if INCLUDE_CDS
677 // CDS support
678 objArrayOop prepare_resolved_references_for_archiving() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
679 void add_dumped_interned_strings() NOT_CDS_JAVA_HEAP_RETURN;
680 bool maybe_archive_resolved_klass_at(int cp_index);
681 void remove_unshareable_info();
682 void restore_unshareable_info(TRAPS);
683 #endif
684
685 private:
686 enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
687 public:
688
689 // Get the tag for a constant, which may involve a constant dynamic
690 constantTag constant_tag_at(int cp_index);
691 // Get the basic type for a constant, which may involve a constant dynamic
692 BasicType basic_type_for_constant_at(int cp_index);
693
694 // Resolve late bound constants.
695 oop resolve_constant_at(int cp_index, TRAPS) {
696 constantPoolHandle h_this(THREAD, this);
697 return resolve_constant_at_impl(h_this, cp_index, _no_index_sentinel, nullptr, THREAD);
698 }
699
700 oop resolve_cached_constant_at(int cache_index, TRAPS) {
701 constantPoolHandle h_this(THREAD, this);
702 return resolve_constant_at_impl(h_this, _no_index_sentinel, cache_index, nullptr, THREAD);
|
91 Array<u2>* _operands; // for variable-sized (InvokeDynamic) nodes, usually empty
92
93 // Consider using an array of compressed klass pointers to
94 // save space on 64-bit platforms.
95 Array<Klass*>* _resolved_klasses;
96
97 u2 _major_version; // major version number of class file
98 u2 _minor_version; // minor version number of class file
99
100 // Constant pool index to the utf8 entry of the Generic signature,
101 // or 0 if none.
102 u2 _generic_signature_index;
103 // Constant pool index to the utf8 entry for the name of source file
104 // containing this klass, 0 if not specified.
105 u2 _source_file_name_index;
106
107 enum {
108 _has_preresolution = 1, // Flags
109 _on_stack = 2,
110 _is_shared = 4,
111 _has_dynamic_constant = 8,
112 _is_for_method_handle_intrinsic = 16
113 };
114
115 u2 _flags; // old fashioned bit twiddling
116
117 int _length; // number of elements in the array
118
119 union {
120 // set for CDS to restore resolved references
121 int _resolved_reference_length;
122 // keeps version number for redefined classes (used in backtrace)
123 int _version;
124 } _saved;
125
126 void set_tags(Array<u1>* tags) { _tags = tags; }
127 void tag_at_put(int cp_index, jbyte t) { tags()->at_put(cp_index, t); }
128 void release_tag_at_put(int cp_index, jbyte t) { tags()->release_at_put(cp_index, t); }
129
130 u1* tag_addr_at(int cp_index) const { return tags()->adr_at(cp_index); }
131
132 void set_operands(Array<u2>* operands) { _operands = operands; }
199 }
200 u2 source_file_name_index() const { return _source_file_name_index; }
201 void set_source_file_name_index(u2 sourcefile_index) { _source_file_name_index = sourcefile_index; }
202
203 void copy_fields(const ConstantPool* orig);
204
205 // Redefine classes support. If a method referring to this constant pool
206 // is on the executing stack, or as a handle in vm code, this constant pool
207 // can't be removed from the set of previous versions saved in the instance
208 // class.
209 bool on_stack() const;
210 bool is_maybe_on_stack() const;
211 void set_on_stack(const bool value);
212
213 // Faster than MetaspaceObj::is_shared() - used by set_on_stack()
214 bool is_shared() const { return (_flags & _is_shared) != 0; }
215
216 bool has_dynamic_constant() const { return (_flags & _has_dynamic_constant) != 0; }
217 void set_has_dynamic_constant() { _flags |= _has_dynamic_constant; }
218
219 bool is_for_method_handle_intrinsic() const { return (_flags & _is_for_method_handle_intrinsic) != 0; }
220 void set_is_for_method_handle_intrinsic() { _flags |= _is_for_method_handle_intrinsic; }
221
222 // Klass holding pool
223 InstanceKlass* pool_holder() const { return _pool_holder; }
224 void set_pool_holder(InstanceKlass* k) { _pool_holder = k; }
225 InstanceKlass** pool_holder_addr() { return &_pool_holder; }
226
227 // Interpreter runtime support
228 ConstantPoolCache* cache() const { return _cache; }
229 void set_cache(ConstantPoolCache* cache){ _cache = cache; }
230
231 virtual void metaspace_pointers_do(MetaspaceClosure* iter);
232 virtual MetaspaceObj::Type type() const { return ConstantPoolType; }
233
234 // Create object cache in the constant pool
235 void initialize_resolved_references(ClassLoaderData* loader_data,
236 const intStack& reference_map,
237 int constant_pool_map_length,
238 TRAPS);
239
240 // resolved strings, methodHandles and callsite objects from the constant pool
241 objArrayOop resolved_references() const;
648
649 // Lookup for entries consisting of (klass_index, name_and_type index)
650 Klass* klass_ref_at(int which, Bytecodes::Code code, TRAPS);
651 Symbol* klass_ref_at_noresolve(int which, Bytecodes::Code code);
652 Symbol* name_ref_at(int which, Bytecodes::Code code) {
653 int name_index = name_ref_index_at(name_and_type_ref_index_at(which, code));
654 return symbol_at(name_index);
655 }
656 Symbol* signature_ref_at(int which, Bytecodes::Code code) {
657 int signature_index = signature_ref_index_at(name_and_type_ref_index_at(which, code));
658 return symbol_at(signature_index);
659 }
660
661 u2 klass_ref_index_at(int which, Bytecodes::Code code);
662 u2 name_and_type_ref_index_at(int which, Bytecodes::Code code);
663
664 constantTag tag_ref_at(int cp_cache_index, Bytecodes::Code code);
665
666 int to_cp_index(int which, Bytecodes::Code code);
667
668 bool is_resolved(int which, Bytecodes::Code code);
669
670 // Lookup for entries consisting of (name_index, signature_index)
671 u2 name_ref_index_at(int cp_index); // == low-order jshort of name_and_type_at(cp_index)
672 u2 signature_ref_index_at(int cp_index); // == high-order jshort of name_and_type_at(cp_index)
673
674 BasicType basic_type_for_signature_at(int cp_index) const;
675
676 // Resolve string constants (to prevent allocation during compilation)
677 void resolve_string_constants(TRAPS) {
678 constantPoolHandle h_this(THREAD, this);
679 resolve_string_constants_impl(h_this, CHECK);
680 }
681
682 #if INCLUDE_CDS
683 // CDS support
684 objArrayOop prepare_resolved_references_for_archiving() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
685 void add_dumped_interned_strings() NOT_CDS_JAVA_HEAP_RETURN;
686 bool can_archive_invokehandle(ResolvedMethodEntry* rme);
687 bool can_archive_resolved_method(ResolvedMethodEntry* method_entry);
688 void remove_unshareable_info();
689 void remove_unshareable_entries();
690 void restore_unshareable_info(TRAPS);
691 private:
692 void remove_resolved_klass_if_non_deterministic(int cp_index);
693 void remove_resolved_field_entries_if_non_deterministic();
694 void remove_resolved_method_entries_if_non_deterministic();
695 void remove_resolved_indy_entries_if_non_deterministic();
696 #endif
697
698 private:
699 enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
700 public:
701
702 // Get the tag for a constant, which may involve a constant dynamic
703 constantTag constant_tag_at(int cp_index);
704 // Get the basic type for a constant, which may involve a constant dynamic
705 BasicType basic_type_for_constant_at(int cp_index);
706
707 // Resolve late bound constants.
708 oop resolve_constant_at(int cp_index, TRAPS) {
709 constantPoolHandle h_this(THREAD, this);
710 return resolve_constant_at_impl(h_this, cp_index, _no_index_sentinel, nullptr, THREAD);
711 }
712
713 oop resolve_cached_constant_at(int cache_index, TRAPS) {
714 constantPoolHandle h_this(THREAD, this);
715 return resolve_constant_at_impl(h_this, _no_index_sentinel, cache_index, nullptr, THREAD);
|