< prev index next >

src/hotspot/share/cds/archiveBuilder.hpp

Print this page
*** 88,10 ***
--- 88,24 ---
  //
  // Translation between "buffered" and "requested" addresses is done with a simple shift:
  //    buffered_address + _buffer_to_requested_delta == requested_address
  //
  class ArchiveBuilder : public StackObj {
+ public:
+   // The archive contains pre-computed narrow Klass IDs in two places:
+   // - in the header of archived java objects (only if the archive contains java heap portions)
+   // - within the prototype markword of archived Klass structures.
+   // These narrow Klass ids have been computed at dump time with the following scheme:
+   // 1) the encoding base must be the mapping start address.
+   // 2) shift must be large enough to result in an encoding range that covers the runtime Klass range.
+   //    That Klass range is defined by CDS archive size and runtime class space size. Luckily, the maximum
+   //    size can be predicted: archive size is assumed to be <1G, class space size capped at 3G, and at
+   //    runtime we put both regions adjacent to each other. Therefore, runtime Klass range size < 4G.
+   //    Since nKlass itself is 32 bit, our encoding range len is 4G, and since we set the base directly
+   //    at mapping start, these 4G are enough. Therefore, we don't need to shift at all (shift=0).
+   static constexpr int precomputed_narrow_klass_shift = 0;
+ 
  protected:
    DumpRegion* _current_dump_space;
    address _buffer_bottom;                      // for writing the contents of rw/ro regions
    address _last_verified_top;
    int _num_dump_regions_used;
< prev index next >