< prev index next >

src/share/vm/oops/cpCache.hpp

Print this page


 385 
 386   static void verify_tos_state_shift() {
 387     // When shifting flags as a 32-bit int, make sure we don't need an extra mask for tos_state:
 388     assert((((u4)-1 >> tos_state_shift) & ~tos_state_mask) == 0, "no need for tos_state mask");
 389   }
 390 };
 391 
 392 
 393 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache
 394 // holds interpreter runtime information for all field access and invoke bytecodes. The cache
 395 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
 396 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
 397 
 398 class ConstantPoolCache: public MetaspaceObj {
 399   friend class VMStructs;
 400   friend class MetadataFactory;
 401  private:
 402   int             _length;
 403   ConstantPool*   _constant_pool;          // the corresponding constant pool
 404 







 405   // Sizing
 406   debug_only(friend class ClassVerifier;)
 407 
 408   // Constructor
 409   ConstantPoolCache(int length,
 410                     const intStack& inverse_index_map,
 411                     const intStack& invokedynamic_inverse_index_map,
 412                     const intStack& invokedynamic_references_map) :
 413                           _length(length),
 414                           _constant_pool(NULL) {
 415     initialize(inverse_index_map, invokedynamic_inverse_index_map,
 416                invokedynamic_references_map);
 417     for (int i = 0; i < length; i++) {
 418       assert(entry_at(i)->is_f1_null(), "Failed to clear?");
 419     }
 420   }
 421 
 422   // Initialization
 423   void initialize(const intArray& inverse_index_map,
 424                   const intArray& invokedynamic_inverse_index_map,
 425                   const intArray& invokedynamic_references_map);
 426  public:
 427   static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
 428                                      const intStack& cp_cache_map,
 429                                      const intStack& invokedynamic_cp_cache_map,
 430                                      const intStack& invokedynamic_references_map, TRAPS);
 431   bool is_constantPoolCache() const { return true; }
 432 
 433   int length() const                             { return _length; }









 434  private:
 435   void set_length(int length)                    { _length = length; }
 436 
 437   static int header_size()                       { return sizeof(ConstantPoolCache) / wordSize; }
 438   static int size(int length)                    { return align_metadata_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
 439  public:
 440   int size() const                               { return size(length()); }
 441  private:
 442 
 443   // Helpers
 444   ConstantPool**        constant_pool_addr()     { return &_constant_pool; }
 445   ConstantPoolCacheEntry* base() const           { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); }
 446 
 447   friend class constantPoolCacheKlass;
 448   friend class ConstantPoolCacheEntry;
 449 
 450  public:
 451   // Accessors
 452   void set_constant_pool(ConstantPool* pool)   { _constant_pool = pool; }
 453   ConstantPool* constant_pool() const          { return _constant_pool; }




 385 
 386   static void verify_tos_state_shift() {
 387     // When shifting flags as a 32-bit int, make sure we don't need an extra mask for tos_state:
 388     assert((((u4)-1 >> tos_state_shift) & ~tos_state_mask) == 0, "no need for tos_state mask");
 389   }
 390 };
 391 
 392 
 393 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache
 394 // holds interpreter runtime information for all field access and invoke bytecodes. The cache
 395 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
 396 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
 397 
 398 class ConstantPoolCache: public MetaspaceObj {
 399   friend class VMStructs;
 400   friend class MetadataFactory;
 401  private:
 402   int             _length;
 403   ConstantPool*   _constant_pool;          // the corresponding constant pool
 404 
 405   // The following fields need to be modified at runtime, so they cannot be
 406   // stored in the ConstantPool, which is read-only.
 407   // Array of resolved objects from the constant pool and map from resolved
 408   // object index to original constant pool index
 409   jobject              _resolved_references;
 410   Array<u2>*           _reference_map;
 411 
 412   // Sizing
 413   debug_only(friend class ClassVerifier;)
 414 
 415   // Constructor
 416   ConstantPoolCache(int length,
 417                     const intStack& inverse_index_map,
 418                     const intStack& invokedynamic_inverse_index_map,
 419                     const intStack& invokedynamic_references_map) :
 420                           _length(length),
 421                           _constant_pool(NULL) {
 422     initialize(inverse_index_map, invokedynamic_inverse_index_map,
 423                invokedynamic_references_map);
 424     for (int i = 0; i < length; i++) {
 425       assert(entry_at(i)->is_f1_null(), "Failed to clear?");
 426     }
 427   }
 428 
 429   // Initialization
 430   void initialize(const intArray& inverse_index_map,
 431                   const intArray& invokedynamic_inverse_index_map,
 432                   const intArray& invokedynamic_references_map);
 433  public:
 434   static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
 435                                      const intStack& cp_cache_map,
 436                                      const intStack& invokedynamic_cp_cache_map,
 437                                      const intStack& invokedynamic_references_map, TRAPS);
 438   bool is_constantPoolCache() const { return true; }
 439 
 440   int length() const                             { return _length; }
 441 
 442   jobject resolved_references()           { return _resolved_references; }
 443   void set_resolved_references(jobject s) { _resolved_references = s; }
 444   Array<u2>* reference_map() const        { return _reference_map; }
 445   void set_reference_map(Array<u2>* o)    { _reference_map = o; }
 446 
 447   // Assembly code support
 448   static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
 449 
 450  private:
 451   void set_length(int length)                    { _length = length; }
 452 
 453   static int header_size()                       { return sizeof(ConstantPoolCache) / wordSize; }
 454   static int size(int length)                    { return align_metadata_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
 455  public:
 456   int size() const                               { return size(length()); }
 457  private:
 458 
 459   // Helpers
 460   ConstantPool**        constant_pool_addr()     { return &_constant_pool; }
 461   ConstantPoolCacheEntry* base() const           { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); }
 462 
 463   friend class constantPoolCacheKlass;
 464   friend class ConstantPoolCacheEntry;
 465 
 466  public:
 467   // Accessors
 468   void set_constant_pool(ConstantPool* pool)   { _constant_pool = pool; }
 469   ConstantPool* constant_pool() const          { return _constant_pool; }


< prev index next >