< prev index next >

src/hotspot/share/oops/compressedKlass.hpp

Print this page

 90 // _klass_range_start                   _klass_range_end                        encoding end
 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 class CompressedKlassPointers : public AllStatic {
102   friend class VMStructs;
103   friend class ArchiveBuilder;
104 
105   // We use a different narrow Klass pointer geometry depending on
106   // whether we run in standard mode or in compact-object-header-mode.
107 
108   // Narrow klass pointer bits for an unshifted narrow Klass pointer.
109   static constexpr int narrow_klass_pointer_bits_noncoh = 32;
110   static constexpr int narrow_klass_pointer_bits_coh = 22;
111 
112   // Bit size of a narrowKlass
113   static int _narrow_klass_pointer_bits;
114 
115   // The maximum shift values we can use depending on UseCompactObjectHeaders
116   static constexpr int max_shift_noncoh = 3;
117   static constexpr int max_shift_coh = 10;
118 
119   // Maximum shift usable
120   static int _max_shift;
121 
122   // Encoding Base, Encoding Shift
123   static address _base;
124   static int _shift;
125 
126   // Start and end of the Klass Range. Start includes the protection zone if one exists.
127   // Note: guaranteed to be aligned to 1<<shift (klass_alignment_in_bytes)
128   static address _klass_range_start;
129   static address _klass_range_end;
130 

169   // 4) call reserve_address_space_for_compressed_classes() either from CDS initialization or, if CDS is off,
170   //    from metaspace initialization. Reserves space for class space + CDS, attempts to reserve such that
171   //    we later can use a "good" encoding scheme. Reservation is highly CPU-specific.
172   // 5) Initialize the narrow Klass encoding scheme by determining encoding base and shift:
173   //   5a) if CDS=on: Calls initialize_for_given_encoding() with the reservation base from step (4) and the
174   //       CDS-intrinsic setting for shift; here, we don't have any freedom to deviate from the base.
175   //   5b) if CDS=off: Calls initialize() - here, we have more freedom and, if we want, can choose an encoding
176   //       base that differs from the reservation base from step (4). That allows us, e.g., to later use
177   //       zero-based encoding.
178   // 6) ... from now on, we can use base() and shift().
179 
180   // Called right after argument parsing; defines narrow klass pointer geometry limits
181   static void pre_initialize();
182 
183   // The number of bits a narrow Klass pointer has;
184   static int narrow_klass_pointer_bits() { check_init(_narrow_klass_pointer_bits); return _narrow_klass_pointer_bits; }
185 
186   // The maximum possible shift; the actual shift employed later can be smaller (see initialize())
187   static int max_shift()                 { check_init(_max_shift); return _max_shift; }
188 
189   // Returns the maximum allowed klass range size. It is calculated from the length of the encoding range
190   // resulting from the current encoding settings (base, shift), capped to a certain max. value.





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

 90 // _klass_range_start                   _klass_range_end                        encoding end
 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 class CompressedKlassPointers : public AllStatic {
102   friend class VMStructs;
103   friend class ArchiveBuilder;
104 
105   // We use a different narrow Klass pointer geometry depending on
106   // whether we run in standard mode or in compact-object-header-mode.
107 
108   // Narrow klass pointer bits for an unshifted narrow Klass pointer.
109   static constexpr int narrow_klass_pointer_bits_noncoh = 32;
110   static constexpr int narrow_klass_pointer_bits_coh = 19;
111 
112   // Bit size of a narrowKlass
113   static int _narrow_klass_pointer_bits;
114 
115   // The maximum shift values we can use depending on UseCompactObjectHeaders
116   static constexpr int max_shift_noncoh = 3;
117   static constexpr int max_shift_coh = 10;
118 
119   // Maximum shift usable
120   static int _max_shift;
121 
122   // Encoding Base, Encoding Shift
123   static address _base;
124   static int _shift;
125 
126   // Start and end of the Klass Range. Start includes the protection zone if one exists.
127   // Note: guaranteed to be aligned to 1<<shift (klass_alignment_in_bytes)
128   static address _klass_range_start;
129   static address _klass_range_end;
130 

169   // 4) call reserve_address_space_for_compressed_classes() either from CDS initialization or, if CDS is off,
170   //    from metaspace initialization. Reserves space for class space + CDS, attempts to reserve such that
171   //    we later can use a "good" encoding scheme. Reservation is highly CPU-specific.
172   // 5) Initialize the narrow Klass encoding scheme by determining encoding base and shift:
173   //   5a) if CDS=on: Calls initialize_for_given_encoding() with the reservation base from step (4) and the
174   //       CDS-intrinsic setting for shift; here, we don't have any freedom to deviate from the base.
175   //   5b) if CDS=off: Calls initialize() - here, we have more freedom and, if we want, can choose an encoding
176   //       base that differs from the reservation base from step (4). That allows us, e.g., to later use
177   //       zero-based encoding.
178   // 6) ... from now on, we can use base() and shift().
179 
180   // Called right after argument parsing; defines narrow klass pointer geometry limits
181   static void pre_initialize();
182 
183   // The number of bits a narrow Klass pointer has;
184   static int narrow_klass_pointer_bits() { check_init(_narrow_klass_pointer_bits); return _narrow_klass_pointer_bits; }
185 
186   // The maximum possible shift; the actual shift employed later can be smaller (see initialize())
187   static int max_shift()                 { check_init(_max_shift); return _max_shift; }
188 
189   // Returns the maximum encoding range, given the current geometry (narrow klass bit size and shift)
190   static size_t max_encoding_range_size() { return nth_bit(narrow_klass_pointer_bits() + max_shift()); }
191 
192   // For use before pre-initialization
193   static constexpr size_t max_klass_range_size_coh = nth_bit(narrow_klass_pointer_bits_coh + max_shift_coh);
194 
195   // Returns the maximum allowed klass range size.
196   static size_t max_klass_range_size();
197 
198   // Reserve a range of memory that is to contain Klass strucutures which are referenced by narrow Klass IDs.
199   // If optimize_for_zero_base is true, the implementation will attempt to reserve optimized for zero-based encoding.
200   static char* reserve_address_space_for_compressed_classes(size_t size, bool aslr, bool optimize_for_zero_base);
201 
202   // Given a klass range [addr, addr+len) and a given encoding scheme, assert that this scheme covers the range, then
203   // set this encoding scheme. Used by CDS at runtime to re-instate the scheme used to pre-compute klass ids for
204   // archived heap objects. In this case, we don't have the freedom to choose base and shift; they are handed to
205   // us from CDS.
206   // Note: CDS with +UCCP for 32-bit currently unsupported.
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 >