< 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 //

430   }
431 
432   static CompactHashtableStats* string_stats() {
433     return alloc_stats()->string_stats();
434   }
435 
436   narrowKlass get_requested_narrow_klass(Klass* k);
437 
438   static Klass* get_buffered_klass(Klass* src_klass) {
439     Klass* klass = (Klass*)current()->get_buffered_addr((address)src_klass);
440     assert(klass != nullptr && klass->is_klass(), "must be");
441     return klass;
442   }
443 
444   static Symbol* get_buffered_symbol(Symbol* src_symbol) {
445     return (Symbol*)current()->get_buffered_addr((address)src_symbol);
446   }
447 
448   void print_stats();
449   void report_out_of_space(const char* name, size_t needed_bytes);



















450 };
451 
452 #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 //

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