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;
661
662 int to_cp_index(int which, Bytecodes::Code code);
663
664 bool is_resolved(int which, Bytecodes::Code code);
665
666 // Lookup for entries consisting of (name_index, signature_index)
667 u2 name_ref_index_at(int cp_index); // == low-order jshort of name_and_type_at(cp_index)
668 u2 signature_ref_index_at(int cp_index); // == high-order jshort of name_and_type_at(cp_index)
669
670 BasicType basic_type_for_signature_at(int cp_index) const;
671
672 // Resolve string constants (to prevent allocation during compilation)
673 void resolve_string_constants(TRAPS) {
674 constantPoolHandle h_this(THREAD, this);
675 resolve_string_constants_impl(h_this, CHECK);
676 }
677
678 #if INCLUDE_CDS
679 // CDS support
680 objArrayOop prepare_resolved_references_for_archiving() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
681 void add_dumped_interned_strings() NOT_CDS_JAVA_HEAP_RETURN;
682 void remove_unshareable_info();
683 void restore_unshareable_info(TRAPS);
684 private:
685 void remove_unshareable_entries();
686 void remove_resolved_klass_if_non_deterministic(int cp_index);
687 #endif
688
689 private:
690 enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
691 public:
692
693 // Get the tag for a constant, which may involve a constant dynamic
694 constantTag constant_tag_at(int cp_index);
695 // Get the basic type for a constant, which may involve a constant dynamic
696 BasicType basic_type_for_constant_at(int cp_index);
697
698 // Resolve late bound constants.
699 oop resolve_constant_at(int cp_index, TRAPS) {
700 constantPoolHandle h_this(THREAD, this);
701 return resolve_constant_at_impl(h_this, cp_index, _no_index_sentinel, nullptr, THREAD);
702 }
703
704 oop resolve_cached_constant_at(int cache_index, TRAPS) {
705 constantPoolHandle h_this(THREAD, this);
706 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;
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 find_archivable_hidden_classes() NOT_CDS_JAVA_HEAP_RETURN;
686 void add_dumped_interned_strings() NOT_CDS_JAVA_HEAP_RETURN;
687 void remove_unshareable_info();
688 void restore_unshareable_info(TRAPS);
689 private:
690 void remove_unshareable_entries();
691 void remove_resolved_klass_if_non_deterministic(int cp_index);
692 template <typename Function> void iterate_archivable_resolved_references(Function function);
693 #endif
694
695 private:
696 enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
697 public:
698
699 // Get the tag for a constant, which may involve a constant dynamic
700 constantTag constant_tag_at(int cp_index);
701 // Get the basic type for a constant, which may involve a constant dynamic
702 BasicType basic_type_for_constant_at(int cp_index);
703
704 // Resolve late bound constants.
705 oop resolve_constant_at(int cp_index, TRAPS) {
706 constantPoolHandle h_this(THREAD, this);
707 return resolve_constant_at_impl(h_this, cp_index, _no_index_sentinel, nullptr, THREAD);
708 }
709
710 oop resolve_cached_constant_at(int cache_index, TRAPS) {
711 constantPoolHandle h_this(THREAD, this);
712 return resolve_constant_at_impl(h_this, _no_index_sentinel, cache_index, nullptr, THREAD);
|