author | naoto |
Mon, 28 Oct 2019 11:06:17 -0700 | |
changeset 58825 | c3696c94049d |
parent 52381 | 7f90bc64b0fc |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
2 |
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
package jdk.vm.ci.hotspot.amd64; |
|
24 |
||
25 |
import static jdk.vm.ci.common.InitTimer.timer; |
|
26 |
||
27 |
import java.util.EnumSet; |
|
28 |
||
29 |
import jdk.vm.ci.amd64.AMD64; |
|
30 |
import jdk.vm.ci.code.Architecture; |
|
31 |
import jdk.vm.ci.code.RegisterConfig; |
|
32 |
import jdk.vm.ci.code.TargetDescription; |
|
33 |
import jdk.vm.ci.code.stack.StackIntrospection; |
|
34 |
import jdk.vm.ci.common.InitTimer; |
|
35 |
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; |
|
36 |
import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; |
|
37 |
import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; |
|
50858 | 38 |
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
43972 | 39 |
import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; |
40 |
import jdk.vm.ci.hotspot.HotSpotStackIntrospection; |
|
41 |
import jdk.vm.ci.meta.ConstantReflectionProvider; |
|
42 |
import jdk.vm.ci.runtime.JVMCIBackend; |
|
43 |
||
44 |
public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { |
|
45 |
||
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
50858
diff
changeset
|
46 |
private static EnumSet<AMD64.CPUFeature> computeFeatures(AMD64HotSpotVMConfig config) { |
43972 | 47 |
// Configure the feature set using the HotSpot flag settings. |
48 |
EnumSet<AMD64.CPUFeature> features = EnumSet.noneOf(AMD64.CPUFeature.class); |
|
49 |
if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) { |
|
50 |
features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); |
|
51 |
} |
|
52 |
assert config.useSSE >= 2 : "minimum config for x64"; |
|
53 |
features.add(AMD64.CPUFeature.SSE); |
|
54 |
features.add(AMD64.CPUFeature.SSE2); |
|
55 |
if ((config.vmVersionFeatures & config.amd64SSE3) != 0) { |
|
56 |
features.add(AMD64.CPUFeature.SSE3); |
|
57 |
} |
|
58 |
if ((config.vmVersionFeatures & config.amd64SSSE3) != 0) { |
|
59 |
features.add(AMD64.CPUFeature.SSSE3); |
|
60 |
} |
|
61 |
if ((config.vmVersionFeatures & config.amd64SSE4A) != 0) { |
|
62 |
features.add(AMD64.CPUFeature.SSE4A); |
|
63 |
} |
|
64 |
if ((config.vmVersionFeatures & config.amd64SSE41) != 0) { |
|
65 |
features.add(AMD64.CPUFeature.SSE4_1); |
|
66 |
} |
|
67 |
if ((config.vmVersionFeatures & config.amd64SSE42) != 0) { |
|
68 |
features.add(AMD64.CPUFeature.SSE4_2); |
|
69 |
} |
|
70 |
if ((config.vmVersionFeatures & config.amd64POPCNT) != 0) { |
|
71 |
features.add(AMD64.CPUFeature.POPCNT); |
|
72 |
} |
|
73 |
if ((config.vmVersionFeatures & config.amd64LZCNT) != 0) { |
|
74 |
features.add(AMD64.CPUFeature.LZCNT); |
|
75 |
} |
|
76 |
if ((config.vmVersionFeatures & config.amd64ERMS) != 0) { |
|
77 |
features.add(AMD64.CPUFeature.ERMS); |
|
78 |
} |
|
79 |
if ((config.vmVersionFeatures & config.amd64AVX) != 0) { |
|
80 |
features.add(AMD64.CPUFeature.AVX); |
|
81 |
} |
|
82 |
if ((config.vmVersionFeatures & config.amd64AVX2) != 0) { |
|
83 |
features.add(AMD64.CPUFeature.AVX2); |
|
84 |
} |
|
85 |
if ((config.vmVersionFeatures & config.amd64AES) != 0) { |
|
86 |
features.add(AMD64.CPUFeature.AES); |
|
87 |
} |
|
88 |
if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) { |
|
89 |
features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); |
|
90 |
} |
|
91 |
if ((config.vmVersionFeatures & config.amd64BMI1) != 0) { |
|
92 |
features.add(AMD64.CPUFeature.BMI1); |
|
93 |
} |
|
94 |
if ((config.vmVersionFeatures & config.amd64BMI2) != 0) { |
|
95 |
features.add(AMD64.CPUFeature.BMI2); |
|
96 |
} |
|
97 |
if ((config.vmVersionFeatures & config.amd64RTM) != 0) { |
|
98 |
features.add(AMD64.CPUFeature.RTM); |
|
99 |
} |
|
100 |
if ((config.vmVersionFeatures & config.amd64ADX) != 0) { |
|
101 |
features.add(AMD64.CPUFeature.ADX); |
|
102 |
} |
|
103 |
if ((config.vmVersionFeatures & config.amd64AVX512F) != 0) { |
|
104 |
features.add(AMD64.CPUFeature.AVX512F); |
|
105 |
} |
|
106 |
if ((config.vmVersionFeatures & config.amd64AVX512DQ) != 0) { |
|
107 |
features.add(AMD64.CPUFeature.AVX512DQ); |
|
108 |
} |
|
109 |
if ((config.vmVersionFeatures & config.amd64AVX512PF) != 0) { |
|
110 |
features.add(AMD64.CPUFeature.AVX512PF); |
|
111 |
} |
|
112 |
if ((config.vmVersionFeatures & config.amd64AVX512ER) != 0) { |
|
113 |
features.add(AMD64.CPUFeature.AVX512ER); |
|
114 |
} |
|
115 |
if ((config.vmVersionFeatures & config.amd64AVX512CD) != 0) { |
|
116 |
features.add(AMD64.CPUFeature.AVX512CD); |
|
117 |
} |
|
118 |
if ((config.vmVersionFeatures & config.amd64AVX512BW) != 0) { |
|
119 |
features.add(AMD64.CPUFeature.AVX512BW); |
|
120 |
} |
|
121 |
if ((config.vmVersionFeatures & config.amd64AVX512VL) != 0) { |
|
122 |
features.add(AMD64.CPUFeature.AVX512VL); |
|
123 |
} |
|
124 |
if ((config.vmVersionFeatures & config.amd64SHA) != 0) { |
|
125 |
features.add(AMD64.CPUFeature.SHA); |
|
126 |
} |
|
127 |
if ((config.vmVersionFeatures & config.amd64FMA) != 0) { |
|
128 |
features.add(AMD64.CPUFeature.FMA); |
|
129 |
} |
|
130 |
return features; |
|
131 |
} |
|
132 |
||
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
50858
diff
changeset
|
133 |
private static EnumSet<AMD64.Flag> computeFlags(AMD64HotSpotVMConfig config) { |
43972 | 134 |
EnumSet<AMD64.Flag> flags = EnumSet.noneOf(AMD64.Flag.class); |
135 |
if (config.useCountLeadingZerosInstruction) { |
|
136 |
flags.add(AMD64.Flag.UseCountLeadingZerosInstruction); |
|
137 |
} |
|
138 |
if (config.useCountTrailingZerosInstruction) { |
|
139 |
flags.add(AMD64.Flag.UseCountTrailingZerosInstruction); |
|
140 |
} |
|
141 |
return flags; |
|
142 |
} |
|
143 |
||
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
50858
diff
changeset
|
144 |
private static TargetDescription createTarget(AMD64HotSpotVMConfig config) { |
43972 | 145 |
final int stackFrameAlignment = 16; |
146 |
final int implicitNullCheckLimit = 4096; |
|
147 |
final boolean inlineObjects = true; |
|
148 |
Architecture arch = new AMD64(computeFeatures(config), computeFlags(config)); |
|
149 |
return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); |
|
150 |
} |
|
151 |
||
50858 | 152 |
protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntime runtime) { |
43972 | 153 |
return new HotSpotConstantReflectionProvider(runtime); |
154 |
} |
|
155 |
||
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
50858
diff
changeset
|
156 |
private static RegisterConfig createRegisterConfig(AMD64HotSpotVMConfig config, TargetDescription target) { |
43972 | 157 |
return new AMD64HotSpotRegisterConfig(target, config.useCompressedOops, config.windowsOs); |
158 |
} |
|
159 |
||
50858 | 160 |
protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntime runtime, TargetDescription target, RegisterConfig regConfig) { |
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
50858
diff
changeset
|
161 |
return new HotSpotCodeCacheProvider(runtime, target, regConfig); |
43972 | 162 |
} |
163 |
||
50858 | 164 |
protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntime runtime) { |
43972 | 165 |
return new HotSpotMetaAccessProvider(runtime); |
166 |
} |
|
167 |
||
168 |
@Override |
|
169 |
public String getArchitecture() { |
|
170 |
return "AMD64"; |
|
171 |
} |
|
172 |
||
173 |
@Override |
|
174 |
public String toString() { |
|
175 |
return "JVMCIBackend:" + getArchitecture(); |
|
176 |
} |
|
177 |
||
50858 | 178 |
@Override |
43972 | 179 |
@SuppressWarnings("try") |
50858 | 180 |
public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntime runtime, JVMCIBackend host) { |
43972 | 181 |
assert host == null; |
182 |
AMD64HotSpotVMConfig config = new AMD64HotSpotVMConfig(runtime.getConfigStore()); |
|
183 |
TargetDescription target = createTarget(config); |
|
184 |
||
185 |
RegisterConfig regConfig; |
|
186 |
HotSpotCodeCacheProvider codeCache; |
|
187 |
ConstantReflectionProvider constantReflection; |
|
188 |
HotSpotMetaAccessProvider metaAccess; |
|
189 |
StackIntrospection stackIntrospection; |
|
190 |
try (InitTimer t = timer("create providers")) { |
|
191 |
try (InitTimer rt = timer("create MetaAccess provider")) { |
|
192 |
metaAccess = createMetaAccess(runtime); |
|
193 |
} |
|
194 |
try (InitTimer rt = timer("create RegisterConfig")) { |
|
195 |
regConfig = createRegisterConfig(config, target); |
|
196 |
} |
|
197 |
try (InitTimer rt = timer("create CodeCache provider")) { |
|
198 |
codeCache = createCodeCache(runtime, target, regConfig); |
|
199 |
} |
|
200 |
try (InitTimer rt = timer("create ConstantReflection provider")) { |
|
201 |
constantReflection = createConstantReflection(runtime); |
|
202 |
} |
|
203 |
try (InitTimer rt = timer("create StackIntrospection provider")) { |
|
204 |
stackIntrospection = new HotSpotStackIntrospection(runtime); |
|
205 |
} |
|
206 |
} |
|
207 |
try (InitTimer rt = timer("instantiate backend")) { |
|
208 |
return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); |
|
209 |
} |
|
210 |
} |
|
211 |
||
212 |
protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, |
|
213 |
StackIntrospection stackIntrospection) { |
|
214 |
return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); |
|
215 |
} |
|
216 |
} |