< prev index next >

src/hotspot/share/cds/archiveBuilder.hpp

Print this page

 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  *
 23  */
 24 
 25 #ifndef SHARE_CDS_ARCHIVEBUILDER_HPP
 26 #define SHARE_CDS_ARCHIVEBUILDER_HPP
 27 
 28 #include "cds/archiveUtils.hpp"
 29 #include "cds/dumpAllocStats.hpp"

 30 #include "memory/metaspaceClosure.hpp"
 31 #include "oops/array.hpp"
 32 #include "oops/klass.hpp"
 33 #include "runtime/os.hpp"
 34 #include "utilities/bitMap.hpp"
 35 #include "utilities/growableArray.hpp"
 36 #include "utilities/resizeableResourceHash.hpp"
 37 #include "utilities/resourceHash.hpp"
 38 
 39 class ArchiveHeapInfo;
 40 class CHeapBitMap;
 41 class FileMapInfo;
 42 class Klass;
 43 class MemRegion;
 44 class Symbol;
 45 
 46 // Metaspace::allocate() requires that all blocks must be aligned with KlassAlignmentInBytes.
 47 // We enforce the same alignment rule in blocks allocated from the shared space.
 48 const int SharedSpaceObjectAlignment = KlassAlignmentInBytes;
 49 
 50 // Overview of CDS archive creation (for both static and dynamic dump):
 51 //
 52 // [1] Load all classes (static dump: from the classlist, dynamic dump: as part of app execution)
 53 // [2] Allocate "output buffer"
 54 // [3] Copy contents of the 2 "core" regions (rw/ro) into the output buffer.
 55 //       - allocate the cpp vtables in rw (static dump only)
 56 //       - memcpy the MetaspaceObjs into rw/ro:
 57 //         dump_rw_region();
 58 //         dump_ro_region();
 59 //       - fix all the pointers in the MetaspaceObjs to point to the copies
 60 //         relocate_metaspaceobj_embedded_pointers()
 61 // [4] Copy symbol table, dictionary, etc, into the ro region
 62 // [5] Relocate all the pointers in rw/ro, so that the archive can be mapped to
 63 //     the "requested" location without runtime relocation. See relocate_to_requested()
 64 //
 65 // "source" vs "buffered" vs "requested"
 66 //
 67 // The ArchiveBuilder deals with three types of addresses.
 68 //

441   }
442 
443   static CompactHashtableStats* string_stats() {
444     return alloc_stats()->string_stats();
445   }
446 
447   narrowKlass get_requested_narrow_klass(Klass* k);
448 
449   static Klass* get_buffered_klass(Klass* src_klass) {
450     Klass* klass = (Klass*)current()->get_buffered_addr((address)src_klass);
451     assert(klass != nullptr && klass->is_klass(), "must be");
452     return klass;
453   }
454 
455   static Symbol* get_buffered_symbol(Symbol* src_symbol) {
456     return (Symbol*)current()->get_buffered_addr((address)src_symbol);
457   }
458 
459   void print_stats();
460   void report_out_of_space(const char* name, size_t needed_bytes);



















461 };
462 
463 #endif // SHARE_CDS_ARCHIVEBUILDER_HPP

 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  *
 23  */
 24 
 25 #ifndef SHARE_CDS_ARCHIVEBUILDER_HPP
 26 #define SHARE_CDS_ARCHIVEBUILDER_HPP
 27 
 28 #include "cds/archiveUtils.hpp"
 29 #include "cds/dumpAllocStats.hpp"
 30 #include "memory/metaspace.hpp"
 31 #include "memory/metaspaceClosure.hpp"
 32 #include "oops/array.hpp"
 33 #include "oops/klass.hpp"
 34 #include "runtime/os.hpp"
 35 #include "utilities/bitMap.hpp"
 36 #include "utilities/growableArray.hpp"
 37 #include "utilities/resizeableResourceHash.hpp"
 38 #include "utilities/resourceHash.hpp"
 39 
 40 class ArchiveHeapInfo;
 41 class CHeapBitMap;
 42 class FileMapInfo;
 43 class Klass;
 44 class MemRegion;
 45 class Symbol;
 46 
 47 // The minimum alignment for non-Klass objects inside the CDS archive. Klass objects need
 48 // to follow CompressedKlassPointers::klass_alignment_in_bytes().
 49 constexpr size_t SharedSpaceObjectAlignment = Metaspace::min_allocation_alignment_bytes;
 50 
 51 // Overview of CDS archive creation (for both static and dynamic dump):
 52 //
 53 // [1] Load all classes (static dump: from the classlist, dynamic dump: as part of app execution)
 54 // [2] Allocate "output buffer"
 55 // [3] Copy contents of the 2 "core" regions (rw/ro) into the output buffer.
 56 //       - allocate the cpp vtables in rw (static dump only)
 57 //       - memcpy the MetaspaceObjs into rw/ro:
 58 //         dump_rw_region();
 59 //         dump_ro_region();
 60 //       - fix all the pointers in the MetaspaceObjs to point to the copies
 61 //         relocate_metaspaceobj_embedded_pointers()
 62 // [4] Copy symbol table, dictionary, etc, into the ro region
 63 // [5] Relocate all the pointers in rw/ro, so that the archive can be mapped to
 64 //     the "requested" location without runtime relocation. See relocate_to_requested()
 65 //
 66 // "source" vs "buffered" vs "requested"
 67 //
 68 // The ArchiveBuilder deals with three types of addresses.
 69 //

442   }
443 
444   static CompactHashtableStats* string_stats() {
445     return alloc_stats()->string_stats();
446   }
447 
448   narrowKlass get_requested_narrow_klass(Klass* k);
449 
450   static Klass* get_buffered_klass(Klass* src_klass) {
451     Klass* klass = (Klass*)current()->get_buffered_addr((address)src_klass);
452     assert(klass != nullptr && klass->is_klass(), "must be");
453     return klass;
454   }
455 
456   static Symbol* get_buffered_symbol(Symbol* src_symbol) {
457     return (Symbol*)current()->get_buffered_addr((address)src_symbol);
458   }
459 
460   void print_stats();
461   void report_out_of_space(const char* name, size_t needed_bytes);
462 
463 #ifdef _LP64
464   // Archived heap object headers (and soon, with Lilliput, markword prototypes) carry pre-computed
465   // narrow Klass ids calculated with the following scheme:
466   // 1) the encoding base must be the mapping start address.
467   // 2) shift must be large enough to result in an encoding range that covers the runtime Klass range.
468   //    That Klass range is defined by CDS archive size and runtime class space size. Luckily, the maximum
469   //    size can be predicted: archive size is assumed to be <1G, class space size capped at 3G, and at
470   //    runtime we put both regions adjacent to each other. Therefore, runtime Klass range size < 4G.
471   // The value of this precomputed shift depends on the class pointer mode at dump time.
472   // Legacy Mode:
473   //    Since nKlass itself is 32 bit, our encoding range len is 4G, and since we set the base directly
474   //    at mapping start, these 4G are enough. Therefore, we don't need to shift at all (shift=0).
475   // TinyClassPointer Mode:
476   //    To cover the 4G, we need the highest possible shift value. That may change in the future, if
477   //    we decide to correct the pre-calculated narrow Klass IDs at load time.
478   static int precomputed_narrow_klass_shift();
479 #endif // _LP64
480 
481 };
482 
483 #endif // SHARE_CDS_ARCHIVEBUILDER_HPP
< prev index next >