< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java

Print this page




   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.inittimer.InitTimer.*;
  26 
  27 import java.util.*;
  28 
  29 import jdk.vm.ci.amd64.*;
  30 import jdk.vm.ci.code.*;
  31 import jdk.vm.ci.compiler.*;
  32 import jdk.vm.ci.hotspot.*;
  33 import jdk.vm.ci.inittimer.*;
  34 import jdk.vm.ci.meta.*;
  35 import jdk.vm.ci.runtime.*;
  36 import jdk.vm.ci.service.*;








  37 
  38 @ServiceProvider(HotSpotJVMCIBackendFactory.class)
  39 public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory {
  40 
  41     protected EnumSet<AMD64.CPUFeature> computeFeatures(HotSpotVMConfig config) {
  42         // Configure the feature set using the HotSpot flag settings.
  43         EnumSet<AMD64.CPUFeature> features = EnumSet.noneOf(AMD64.CPUFeature.class);
  44         if ((config.x86CPUFeatures & config.cpu3DNOWPREFETCH) != 0) {
  45             features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH);
  46         }
  47         assert config.useSSE >= 2 : "minimum config for x64";
  48         features.add(AMD64.CPUFeature.SSE);
  49         features.add(AMD64.CPUFeature.SSE2);
  50         if ((config.x86CPUFeatures & config.cpuSSE3) != 0) {
  51             features.add(AMD64.CPUFeature.SSE3);
  52         }
  53         if ((config.x86CPUFeatures & config.cpuSSSE3) != 0) {
  54             features.add(AMD64.CPUFeature.SSSE3);
  55         }
  56         if ((config.x86CPUFeatures & config.cpuSSE4A) != 0) {
  57             features.add(AMD64.CPUFeature.SSE4A);
  58         }
  59         if ((config.x86CPUFeatures & config.cpuSSE41) != 0) {
  60             features.add(AMD64.CPUFeature.SSE4_1);
  61         }
  62         if ((config.x86CPUFeatures & config.cpuSSE42) != 0) {
  63             features.add(AMD64.CPUFeature.SSE4_2);
  64         }
  65         if ((config.x86CPUFeatures & config.cpuPOPCNT) != 0) {
  66             features.add(AMD64.CPUFeature.POPCNT);
  67         }
  68         if ((config.x86CPUFeatures & config.cpuLZCNT) != 0) {
  69             features.add(AMD64.CPUFeature.LZCNT);
  70         }



  71         if ((config.x86CPUFeatures & config.cpuAVX) != 0) {
  72             features.add(AMD64.CPUFeature.AVX);
  73         }
  74         if ((config.x86CPUFeatures & config.cpuAVX2) != 0) {
  75             features.add(AMD64.CPUFeature.AVX2);
  76         }
  77         if ((config.x86CPUFeatures & config.cpuAES) != 0) {
  78             features.add(AMD64.CPUFeature.AES);
  79         }
  80         if ((config.x86CPUFeatures & config.cpuERMS) != 0) {
  81             features.add(AMD64.CPUFeature.ERMS);
  82         }
  83         if ((config.x86CPUFeatures & config.cpuBMI1) != 0) {
  84             features.add(AMD64.CPUFeature.BMI1);
  85         }






























  86         return features;
  87     }
  88 
  89     protected EnumSet<AMD64.Flag> computeFlags(HotSpotVMConfig config) {
  90         EnumSet<AMD64.Flag> flags = EnumSet.noneOf(AMD64.Flag.class);
  91         if (config.useCountLeadingZerosInstruction) {
  92             flags.add(AMD64.Flag.UseCountLeadingZerosInstruction);
  93         }
  94         if (config.useCountTrailingZerosInstruction) {
  95             flags.add(AMD64.Flag.UseCountTrailingZerosInstruction);
  96         }
  97         return flags;
  98     }
  99 
 100     protected TargetDescription createTarget(HotSpotVMConfig config, CompilerFactory compilerFactory) {
 101         final int stackFrameAlignment = 16;
 102         final int implicitNullCheckLimit = 4096;
 103         final boolean inlineObjects = true;
 104         Architecture arch = new AMD64(computeFeatures(config), computeFlags(config));
 105         return new TargetDescription(compilerFactory.initializeArchitecture(arch), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects);
 106     }
 107 
 108     protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) {
 109         return new HotSpotConstantReflectionProvider(runtime);
 110     }
 111 
 112     protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) {
 113         return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig());
 114     }
 115 
 116     protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) {
 117         return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig);
 118     }
 119 
 120     protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) {
 121         return new HotSpotMetaAccessProvider(runtime);
 122     }
 123 
 124     @Override
 125     public String getArchitecture() {
 126         return "AMD64";
 127     }
 128 
 129     @Override
 130     public String toString() {
 131         return "JVMCIBackend:" + getArchitecture();
 132     }
 133 
 134     @SuppressWarnings("try")
 135     public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, CompilerFactory compilerFactory, JVMCIBackend host) {
 136 
 137         assert host == null;
 138         TargetDescription target = createTarget(runtime.getConfig(), compilerFactory);
 139 
 140         RegisterConfig regConfig;
 141         HotSpotCodeCacheProvider codeCache;
 142         ConstantReflectionProvider constantReflection;
 143         HotSpotMetaAccessProvider metaAccess;

 144         try (InitTimer t = timer("create providers")) {
 145             try (InitTimer rt = timer("create MetaAccess provider")) {
 146                 metaAccess = createMetaAccess(runtime);
 147             }
 148             try (InitTimer rt = timer("create RegisterConfig")) {
 149                 regConfig = createRegisterConfig(runtime, target);
 150             }
 151             try (InitTimer rt = timer("create CodeCache provider")) {
 152                 codeCache = createCodeCache(runtime, target, regConfig);
 153             }
 154             try (InitTimer rt = timer("create ConstantReflection provider")) {
 155                 constantReflection = createConstantReflection(runtime);
 156             }



 157         }
 158         try (InitTimer rt = timer("instantiate backend")) {
 159             return createBackend(metaAccess, codeCache, constantReflection);
 160         }
 161     }
 162 
 163     protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection) {
 164         return new JVMCIBackend(metaAccess, codeCache, constantReflection);
 165     }
 166 }


   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.inittimer.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.hotspot.HotSpotCodeCacheProvider;
  35 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
  36 import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
  37 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
  38 import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider;
  39 import jdk.vm.ci.hotspot.HotSpotStackIntrospection;
  40 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  41 import jdk.vm.ci.inittimer.InitTimer;
  42 import jdk.vm.ci.meta.ConstantReflectionProvider;
  43 import jdk.vm.ci.runtime.JVMCIBackend;
  44 import jdk.vm.ci.service.ServiceProvider;
  45 
  46 @ServiceProvider(HotSpotJVMCIBackendFactory.class)
  47 public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory {
  48 
  49     protected EnumSet<AMD64.CPUFeature> computeFeatures(HotSpotVMConfig config) {
  50         // Configure the feature set using the HotSpot flag settings.
  51         EnumSet<AMD64.CPUFeature> features = EnumSet.noneOf(AMD64.CPUFeature.class);
  52         if ((config.x86CPUFeatures & config.cpu3DNOWPREFETCH) != 0) {
  53             features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH);
  54         }
  55         assert config.useSSE >= 2 : "minimum config for x64";
  56         features.add(AMD64.CPUFeature.SSE);
  57         features.add(AMD64.CPUFeature.SSE2);
  58         if ((config.x86CPUFeatures & config.cpuSSE3) != 0) {
  59             features.add(AMD64.CPUFeature.SSE3);
  60         }
  61         if ((config.x86CPUFeatures & config.cpuSSSE3) != 0) {
  62             features.add(AMD64.CPUFeature.SSSE3);
  63         }
  64         if ((config.x86CPUFeatures & config.cpuSSE4A) != 0) {
  65             features.add(AMD64.CPUFeature.SSE4A);
  66         }
  67         if ((config.x86CPUFeatures & config.cpuSSE41) != 0) {
  68             features.add(AMD64.CPUFeature.SSE4_1);
  69         }
  70         if ((config.x86CPUFeatures & config.cpuSSE42) != 0) {
  71             features.add(AMD64.CPUFeature.SSE4_2);
  72         }
  73         if ((config.x86CPUFeatures & config.cpuPOPCNT) != 0) {
  74             features.add(AMD64.CPUFeature.POPCNT);
  75         }
  76         if ((config.x86CPUFeatures & config.cpuLZCNT) != 0) {
  77             features.add(AMD64.CPUFeature.LZCNT);
  78         }
  79         if ((config.x86CPUFeatures & config.cpuERMS) != 0) {
  80             features.add(AMD64.CPUFeature.ERMS);
  81         }
  82         if ((config.x86CPUFeatures & config.cpuAVX) != 0) {
  83             features.add(AMD64.CPUFeature.AVX);
  84         }
  85         if ((config.x86CPUFeatures & config.cpuAVX2) != 0) {
  86             features.add(AMD64.CPUFeature.AVX2);
  87         }
  88         if ((config.x86CPUFeatures & config.cpuAES) != 0) {
  89             features.add(AMD64.CPUFeature.AES);
  90         }
  91         if ((config.x86CPUFeatures & config.cpu3DNOWPREFETCH) != 0) {
  92             features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH);
  93         }
  94         if ((config.x86CPUFeatures & config.cpuBMI1) != 0) {
  95             features.add(AMD64.CPUFeature.BMI1);
  96         }
  97         if ((config.x86CPUFeatures & config.cpuBMI2) != 0) {
  98             features.add(AMD64.CPUFeature.BMI2);
  99         }
 100         if ((config.x86CPUFeatures & config.cpuRTM) != 0) {
 101             features.add(AMD64.CPUFeature.RTM);
 102         }
 103         if ((config.x86CPUFeatures & config.cpuADX) != 0) {
 104             features.add(AMD64.CPUFeature.ADX);
 105         }
 106         if ((config.x86CPUFeatures & config.cpuAVX512F) != 0) {
 107             features.add(AMD64.CPUFeature.AVX512F);
 108         }
 109         if ((config.x86CPUFeatures & config.cpuAVX512DQ) != 0) {
 110             features.add(AMD64.CPUFeature.AVX512DQ);
 111         }
 112         if ((config.x86CPUFeatures & config.cpuAVX512PF) != 0) {
 113             features.add(AMD64.CPUFeature.AVX512PF);
 114         }
 115         if ((config.x86CPUFeatures & config.cpuAVX512ER) != 0) {
 116             features.add(AMD64.CPUFeature.AVX512ER);
 117         }
 118         if ((config.x86CPUFeatures & config.cpuAVX512CD) != 0) {
 119             features.add(AMD64.CPUFeature.AVX512CD);
 120         }
 121         if ((config.x86CPUFeatures & config.cpuAVX512BW) != 0) {
 122             features.add(AMD64.CPUFeature.AVX512BW);
 123         }
 124         if ((config.x86CPUFeatures & config.cpuAVX512VL) != 0) {
 125             features.add(AMD64.CPUFeature.AVX512VL);
 126         }
 127         return features;
 128     }
 129 
 130     protected EnumSet<AMD64.Flag> computeFlags(HotSpotVMConfig config) {
 131         EnumSet<AMD64.Flag> flags = EnumSet.noneOf(AMD64.Flag.class);
 132         if (config.useCountLeadingZerosInstruction) {
 133             flags.add(AMD64.Flag.UseCountLeadingZerosInstruction);
 134         }
 135         if (config.useCountTrailingZerosInstruction) {
 136             flags.add(AMD64.Flag.UseCountTrailingZerosInstruction);
 137         }
 138         return flags;
 139     }
 140 
 141     protected TargetDescription createTarget(HotSpotVMConfig config) {
 142         final int stackFrameAlignment = 16;
 143         final int implicitNullCheckLimit = 4096;
 144         final boolean inlineObjects = true;
 145         Architecture arch = new AMD64(computeFeatures(config), computeFlags(config));
 146         return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects);
 147     }
 148 
 149     protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) {
 150         return new HotSpotConstantReflectionProvider(runtime);
 151     }
 152 
 153     protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) {
 154         return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig());
 155     }
 156 
 157     protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) {
 158         return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig);
 159     }
 160 
 161     protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) {
 162         return new HotSpotMetaAccessProvider(runtime);
 163     }
 164 
 165     @Override
 166     public String getArchitecture() {
 167         return "AMD64";
 168     }
 169 
 170     @Override
 171     public String toString() {
 172         return "JVMCIBackend:" + getArchitecture();
 173     }
 174 
 175     @SuppressWarnings("try")
 176     public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) {
 177 
 178         assert host == null;
 179         TargetDescription target = createTarget(runtime.getConfig());
 180 
 181         RegisterConfig regConfig;
 182         HotSpotCodeCacheProvider codeCache;
 183         ConstantReflectionProvider constantReflection;
 184         HotSpotMetaAccessProvider metaAccess;
 185         StackIntrospection stackIntrospection;
 186         try (InitTimer t = timer("create providers")) {
 187             try (InitTimer rt = timer("create MetaAccess provider")) {
 188                 metaAccess = createMetaAccess(runtime);
 189             }
 190             try (InitTimer rt = timer("create RegisterConfig")) {
 191                 regConfig = createRegisterConfig(runtime, target);
 192             }
 193             try (InitTimer rt = timer("create CodeCache provider")) {
 194                 codeCache = createCodeCache(runtime, target, regConfig);
 195             }
 196             try (InitTimer rt = timer("create ConstantReflection provider")) {
 197                 constantReflection = createConstantReflection(runtime);
 198             }
 199             try (InitTimer rt = timer("create StackIntrospection provider")) {
 200                 stackIntrospection = new HotSpotStackIntrospection(runtime);
 201             }
 202         }
 203         try (InitTimer rt = timer("instantiate backend")) {
 204             return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection);
 205         }
 206     }
 207 
 208     protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) {
 209         return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection);
 210     }
 211 }
< prev index next >