author | adinn |
Tue, 20 Aug 2019 10:11:53 +0100 | |
changeset 57804 | 9b7b9f16dfd9 |
parent 54439 | d9b46b7de028 |
permissions | -rw-r--r-- |
54439
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
1 |
/* |
57804 | 2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
54439
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
3 |
* Copyright (c) 2019, Red Hat Inc. All rights reserved. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
5 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. Oracle designates this |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
9 |
* particular file as subject to the "Classpath" exception as provided |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
10 |
* by Oracle in the LICENSE file that accompanied this code. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
11 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
12 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
14 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
15 |
* version 2 for more details (a copy is included in the LICENSE file that |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
16 |
* accompanied this code). |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
17 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License version |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
19 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
20 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
21 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
22 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
23 |
* or visit www.oracle.com if you need additional information or have any |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
24 |
* questions. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
25 |
*/ |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
26 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
27 |
package jdk.internal.misc; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
28 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
29 |
/** |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
30 |
* A class used to expose details of the underlying hardware that |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
31 |
* configure the operation of class Unsafe. This class is |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
32 |
* package-private as the only intended client is class Unsafe. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
33 |
* All fields in this class must be static final constants. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
34 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
35 |
* @since 13 |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
36 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
37 |
* @implNote |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
38 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
39 |
* The JVM injects hardware-specific values into all the static fields |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
40 |
* of this class during JVM initialization. The static initialization |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
41 |
* block is executed when the class is initialized then JVM injection |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
42 |
* updates the fields with the correct constants. The static block |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
43 |
* is required to prevent the fields from being considered constant |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
44 |
* variables, so the field values will be not be compiled directly into |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
45 |
* any class that uses them. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
46 |
*/ |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
47 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
48 |
final class UnsafeConstants { |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
49 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
50 |
/** |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
51 |
* This constructor is private because the class is not meant to |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
52 |
* be instantiated. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
53 |
*/ |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
54 |
private UnsafeConstants() {} |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
55 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
56 |
/** |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
57 |
* The size in bytes of a native pointer, as stored via {@link |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
58 |
* #putAddress}. This value will be either 4 or 8. Note that the |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
59 |
* sizes of other primitive types (as stored in native memory |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
60 |
* blocks) is determined fully by their information content. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
61 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
62 |
* @implNote |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
63 |
* The actual value for this field is injected by the JVM. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
64 |
*/ |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
65 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
66 |
static final int ADDRESS_SIZE0; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
67 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
68 |
/** |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
69 |
* The size in bytes of a native memory page (whatever that is). |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
70 |
* This value will always be a power of two. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
71 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
72 |
* @implNote |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
73 |
* The actual value for this field is injected by the JVM. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
74 |
*/ |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
75 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
76 |
static final int PAGE_SIZE; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
77 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
78 |
/** |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
79 |
* Flag whose value is true if and only if the native endianness |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
80 |
* of this platform is big. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
81 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
82 |
* @implNote |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
83 |
* The actual value for this field is injected by the JVM. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
84 |
*/ |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
85 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
86 |
static final boolean BIG_ENDIAN; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
87 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
88 |
/** |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
89 |
* Flag whose value is true if and only if the platform can |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
90 |
* perform unaligned accesses |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
91 |
* |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
92 |
* @implNote |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
93 |
* The actual value for this field is injected by the JVM. |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
94 |
*/ |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
95 |
|
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
96 |
static final boolean UNALIGNED_ACCESS; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
97 |
|
57804 | 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 |
||
54439
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
115 |
static { |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
116 |
ADDRESS_SIZE0 = 0; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
117 |
PAGE_SIZE = 0; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
118 |
BIG_ENDIAN = false; |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
119 |
UNALIGNED_ACCESS = false; |
57804 | 120 |
DATA_CACHE_LINE_FLUSH_SIZE = 0; |
54439
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
121 |
} |
d9b46b7de028
8221477: Inject os/cpu-specific constants into Unsafe from JVM
adinn
parents:
diff
changeset
|
122 |
} |