< prev index next >

src/hotspot/share/oops/constantPool.hpp

Print this page

 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;

668   constantTag tag_ref_at(int cp_cache_index, Bytecodes::Code code);
669 
670   int to_cp_index(int which, Bytecodes::Code code);
671 
672   // Lookup for entries consisting of (name_index, signature_index)
673   u2 name_ref_index_at(int cp_index);            // ==  low-order jshort of name_and_type_at(cp_index)
674   u2 signature_ref_index_at(int cp_index);       // == high-order jshort of name_and_type_at(cp_index)
675 
676   BasicType basic_type_for_signature_at(int cp_index) const;
677 
678   // Resolve string constants (to prevent allocation during compilation)
679   void resolve_string_constants(TRAPS) {
680     constantPoolHandle h_this(THREAD, this);
681     resolve_string_constants_impl(h_this, CHECK);
682   }
683 
684 #if INCLUDE_CDS
685   // CDS support
686   objArrayOop prepare_resolved_references_for_archiving() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
687   void add_dumped_interned_strings() NOT_CDS_JAVA_HEAP_RETURN;

688   bool maybe_archive_resolved_klass_at(int cp_index);


689   void remove_unshareable_info();
690   void restore_unshareable_info(TRAPS);
691 #endif
692 
693  private:
694   enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
695  public:
696 
697   // Get the tag for a constant, which may involve a constant dynamic
698   constantTag constant_tag_at(int cp_index);
699   // Get the basic type for a constant, which may involve a constant dynamic
700   BasicType basic_type_for_constant_at(int cp_index);
701 
702   // Resolve late bound constants.
703   oop resolve_constant_at(int cp_index, TRAPS) {
704     constantPoolHandle h_this(THREAD, this);
705     return resolve_constant_at_impl(h_this, cp_index, _no_index_sentinel, nullptr, THREAD);
706   }
707 
708   oop resolve_cached_constant_at(int cache_index, TRAPS) {

 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;

672   constantTag tag_ref_at(int cp_cache_index, Bytecodes::Code code);
673 
674   int to_cp_index(int which, Bytecodes::Code code);
675 
676   // Lookup for entries consisting of (name_index, signature_index)
677   u2 name_ref_index_at(int cp_index);            // ==  low-order jshort of name_and_type_at(cp_index)
678   u2 signature_ref_index_at(int cp_index);       // == high-order jshort of name_and_type_at(cp_index)
679 
680   BasicType basic_type_for_signature_at(int cp_index) const;
681 
682   // Resolve string constants (to prevent allocation during compilation)
683   void resolve_string_constants(TRAPS) {
684     constantPoolHandle h_this(THREAD, this);
685     resolve_string_constants_impl(h_this, CHECK);
686   }
687 
688 #if INCLUDE_CDS
689   // CDS support
690   objArrayOop prepare_resolved_references_for_archiving() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
691   void add_dumped_interned_strings() NOT_CDS_JAVA_HEAP_RETURN;
692   bool can_archive_invokehandle(ResolvedMethodEntry* rme);
693   bool maybe_archive_resolved_klass_at(int cp_index);
694   bool can_archive_resolved_method(ResolvedMethodEntry* method_entry);
695   void archive_entries();
696   void remove_unshareable_info();
697   void restore_unshareable_info(TRAPS);
698 #endif
699 
700  private:
701   enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
702  public:
703 
704   // Get the tag for a constant, which may involve a constant dynamic
705   constantTag constant_tag_at(int cp_index);
706   // Get the basic type for a constant, which may involve a constant dynamic
707   BasicType basic_type_for_constant_at(int cp_index);
708 
709   // Resolve late bound constants.
710   oop resolve_constant_at(int cp_index, TRAPS) {
711     constantPoolHandle h_this(THREAD, this);
712     return resolve_constant_at_impl(h_this, cp_index, _no_index_sentinel, nullptr, THREAD);
713   }
714 
715   oop resolve_cached_constant_at(int cache_index, TRAPS) {
< prev index next >