Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/jvmci/AMD64HotSpotJVMCIBackendFactory.java @ 21527:07b088d61d5d
added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 22 May 2015 23:26:20 +0200 |
parents | |
children | c1e2fdb5fea3 |
comparison
equal
deleted
inserted
replaced
21526:1da7aef31a08 | 21527:07b088d61d5d |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2015, 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 com.oracle.graal.hotspot.amd64.jvmci; | |
24 | |
25 import static com.oracle.graal.hotspot.jvmci.InitTimer.*; | |
26 | |
27 import java.util.*; | |
28 | |
29 import com.oracle.graal.amd64.*; | |
30 import com.oracle.graal.api.code.*; | |
31 import com.oracle.graal.hotspot.*; | |
32 import com.oracle.graal.hotspot.amd64.*; | |
33 import com.oracle.graal.hotspot.jvmci.*; | |
34 import com.oracle.graal.hotspot.meta.*; | |
35 import com.oracle.jvmci.runtime.*; | |
36 | |
37 public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { | |
38 | |
39 protected Architecture createArchitecture(HotSpotVMConfig config) { | |
40 return new AMD64(computeFeatures(config), computeFlags(config)); | |
41 } | |
42 | |
43 protected EnumSet<AMD64.CPUFeature> computeFeatures(HotSpotVMConfig config) { | |
44 // Configure the feature set using the HotSpot flag settings. | |
45 EnumSet<AMD64.CPUFeature> features = EnumSet.noneOf(AMD64.CPUFeature.class); | |
46 assert config.useSSE >= 2 : "minimum config for x64"; | |
47 features.add(AMD64.CPUFeature.SSE); | |
48 features.add(AMD64.CPUFeature.SSE2); | |
49 if ((config.x86CPUFeatures & config.cpuSSE3) != 0) { | |
50 features.add(AMD64.CPUFeature.SSE3); | |
51 } | |
52 if ((config.x86CPUFeatures & config.cpuSSSE3) != 0) { | |
53 features.add(AMD64.CPUFeature.SSSE3); | |
54 } | |
55 if ((config.x86CPUFeatures & config.cpuSSE4A) != 0) { | |
56 features.add(AMD64.CPUFeature.SSE4a); | |
57 } | |
58 if ((config.x86CPUFeatures & config.cpuSSE41) != 0) { | |
59 features.add(AMD64.CPUFeature.SSE4_1); | |
60 } | |
61 if ((config.x86CPUFeatures & config.cpuSSE42) != 0) { | |
62 features.add(AMD64.CPUFeature.SSE4_2); | |
63 } | |
64 if ((config.x86CPUFeatures & config.cpuAVX) != 0) { | |
65 features.add(AMD64.CPUFeature.AVX); | |
66 } | |
67 if ((config.x86CPUFeatures & config.cpuAVX2) != 0) { | |
68 features.add(AMD64.CPUFeature.AVX2); | |
69 } | |
70 if ((config.x86CPUFeatures & config.cpuERMS) != 0) { | |
71 features.add(AMD64.CPUFeature.ERMS); | |
72 } | |
73 if ((config.x86CPUFeatures & config.cpuLZCNT) != 0) { | |
74 features.add(AMD64.CPUFeature.LZCNT); | |
75 } | |
76 if ((config.x86CPUFeatures & config.cpuPOPCNT) != 0) { | |
77 features.add(AMD64.CPUFeature.POPCNT); | |
78 } | |
79 if ((config.x86CPUFeatures & config.cpuAES) != 0) { | |
80 features.add(AMD64.CPUFeature.AES); | |
81 } | |
82 if ((config.x86CPUFeatures & config.cpu3DNOWPREFETCH) != 0) { | |
83 features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); | |
84 } | |
85 if ((config.x86CPUFeatures & config.cpuBMI1) != 0) { | |
86 features.add(AMD64.CPUFeature.BMI1); | |
87 } | |
88 return features; | |
89 } | |
90 | |
91 protected EnumSet<AMD64.Flag> computeFlags(HotSpotVMConfig config) { | |
92 EnumSet<AMD64.Flag> flags = EnumSet.noneOf(AMD64.Flag.class); | |
93 if (config.useCountLeadingZerosInstruction) { | |
94 flags.add(AMD64.Flag.UseCountLeadingZerosInstruction); | |
95 } | |
96 if (config.useCountTrailingZerosInstruction) { | |
97 flags.add(AMD64.Flag.UseCountTrailingZerosInstruction); | |
98 } | |
99 return flags; | |
100 } | |
101 | |
102 protected TargetDescription createTarget(HotSpotVMConfig config) { | |
103 final int stackFrameAlignment = 16; | |
104 final int implicitNullCheckLimit = 4096; | |
105 final boolean inlineObjects = true; | |
106 return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); | |
107 } | |
108 | |
109 protected AMD64HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { | |
110 return new AMD64HotSpotBackend(runtime, providers); | |
111 } | |
112 | |
113 protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { | |
114 return new HotSpotConstantReflectionProvider(runtime); | |
115 } | |
116 | |
117 protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { | |
118 return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig()); | |
119 } | |
120 | |
121 protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { | |
122 return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); | |
123 } | |
124 | |
125 protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { | |
126 return new HotSpotMetaAccessProvider(runtime); | |
127 } | |
128 | |
129 public String getArchitecture() { | |
130 return "AMD64"; | |
131 } | |
132 | |
133 public String getGraalRuntimeName() { | |
134 return "basic"; | |
135 } | |
136 | |
137 @Override | |
138 public String toString() { | |
139 return getGraalRuntimeName() + ":" + getArchitecture(); | |
140 } | |
141 | |
142 public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { | |
143 | |
144 assert host == null; | |
145 TargetDescription target = createTarget(runtime.getConfig()); | |
146 | |
147 RegisterConfig regConfig; | |
148 HotSpotCodeCacheProvider codeCache; | |
149 HotSpotConstantReflectionProvider constantReflection; | |
150 HotSpotMetaAccessProvider metaAccess; | |
151 try (InitTimer t = timer("create providers")) { | |
152 try (InitTimer rt = timer("create MetaAccess provider")) { | |
153 metaAccess = createMetaAccess(runtime); | |
154 } | |
155 try (InitTimer rt = timer("create RegisterConfig")) { | |
156 regConfig = createRegisterConfig(runtime, target); | |
157 } | |
158 try (InitTimer rt = timer("create CodeCache provider")) { | |
159 codeCache = createCodeCache(runtime, target, regConfig); | |
160 } | |
161 try (InitTimer rt = timer("create ConstantReflection provider")) { | |
162 constantReflection = createConstantReflection(runtime); | |
163 } | |
164 } | |
165 try (InitTimer rt = timer("instantiate backend")) { | |
166 return createBackend(metaAccess, codeCache, constantReflection); | |
167 } | |
168 } | |
169 | |
170 protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection) { | |
171 return new JVMCIBackend(metaAccess, codeCache, constantReflection); | |
172 } | |
173 | |
174 public String getJVMCIRuntimeName() { | |
175 return "basic"; | |
176 } | |
177 } |