Mercurial > hg > truffle
comparison graal/com.oracle.jvmci.hotspot.amd64/src/com/oracle/jvmci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java @ 21675:2e8c01def9a5
moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 00:30:44 +0200 |
parents | graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/jvmci/AMD64HotSpotJVMCIBackendFactory.java@e0b5d4fcd929 |
children |
comparison
equal
deleted
inserted
replaced
21674:e0b5d4fcd929 | 21675:2e8c01def9a5 |
---|---|
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.jvmci.hotspot.amd64; | |
24 | |
25 import static com.oracle.jvmci.hotspot.InitTimer.*; | |
26 | |
27 import java.util.*; | |
28 | |
29 import com.oracle.jvmci.amd64.*; | |
30 import com.oracle.jvmci.code.*; | |
31 import com.oracle.jvmci.hotspot.*; | |
32 import com.oracle.jvmci.meta.*; | |
33 import com.oracle.jvmci.runtime.*; | |
34 import com.oracle.jvmci.service.*; | |
35 | |
36 @ServiceProvider(HotSpotJVMCIBackendFactory.class) | |
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 HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { | |
110 return new HotSpotConstantReflectionProvider(runtime); | |
111 } | |
112 | |
113 protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { | |
114 return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig()); | |
115 } | |
116 | |
117 protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { | |
118 return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); | |
119 } | |
120 | |
121 protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { | |
122 return new HotSpotMetaAccessProvider(runtime); | |
123 } | |
124 | |
125 public String getArchitecture() { | |
126 return "AMD64"; | |
127 } | |
128 | |
129 @Override | |
130 public String toString() { | |
131 return getJVMCIRuntimeName() + ":" + getArchitecture(); | |
132 } | |
133 | |
134 public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { | |
135 | |
136 assert host == null; | |
137 TargetDescription target = createTarget(runtime.getConfig()); | |
138 | |
139 RegisterConfig regConfig; | |
140 HotSpotCodeCacheProvider codeCache; | |
141 ConstantReflectionProvider constantReflection; | |
142 HotSpotMetaAccessProvider metaAccess; | |
143 try (InitTimer t = timer("create providers")) { | |
144 try (InitTimer rt = timer("create MetaAccess provider")) { | |
145 metaAccess = createMetaAccess(runtime); | |
146 } | |
147 try (InitTimer rt = timer("create RegisterConfig")) { | |
148 regConfig = createRegisterConfig(runtime, target); | |
149 } | |
150 try (InitTimer rt = timer("create CodeCache provider")) { | |
151 codeCache = createCodeCache(runtime, target, regConfig); | |
152 } | |
153 try (InitTimer rt = timer("create ConstantReflection provider")) { | |
154 constantReflection = createConstantReflection(runtime); | |
155 } | |
156 } | |
157 try (InitTimer rt = timer("instantiate backend")) { | |
158 return createBackend(metaAccess, codeCache, constantReflection); | |
159 } | |
160 } | |
161 | |
162 protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection) { | |
163 return new JVMCIBackend(metaAccess, codeCache, constantReflection); | |
164 } | |
165 | |
166 public String getJVMCIRuntimeName() { | |
167 return "basic"; | |
168 } | |
169 } |