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.runtime.services; 24 25 import jdk.vm.ci.runtime.JVMCICompiler; 26 import jdk.vm.ci.runtime.JVMCIRuntime; 27 import jdk.vm.ci.services.JVMCIPermission; 28 29 /** 30 * Service-provider class for creating JVMCI compilers. 31 */ 32 public abstract class JVMCICompilerFactory { 33 34 private static Void checkPermission() { 35 SecurityManager sm = System.getSecurityManager(); 36 if (sm != null) { 37 sm.checkPermission(new JVMCIPermission()); 38 } 39 return null; 40 } 41 42 @SuppressWarnings("unused") 43 private JVMCICompilerFactory(Void ignore) { 44 } 45 46 /** 47 * Initializes a new instance of this class. 48 * 49 * @throws SecurityException if a security manager has been installed and it denies 50 * {@link JVMCIPermission} 51 */ 52 protected JVMCICompilerFactory() { 53 this(checkPermission()); 54 } 55 56 /** 57 * Get the name of this compiler. The name is used by JVMCI to determine which factory to use. 58 */ 59 public abstract String getCompilerName(); 60 61 /** 62 * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime) 63 * create} a compiler and it should now perform any heavy weight initialization that it deferred 64 * during construction. 65 */ 66 public void onSelection() { 67 } 68 69 /** 70 * Create a new instance of a {@link JVMCICompiler}. 71 */ 72 @SuppressWarnings("unexportedinapi") 73 public abstract JVMCICompiler createCompiler(JVMCIRuntime runtime); 74 }