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.sparc; 24 25 import static jdk.vm.ci.common.InitTimer.timer; 26 27 import java.util.EnumSet; 28 29 import jdk.vm.ci.code.Architecture; 30 import jdk.vm.ci.code.RegisterConfig; 31 import jdk.vm.ci.code.TargetDescription; 32 import jdk.vm.ci.code.stack.StackIntrospection; 33 import jdk.vm.ci.common.InitTimer; 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.runtime.JVMCIBackend; 41 import jdk.vm.ci.sparc.SPARC; 42 import jdk.vm.ci.sparc.SPARC.CPUFeature; 43 44 public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { 45 46 protected TargetDescription createTarget(SPARCHotSpotVMConfig config) { 47 final int stackFrameAlignment = 16; 48 final int implicitNullCheckLimit = 4096; 49 final boolean inlineObjects = false; 50 Architecture arch = new SPARC(computeFeatures(config)); 51 return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); 52 } 53 54 protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { 55 return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); 56 } 57 58 protected EnumSet<CPUFeature> computeFeatures(SPARCHotSpotVMConfig config) { 59 EnumSet<CPUFeature> features = EnumSet.noneOf(CPUFeature.class); 60 if ((config.vmVersionFeatures & config.sparcVis1Instructions) != 0) { 61 features.add(CPUFeature.VIS1); 62 } 63 if ((config.vmVersionFeatures & config.sparcVis2Instructions) != 0) { 64 features.add(CPUFeature.VIS2); 65 } 66 if ((config.vmVersionFeatures & config.sparcVis3Instructions) != 0) { 67 features.add(CPUFeature.VIS3); 68 } 69 if ((config.vmVersionFeatures & config.sparcCbcondInstructions) != 0) { 70 features.add(CPUFeature.CBCOND); 71 } 72 if ((config.vmVersionFeatures & config.sparcV8Instructions) != 0) { 73 features.add(CPUFeature.V8); 74 } 75 if ((config.vmVersionFeatures & config.sparcHardwareMul32) != 0) { 76 features.add(CPUFeature.HARDWARE_MUL32); 77 } 78 if ((config.vmVersionFeatures & config.sparcHardwareDiv32) != 0) { 79 features.add(CPUFeature.HARDWARE_DIV32); 80 } 81 if ((config.vmVersionFeatures & config.sparcHardwareFsmuld) != 0) { 82 features.add(CPUFeature.HARDWARE_FSMULD); 83 } 84 if ((config.vmVersionFeatures & config.sparcHardwarePopc) != 0) { 85 features.add(CPUFeature.HARDWARE_POPC); 86 } 87 if ((config.vmVersionFeatures & config.sparcV9Instructions) != 0) { 88 features.add(CPUFeature.V9); 89 } 90 if ((config.vmVersionFeatures & config.sparcSun4v) != 0) { 91 features.add(CPUFeature.SUN4V); 92 } 93 if ((config.vmVersionFeatures & config.sparcBlkInitInstructions) != 0) { 94 features.add(CPUFeature.BLK_INIT_INSTRUCTIONS); 95 } 96 if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) { 97 features.add(CPUFeature.FMAF); 98 } 99 if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) { 100 features.add(CPUFeature.SPARC64_FAMILY); 101 } 102 if ((config.vmVersionFeatures & config.sparcMFamily) != 0) { 103 features.add(CPUFeature.M_FAMILY); 104 } 105 if ((config.vmVersionFeatures & config.sparcTFamily) != 0) { 106 features.add(CPUFeature.T_FAMILY); 107 } 108 if ((config.vmVersionFeatures & config.sparcT1Model) != 0) { 109 features.add(CPUFeature.T1_MODEL); 110 } 111 if ((config.vmVersionFeatures & config.sparcSparc5Instructions) != 0) { 112 features.add(CPUFeature.SPARC5); 113 } 114 if ((config.vmVersionFeatures & config.sparcAesInstructions) != 0) { 115 features.add(CPUFeature.SPARC64_FAMILY); 116 } 117 if ((config.vmVersionFeatures & config.sparcSha1Instruction) != 0) { 118 features.add(CPUFeature.SHA1); 119 } 120 if ((config.vmVersionFeatures & config.sparcSha256Instruction) != 0) { 121 features.add(CPUFeature.SHA256); 122 } 123 if ((config.vmVersionFeatures & config.sparcSha512Instruction) != 0) { 124 features.add(CPUFeature.SHA512); 125 } 126 return features; 127 } 128 129 @Override 130 public String getArchitecture() { 131 return "SPARC"; 132 } 133 134 @Override 135 public String toString() { 136 return "JVMCIBackend:" + getArchitecture(); 137 } 138 139 @SuppressWarnings("try") 140 public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { 141 assert host == null; 142 SPARCHotSpotVMConfig config = new SPARCHotSpotVMConfig(runtime.getConfigStore()); 143 TargetDescription target = createTarget(config); 144 145 HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); 146 RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, config.useCompressedOops); 147 HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); 148 HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); 149 StackIntrospection stackIntrospection = new HotSpotStackIntrospection(runtime); 150 try (InitTimer rt = timer("instantiate backend")) { 151 return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); 152 } 153 } 154 155 protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection, 156 StackIntrospection stackIntrospection) { 157 return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); 158 } 159 }