Mercurial > hg > truffle
view graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalRuntimeAccess.java @ 5233:efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
removed XIR ops: Align, StackOverflowCheck, PushFrame, PopFrame, RawBytes
enhanced disassembly to annotate marks
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 12 Apr 2012 15:55:03 +0200 |
parents | e808627bd16f |
children |
line wrap: on
line source
/* * 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.cri.*; /** * Utility for getting a {@link GraalRuntime} instance from the current execution environment. */ class GraalRuntimeAccess { /** * The known classes declaring a {@code getGraalRuntime()} method. These class names * have aliases that can be used with the {@code "graal.runtime"} system property to * specify the VM environment to try first when getting a Graal runtime instance. */ private static Map<String, String> graalRuntimeFactoryClasses = new LinkedHashMap<>(); static { graalRuntimeFactoryClasses.put("HotSpot", "com.oracle.graal.hotspot.CompilerImpl"); graalRuntimeFactoryClasses.put("Maxine", "com.oracle.max.vm.ext.maxri.MaxRuntime"); } /** * Gets a Graal runtime instance from the current execution environment. */ static GraalRuntime getGraalRuntime() { String vm = System.getProperty("graal.runtime"); if (vm != null) { String cn = graalRuntimeFactoryClasses.get(vm); if (cn != null) { GraalRuntime graal = getGraalRuntime(cn); if (graal != null) { return graal; } } } for (String className : graalRuntimeFactoryClasses.values()) { GraalRuntime graal = getGraalRuntime(className); if (graal != null) { return graal; } } throw new InternalError("Could not create a GraalRuntime instance"); } /** * Calls {@code getGraalRuntime()} via reflection on a given class. * * @return {@code null} if there was an error invoking the methodor if the method return {@code null} itself */ private static GraalRuntime getGraalRuntime(String className) { try { Class<?> c = Class.forName(className); Method m = c.getDeclaredMethod("getGraalRuntime"); return (GraalRuntime) m.invoke(null); } catch (Exception e) { //e.printStackTrace(); System.err.println(e); return null; } } }