< prev index next >

src/hotspot/share/oops/compressedKlass.hpp

Print this page

 91 //   |//////////|///////////////////////////|                                         |
 92 //   |///CDS////|////1gb class space////////|            ...    ...                   |
 93 //   |//////////|///////////////////////////|                                         |
 94 //   |                                      |                                         |
 95 // 0x8_0000_0000                      0x8_4800_0000                            0x9_0000_0000
 96 //
 97 
 98 // If compressed klass pointers then use narrowKlass.
 99 typedef juint  narrowKlass;
100 
101 // For UseCompressedClassPointers.
102 class CompressedKlassPointers : public AllStatic {
103   friend class VMStructs;
104   friend class ArchiveBuilder;
105 
106   // We use a different narrow Klass pointer geometry depending on
107   // whether we run in standard mode or in compact-object-header-mode.
108 
109   // Narrow klass pointer bits for an unshifted narrow Klass pointer.
110   static constexpr int narrow_klass_pointer_bits_noncoh = 32;
111   static constexpr int narrow_klass_pointer_bits_coh = 22;
112 
113   // Bit size of a narrowKlass
114   static int _narrow_klass_pointer_bits;
115 
116   // The maximum shift values we can use depending on UseCompactObjectHeaders
117   static constexpr int max_shift_noncoh = 3;
118   static constexpr int max_shift_coh = 10;
119 
120   // Maximum shift usable
121   static int _max_shift;
122 
123   // Encoding Base, Encoding Shift
124   static address _base;
125   static int _shift;
126 
127   // Start and end of the Klass Range.
128   // Note: guaranteed to be aligned to 1<<shift (klass_alignment_in_bytes)
129   static address _klass_range_start;
130   static address _klass_range_end;
131 

173   // 5) Initialize the narrow Klass encoding scheme by determining encoding base and shift:
174   //   5a) if CDS=on: Calls initialize_for_given_encoding() with the reservation base from step (4) and the
175   //       CDS-intrinsic setting for shift; here, we don't have any freedom to deviate from the base.
176   //   5b) if CDS=off: Calls initialize() - here, we have more freedom and, if we want, can choose an encoding
177   //       base that differs from the reservation base from step (4). That allows us, e.g., to later use
178   //       zero-based encoding.
179   // 6) ... from now on, we can use base() and shift().
180 
181   // Called right after argument parsing; defines narrow klass pointer geometry limits
182   static void pre_initialize();
183 
184   // The number of bits a narrow Klass pointer has;
185   static int narrow_klass_pointer_bits() { check_init(_narrow_klass_pointer_bits); return _narrow_klass_pointer_bits; }
186 
187   // The maximum possible shift; the actual shift employed later can be smaller (see initialize())
188   static int max_shift()                 { check_init(_max_shift); return _max_shift; }
189 
190   // Returns the maximum encoding range, given the current geometry (narrow klass bit size and shift)
191   static size_t max_encoding_range_size() { return nth_bit(narrow_klass_pointer_bits() + max_shift()); }
192 



193   // Returns the maximum allowed klass range size.
194   static size_t max_klass_range_size();
195 
196   // Reserve a range of memory that is to contain Klass strucutures which are referenced by narrow Klass IDs.
197   // If optimize_for_zero_base is true, the implementation will attempt to reserve optimized for zero-based encoding.
198   static char* reserve_address_space_for_compressed_classes(size_t size, bool aslr, bool optimize_for_zero_base);
199 
200   // Given a klass range [addr, addr+len) and a given encoding scheme, assert that this scheme covers the range, then
201   // set this encoding scheme. Used by CDS at runtime to re-instate the scheme used to pre-compute klass ids for
202   // archived heap objects. In this case, we don't have the freedom to choose base and shift; they are handed to
203   // us from CDS.
204   static void initialize_for_given_encoding(address addr, size_t len, address requested_base, int requested_shift);
205 
206   // Given an address range [addr, addr+len) which the encoding is supposed to
207   //  cover, choose base, shift and range.
208   //  The address range is the expected range of uncompressed Klass pointers we
209   //  will encounter (and the implicit promise that there will be no Klass
210   //  structures outside this range).
211   static void initialize(address addr, size_t len);
212 

 91 //   |//////////|///////////////////////////|                                         |
 92 //   |///CDS////|////1gb class space////////|            ...    ...                   |
 93 //   |//////////|///////////////////////////|                                         |
 94 //   |                                      |                                         |
 95 // 0x8_0000_0000                      0x8_4800_0000                            0x9_0000_0000
 96 //
 97 
 98 // If compressed klass pointers then use narrowKlass.
 99 typedef juint  narrowKlass;
100 
101 // For UseCompressedClassPointers.
102 class CompressedKlassPointers : public AllStatic {
103   friend class VMStructs;
104   friend class ArchiveBuilder;
105 
106   // We use a different narrow Klass pointer geometry depending on
107   // whether we run in standard mode or in compact-object-header-mode.
108 
109   // Narrow klass pointer bits for an unshifted narrow Klass pointer.
110   static constexpr int narrow_klass_pointer_bits_noncoh = 32;
111   static constexpr int narrow_klass_pointer_bits_coh = 19;
112 
113   // Bit size of a narrowKlass
114   static int _narrow_klass_pointer_bits;
115 
116   // The maximum shift values we can use depending on UseCompactObjectHeaders
117   static constexpr int max_shift_noncoh = 3;
118   static constexpr int max_shift_coh = 10;
119 
120   // Maximum shift usable
121   static int _max_shift;
122 
123   // Encoding Base, Encoding Shift
124   static address _base;
125   static int _shift;
126 
127   // Start and end of the Klass Range.
128   // Note: guaranteed to be aligned to 1<<shift (klass_alignment_in_bytes)
129   static address _klass_range_start;
130   static address _klass_range_end;
131 

173   // 5) Initialize the narrow Klass encoding scheme by determining encoding base and shift:
174   //   5a) if CDS=on: Calls initialize_for_given_encoding() with the reservation base from step (4) and the
175   //       CDS-intrinsic setting for shift; here, we don't have any freedom to deviate from the base.
176   //   5b) if CDS=off: Calls initialize() - here, we have more freedom and, if we want, can choose an encoding
177   //       base that differs from the reservation base from step (4). That allows us, e.g., to later use
178   //       zero-based encoding.
179   // 6) ... from now on, we can use base() and shift().
180 
181   // Called right after argument parsing; defines narrow klass pointer geometry limits
182   static void pre_initialize();
183 
184   // The number of bits a narrow Klass pointer has;
185   static int narrow_klass_pointer_bits() { check_init(_narrow_klass_pointer_bits); return _narrow_klass_pointer_bits; }
186 
187   // The maximum possible shift; the actual shift employed later can be smaller (see initialize())
188   static int max_shift()                 { check_init(_max_shift); return _max_shift; }
189 
190   // Returns the maximum encoding range, given the current geometry (narrow klass bit size and shift)
191   static size_t max_encoding_range_size() { return nth_bit(narrow_klass_pointer_bits() + max_shift()); }
192 
193   // For use before pre-initialization
194   static constexpr size_t max_klass_range_size_coh = nth_bit(narrow_klass_pointer_bits_coh + max_shift_coh);
195 
196   // Returns the maximum allowed klass range size.
197   static size_t max_klass_range_size();
198 
199   // Reserve a range of memory that is to contain Klass strucutures which are referenced by narrow Klass IDs.
200   // If optimize_for_zero_base is true, the implementation will attempt to reserve optimized for zero-based encoding.
201   static char* reserve_address_space_for_compressed_classes(size_t size, bool aslr, bool optimize_for_zero_base);
202 
203   // Given a klass range [addr, addr+len) and a given encoding scheme, assert that this scheme covers the range, then
204   // set this encoding scheme. Used by CDS at runtime to re-instate the scheme used to pre-compute klass ids for
205   // archived heap objects. In this case, we don't have the freedom to choose base and shift; they are handed to
206   // us from CDS.
207   static void initialize_for_given_encoding(address addr, size_t len, address requested_base, int requested_shift);
208 
209   // Given an address range [addr, addr+len) which the encoding is supposed to
210   //  cover, choose base, shift and range.
211   //  The address range is the expected range of uncompressed Klass pointers we
212   //  will encounter (and the implicit promise that there will be no Klass
213   //  structures outside this range).
214   static void initialize(address addr, size_t len);
215 
< prev index next >