< prev index next >

src/hotspot/share/oops/cpCache.hpp

Print this page

  1 /*
  2  * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

400 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
401 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
402 
403 class ConstantPoolCache: public MetaspaceObj {
404   friend class VMStructs;
405   friend class MetadataFactory;
406  private:
407   // If you add a new field that points to any metaspace object, you
408   // must add this field to ConstantPoolCache::metaspace_pointers_do().
409   int             _length;
410   ConstantPool*   _constant_pool;          // the corresponding constant pool
411 
412   // The following fields need to be modified at runtime, so they cannot be
413   // stored in the ConstantPool, which is read-only.
414   // Array of resolved objects from the constant pool and map from resolved
415   // object index to original constant pool index
416   OopHandle            _resolved_references;
417   Array<u2>*           _reference_map;
418   // The narrowOop pointer to the archived resolved_references. Set at CDS dump
419   // time when caching java heap object is supported.
420   CDS_JAVA_HEAP_ONLY(narrowOop _archived_references;)
421 
422   // Sizing
423   debug_only(friend class ClassVerifier;)
424 
425   // Constructor
426   ConstantPoolCache(int length,
427                     const intStack& inverse_index_map,
428                     const intStack& invokedynamic_inverse_index_map,
429                     const intStack& invokedynamic_references_map);
430 
431   // Initialization
432   void initialize(const intArray& inverse_index_map,
433                   const intArray& invokedynamic_inverse_index_map,
434                   const intArray& invokedynamic_references_map);
435  public:
436   static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
437                                      const intStack& cp_cache_map,
438                                      const intStack& invokedynamic_cp_cache_map,
439                                      const intStack& invokedynamic_references_map, TRAPS);
440 
441   int length() const                      { return _length; }
442   void metaspace_pointers_do(MetaspaceClosure* it);
443   MetaspaceObj::Type type() const         { return ConstantPoolCacheType; }
444 
445   oop  archived_references() NOT_CDS_JAVA_HEAP_RETURN_(NULL);
446   void set_archived_references(oop o) NOT_CDS_JAVA_HEAP_RETURN;

447 
448   inline oop resolved_references();
449   void set_resolved_references(OopHandle s) { _resolved_references = s; }
450   Array<u2>* reference_map() const        { return _reference_map; }
451   void set_reference_map(Array<u2>* o)    { _reference_map = o; }
452 
453   // Assembly code support
454   static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
455 
456   // CDS support
457   void remove_unshareable_info();
458   void verify_just_initialized();
459  private:
460   void walk_entries_for_initialization(bool check_only);
461   void set_length(int length)                    { _length = length; }
462 
463   static int header_size()                       { return sizeof(ConstantPoolCache) / wordSize; }
464   static int size(int length)                    { return align_metadata_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
465  public:
466   int size() const                               { return size(length()); }

  1 /*
  2  * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

400 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
401 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
402 
403 class ConstantPoolCache: public MetaspaceObj {
404   friend class VMStructs;
405   friend class MetadataFactory;
406  private:
407   // If you add a new field that points to any metaspace object, you
408   // must add this field to ConstantPoolCache::metaspace_pointers_do().
409   int             _length;
410   ConstantPool*   _constant_pool;          // the corresponding constant pool
411 
412   // The following fields need to be modified at runtime, so they cannot be
413   // stored in the ConstantPool, which is read-only.
414   // Array of resolved objects from the constant pool and map from resolved
415   // object index to original constant pool index
416   OopHandle            _resolved_references;
417   Array<u2>*           _reference_map;
418   // The narrowOop pointer to the archived resolved_references. Set at CDS dump
419   // time when caching java heap object is supported.
420   CDS_JAVA_HEAP_ONLY(int _archived_references_index;)
421 
422   // Sizing
423   debug_only(friend class ClassVerifier;)
424 
425   // Constructor
426   ConstantPoolCache(int length,
427                     const intStack& inverse_index_map,
428                     const intStack& invokedynamic_inverse_index_map,
429                     const intStack& invokedynamic_references_map);
430 
431   // Initialization
432   void initialize(const intArray& inverse_index_map,
433                   const intArray& invokedynamic_inverse_index_map,
434                   const intArray& invokedynamic_references_map);
435  public:
436   static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
437                                      const intStack& cp_cache_map,
438                                      const intStack& invokedynamic_cp_cache_map,
439                                      const intStack& invokedynamic_references_map, TRAPS);
440 
441   int length() const                      { return _length; }
442   void metaspace_pointers_do(MetaspaceClosure* it);
443   MetaspaceObj::Type type() const         { return ConstantPoolCacheType; }
444 
445   oop  archived_references() NOT_CDS_JAVA_HEAP_RETURN_(NULL);
446   void set_archived_references(oop o) NOT_CDS_JAVA_HEAP_RETURN;
447   void clear_archived_references() NOT_CDS_JAVA_HEAP_RETURN;
448 
449   inline oop resolved_references();
450   void set_resolved_references(OopHandle s) { _resolved_references = s; }
451   Array<u2>* reference_map() const        { return _reference_map; }
452   void set_reference_map(Array<u2>* o)    { _reference_map = o; }
453 
454   // Assembly code support
455   static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
456 
457   // CDS support
458   void remove_unshareable_info();
459   void verify_just_initialized();
460  private:
461   void walk_entries_for_initialization(bool check_only);
462   void set_length(int length)                    { _length = length; }
463 
464   static int header_size()                       { return sizeof(ConstantPoolCache) / wordSize; }
465   static int size(int length)                    { return align_metadata_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
466  public:
467   int size() const                               { return size(length()); }
< prev index next >