# HG changeset patch # User Thomas Wuerthinger # Date 1339188639 -7200 # Node ID c5c13f3ed5c4d016d4188a851a2e74abf80aae97 # Parent 82f2bb47c97ee2899adce31027de59d81d6645da Remove GraalAccess class, replace usages new GraalVM API. diff -r 82f2bb47c97e -r c5c13f3ed5c4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompilerImpl.java Fri Jun 08 22:39:39 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompilerImpl.java Fri Jun 08 22:50:39 2012 +0200 @@ -28,6 +28,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.cri.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.ri.*; @@ -200,8 +201,12 @@ return "HotSpotGraalRuntime"; } + @SuppressWarnings("unchecked") @Override public T getCapability(Class clazz) { + if (clazz == ExtendedRiRuntime.class) { + return (T) getRuntime(); + } return null; } } diff -r 82f2bb47c97e -r c5c13f3ed5c4 graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalAccess.java --- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalAccess.java Fri Jun 08 22:39:39 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.compiler.tests; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.compiler.*; - -/** - * Utility for getting a Graal objects from the current execution environment. - */ -class GraalAccess { - - /** - * The known classes declaring a {@code getGraalCompiler()} method. These class names - * have aliases that can be used with the {@code "graal.access"} system property to - * specify the VM environment to try first when getting a Graal compiler instance. - */ - private static Map graalAccessClasses = new LinkedHashMap<>(); - static { - graalAccessClasses.put("HotSpot", "com.oracle.graal.hotspot.HotSpotCompilerImpl"); - graalAccessClasses.put("Maxine", "com.oracle.max.vm.ext.maxri.MaxRuntime"); - } - - /** - * Gets a {@link GraalCompiler} instance from the current execution environment. - */ - static GraalCompiler getGraalCompiler() { - String vm = System.getProperty("graal.access"); - if (vm != null) { - String cn = graalAccessClasses.get(vm); - if (cn != null) { - GraalCompiler graalCompiler = getGraalCompiler(cn); - if (graalCompiler != null) { - return graalCompiler; - } - } - } - - for (String className : graalAccessClasses.values()) { - GraalCompiler graalCompiler = getGraalCompiler(className); - if (graalCompiler != null) { - return graalCompiler; - } - } - throw new InternalError("Could not create a GraalRuntime instance"); - } - - /** - * Calls {@code getGraalCompiler()} via reflection on a given class. - * - * @return {@code null} if there was an error invoking the method or if the method returns {@code null} itself - */ - private static GraalCompiler getGraalCompiler(String className) { - try { - Class c = Class.forName(className); - Method m = c.getDeclaredMethod("getGraalCompiler"); - return (GraalCompiler) m.invoke(null); - } catch (Exception e) { - //e.printStackTrace(); - System.err.println(e); - return null; - } - } -} diff -r 82f2bb47c97e -r c5c13f3ed5c4 graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphTest.java --- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphTest.java Fri Jun 08 22:39:39 2012 +0200 +++ b/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphTest.java Fri Jun 08 22:50:39 2012 +0200 @@ -27,6 +27,7 @@ import junit.framework.*; +import com.oracle.graal.api.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.*; @@ -59,13 +60,11 @@ */ public abstract class GraphTest { - protected final GraalCompiler graalCompiler; protected final ExtendedRiRuntime runtime; public GraphTest() { Debug.enable(); - this.graalCompiler = GraalAccess.getGraalCompiler(); - this.runtime = graalCompiler.runtime; + this.runtime = Graal.getRuntime().getCapability(ExtendedRiRuntime.class); } protected void assertEquals(StructuredGraph expected, StructuredGraph graph) { @@ -158,7 +157,7 @@ } protected RiCompiledMethod addMethod(final RiResolvedMethod method, final CiTargetMethod tm) { - return Debug.scope("CodeInstall", new Object[] {graalCompiler, method}, new Callable() { + return Debug.scope("CodeInstall", new Object[] {method}, new Callable() { @Override public RiCompiledMethod call() throws Exception { final RiCodeInfo[] info = Debug.isDumpEnabled() ? new RiCodeInfo[1] : null; diff -r 82f2bb47c97e -r c5c13f3ed5c4 mx/projects --- a/mx/projects Fri Jun 08 22:39:39 2012 +0200 +++ b/mx/projects Fri Jun 08 22:50:39 2012 +0200 @@ -147,7 +147,7 @@ # graal.test project@com.oracle.graal.tests@subDir=graal project@com.oracle.graal.tests@sourceDirs=src -project@com.oracle.graal.tests@dependencies=JUNIT,com.oracle.graal.printer +project@com.oracle.graal.tests@dependencies=JUNIT,com.oracle.graal.printer,com.oracle.graal.api project@com.oracle.graal.tests@checkstyle=com.oracle.graal.graph project@com.oracle.graal.tests@javaCompliance=1.7