< prev index next >

src/java.base/share/classes/jdk/internal/misc/UnsafeConstants.java

Print this page

 28 
 29 /**
 30  * A class used to expose details of the underlying hardware that
 31  * configure the operation of class Unsafe.  This class is
 32  * package-private as the only intended client is class Unsafe.
 33  * All fields in this class must be static final constants.
 34  *
 35  * @since 13
 36  *
 37  * @implNote
 38  *
 39  * The JVM injects hardware-specific values into all the static fields
 40  * of this class during JVM initialization. The static initialization
 41  * block is executed when the class is initialized then JVM injection
 42  * updates the fields with the correct constants. The static block
 43  * is required to prevent the fields from being considered constant
 44  * variables, so the field values will be not be compiled directly into
 45  * any class that uses them.
 46  */
 47 
 48 final class UnsafeConstants {
 49 
 50     /**
 51      * This constructor is private because the class is not meant to
 52      * be instantiated.
 53      */
 54     private UnsafeConstants() {}
 55 
 56     /**
 57      * The size in bytes of a native pointer, as stored via {@link
 58      * #putAddress}.  This value will be either 4 or 8.  Note that the
 59      * sizes of other primitive types (as stored in native memory
 60      * blocks) is determined fully by their information content.
 61      *
 62      * @implNote
 63      * The actual value for this field is injected by the JVM.
 64      */
 65 
 66     static final int ADDRESS_SIZE0;
 67 
 68     /**

 95 
 96     static final boolean UNALIGNED_ACCESS;
 97 
 98     /**
 99      * The size of an L1 data cache line which will be either a power
100      * of two or zero.
101      *
102      * <p>A non-zero value indicates that writeback to memory is
103      * enabled for the current processor. The value defines the
104      * natural alignment and size of any data cache line committed to
105      * memory by a single writeback operation. If data cache line
106      * writeback is not enabled for the current hardware the field
107      * will have value 0.
108      *
109      * @implNote
110      * The actual value for this field is injected by the JVM.
111      */
112 
113     static final int DATA_CACHE_LINE_FLUSH_SIZE;
114 









115     static {
116         ADDRESS_SIZE0 = 0;
117         PAGE_SIZE = 0;
118         BIG_ENDIAN = false;
119         UNALIGNED_ACCESS = false;
120         DATA_CACHE_LINE_FLUSH_SIZE = 0;

121     }
122 }

 28 
 29 /**
 30  * A class used to expose details of the underlying hardware that
 31  * configure the operation of class Unsafe.  This class is
 32  * package-private as the only intended client is class Unsafe.
 33  * All fields in this class must be static final constants.
 34  *
 35  * @since 13
 36  *
 37  * @implNote
 38  *
 39  * The JVM injects hardware-specific values into all the static fields
 40  * of this class during JVM initialization. The static initialization
 41  * block is executed when the class is initialized then JVM injection
 42  * updates the fields with the correct constants. The static block
 43  * is required to prevent the fields from being considered constant
 44  * variables, so the field values will be not be compiled directly into
 45  * any class that uses them.
 46  */
 47 
 48 public final class UnsafeConstants {
 49 
 50     /**
 51      * This constructor is private because the class is not meant to
 52      * be instantiated.
 53      */
 54     private UnsafeConstants() {}
 55 
 56     /**
 57      * The size in bytes of a native pointer, as stored via {@link
 58      * #putAddress}.  This value will be either 4 or 8.  Note that the
 59      * sizes of other primitive types (as stored in native memory
 60      * blocks) is determined fully by their information content.
 61      *
 62      * @implNote
 63      * The actual value for this field is injected by the JVM.
 64      */
 65 
 66     static final int ADDRESS_SIZE0;
 67 
 68     /**

 95 
 96     static final boolean UNALIGNED_ACCESS;
 97 
 98     /**
 99      * The size of an L1 data cache line which will be either a power
100      * of two or zero.
101      *
102      * <p>A non-zero value indicates that writeback to memory is
103      * enabled for the current processor. The value defines the
104      * natural alignment and size of any data cache line committed to
105      * memory by a single writeback operation. If data cache line
106      * writeback is not enabled for the current hardware the field
107      * will have value 0.
108      *
109      * @implNote
110      * The actual value for this field is injected by the JVM.
111      */
112 
113     static final int DATA_CACHE_LINE_FLUSH_SIZE;
114 
115     /**
116      * The exact log (base 2) of the number of lines in the Scoped cache.
117      *
118      * @implNote
119      * The actual value for this field is injected by the JVM.
120      */
121 
122     public static final int SCOPED_CACHE_SHIFT;
123 
124     static {
125         ADDRESS_SIZE0 = 0;
126         PAGE_SIZE = 0;
127         BIG_ENDIAN = false;
128         UNALIGNED_ACCESS = false;
129         DATA_CACHE_LINE_FLUSH_SIZE = 0;
130         SCOPED_CACHE_SHIFT = -1;
131     }
132 }
< prev index next >