1 /* 2 * Copyright (c) 2015, 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.aarch64; 24 25 import static jdk.vm.ci.common.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.common.InitTimer; 35 import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; 36 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; 37 import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; 38 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; 39 import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; 40 import jdk.vm.ci.hotspot.HotSpotStackIntrospection; 41 import jdk.vm.ci.meta.ConstantReflectionProvider; 42 import jdk.vm.ci.runtime.JVMCIBackend; 43 44 public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { 45 46 protected EnumSet<AArch64.CPUFeature> computeFeatures(@SuppressWarnings("unused") AArch64HotSpotVMConfig config) { 47 // Configure the feature set using the HotSpot flag settings. 48 EnumSet<AArch64.CPUFeature> features = EnumSet.noneOf(AArch64.CPUFeature.class); 49 return features; 50 } 51 52 protected EnumSet<AArch64.Flag> computeFlags(@SuppressWarnings("unused") AArch64HotSpotVMConfig config) { 53 EnumSet<AArch64.Flag> flags = EnumSet.noneOf(AArch64.Flag.class); 54 return flags; 55 } 56 57 protected TargetDescription createTarget(AArch64HotSpotVMConfig config) { 58 final int stackFrameAlignment = 16; 59 final int implicitNullCheckLimit = 4096; 60 final boolean inlineObjects = true; 61 Architecture arch = new AArch64(computeFeatures(config), computeFlags(config)); 62 return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); 63 } 64 65 protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { 66 return new HotSpotConstantReflectionProvider(runtime); 67 } 68 69 protected RegisterConfig createRegisterConfig(AArch64HotSpotVMConfig config, TargetDescription target) { 70 return new AArch64HotSpotRegisterConfig(target, config.useCompressedOops); 71 } 72 73 protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { 74 return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); 75 } 76 77 protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { 78 return new HotSpotMetaAccessProvider(runtime); 79 } 80 81 @Override 82 public String getArchitecture() { 83 return "aarch64"; 84 } 85 86 @Override 87 public String toString() { 88 return "JVMCIBackend:" + getArchitecture(); 89 } 90 91 @SuppressWarnings("try") 92 public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { 93 94 assert host == null; 95 AArch64HotSpotVMConfig config = new AArch64HotSpotVMConfig(runtime.getConfigStore()); 96 TargetDescription target = createTarget(config); 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(config, 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, 126 StackIntrospection stackIntrospection) { 127 return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); 128 } 129 }