1 /* 2 * Copyright (c) 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 jdk.vm.ci.hotspot.aarch64; 24 25 import static jdk.vm.ci.inittimer.InitTimer.timer; 26 27 import java.util.EnumSet; 28 29 import jdk.vm.ci.aarch64.AArch64; 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 45 public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { 46 47 protected EnumSet<AArch64.CPUFeature> computeFeatures(@SuppressWarnings("unused") HotSpotVMConfig config) { 48 // Configure the feature set using the HotSpot flag settings. 49 EnumSet<AArch64.CPUFeature> features = EnumSet.noneOf(AArch64.CPUFeature.class); 50 return features; 51 } 52 53 protected EnumSet<AArch64.Flag> computeFlags(@SuppressWarnings("unused") HotSpotVMConfig config) { 54 EnumSet<AArch64.Flag> flags = EnumSet.noneOf(AArch64.Flag.class); 55 return flags; 56 } 57 58 protected TargetDescription createTarget(HotSpotVMConfig config) { 59 final int stackFrameAlignment = 16; 60 final int implicitNullCheckLimit = 4096; 61 final boolean inlineObjects = true; 62 Architecture arch = new AArch64(computeFeatures(config), computeFlags(config)); 63 return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); 64 } 65 66 protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { 67 return new HotSpotConstantReflectionProvider(runtime); 68 } 69 70 protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { 71 return new AArch64HotSpotRegisterConfig(target.arch, runtime.getConfig()); 72 } 73 74 protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { 75 return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); 76 } 77 78 protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { 79 return new HotSpotMetaAccessProvider(runtime); 80 } 81 82 @Override 83 public String getArchitecture() { 84 return "aarch64"; 85 } 86 87 @Override 88 public String toString() { 89 return "JVMCIBackend:" + getArchitecture(); 90 } 91 92 @SuppressWarnings("try") 93 public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { 94 95 assert host == null; 96 TargetDescription target = createTarget(runtime.getConfig()); 97 98 RegisterConfig regConfig; 99 HotSpotCodeCacheProvider codeCache; 100 ConstantReflectionProvider constantReflection; 101 HotSpotMetaAccessProvider metaAccess; 102 StackIntrospection stackIntrospection; 103 try (InitTimer t = timer("create providers")) { 104 try (InitTimer rt = timer("create MetaAccess provider")) { 105 metaAccess = createMetaAccess(runtime); 106 } 107 try (InitTimer rt = timer("create RegisterConfig")) { 108 regConfig = createRegisterConfig(runtime, target); 109 } 110 try (InitTimer rt = timer("create CodeCache provider")) { 111 codeCache = createCodeCache(runtime, target, regConfig); 112 } 113 try (InitTimer rt = timer("create ConstantReflection provider")) { 114 constantReflection = createConstantReflection(runtime); 115 } 116 try (InitTimer rt = timer("create StackIntrospection provider")) { 117 stackIntrospection = new HotSpotStackIntrospection(runtime); 118 } 119 } 120 try (InitTimer rt = timer("instantiate backend")) { 121 return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); 122 } 123 } 124 125 protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { 126 return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); 127 } 128 }