Mercurial > hg > graal-compiler
changeset 22616:ea96c0f19929
cleanups in preparation for CompilerToVM becoming a concrete class (GRAAL-1255)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 09 Sep 2015 21:31:22 +0200 |
parents | fbc2ef12da21 |
children | 4fba290f7001 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTTYStreamProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/HotSpotTTYStreamProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/ProxyUtil.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/package-info.java |
diffstat | 8 files changed, 157 insertions(+), 467 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Wed Sep 09 11:50:28 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Wed Sep 09 21:31:22 2015 +0200 @@ -22,33 +22,50 @@ */ package com.oracle.graal.hotspot; -import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.debug.GraalDebugConfig.*; -import static jdk.internal.jvmci.inittimer.InitTimer.*; +import static com.oracle.graal.compiler.common.GraalOptions.HotSpotPrintInlining; +import static com.oracle.graal.debug.GraalDebugConfig.DebugValueSummary; +import static com.oracle.graal.debug.GraalDebugConfig.Dump; +import static com.oracle.graal.debug.GraalDebugConfig.Log; +import static com.oracle.graal.debug.GraalDebugConfig.MethodFilter; +import static com.oracle.graal.debug.GraalDebugConfig.Verify; +import static com.oracle.graal.debug.GraalDebugConfig.areScopedMetricsOrTimersEnabled; +import static jdk.internal.jvmci.inittimer.InitTimer.timer; -import java.lang.reflect.*; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; -import com.oracle.graal.api.collections.*; -import com.oracle.graal.api.replacements.*; -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.target.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.debug.*; -import com.oracle.graal.hotspot.logging.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.phases.tiers.*; -import com.oracle.graal.replacements.*; -import com.oracle.graal.runtime.*; +import jdk.internal.jvmci.code.Architecture; +import jdk.internal.jvmci.code.stack.InspectedFrameVisitor; +import jdk.internal.jvmci.code.stack.StackIntrospection; +import jdk.internal.jvmci.common.JVMCIError; +import jdk.internal.jvmci.hotspot.CompilerToVM; +import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime; +import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider; +import jdk.internal.jvmci.hotspot.HotSpotProxified; +import jdk.internal.jvmci.hotspot.HotSpotResolvedJavaMethodImpl; +import jdk.internal.jvmci.hotspot.HotSpotStackFrameReference; +import jdk.internal.jvmci.hotspot.HotSpotVMConfig; +import jdk.internal.jvmci.inittimer.InitTimer; +import jdk.internal.jvmci.meta.JavaKind; +import jdk.internal.jvmci.meta.ResolvedJavaMethod; +import jdk.internal.jvmci.runtime.JVMCI; +import jdk.internal.jvmci.runtime.JVMCIBackend; -import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.code.stack.*; -import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.inittimer.*; -import jdk.internal.jvmci.meta.*; -import jdk.internal.jvmci.runtime.*; +import com.oracle.graal.api.collections.CollectionsProvider; +import com.oracle.graal.api.replacements.SnippetReflectionProvider; +import com.oracle.graal.api.runtime.GraalRuntime; +import com.oracle.graal.compiler.target.Backend; +import com.oracle.graal.debug.Debug; +import com.oracle.graal.debug.DebugEnvironment; +import com.oracle.graal.debug.TTY; +import com.oracle.graal.graph.DefaultNodeCollectionsProvider; +import com.oracle.graal.graph.NodeCollectionsProvider; +import com.oracle.graal.hotspot.debug.BenchmarkCounters; +import com.oracle.graal.hotspot.meta.HotSpotProviders; +import com.oracle.graal.phases.tiers.CompilerConfiguration; +import com.oracle.graal.replacements.SnippetCounter; +import com.oracle.graal.runtime.RuntimeProvider; //JaCoCo Exclude @@ -143,10 +160,6 @@ HotSpotPrintInlining.setValue(config.printInlining); } - if (Boolean.valueOf(System.getProperty("graal.printconfig"))) { - printConfig(config); - } - CompilerConfiguration compilerConfiguration = compilerFactory.createCompilerConfiguration(); JVMCIBackend hostJvmciBackend = jvmciRuntime.getHostJVMCIBackend(); @@ -236,21 +249,6 @@ return backend; } - private static void printConfig(HotSpotVMConfig config) { - Field[] fields = config.getClass().getDeclaredFields(); - Map<String, Field> sortedFields = new TreeMap<>(); - for (Field f : fields) { - f.setAccessible(true); - sortedFields.put(f.getName(), f); - } - for (Field f : sortedFields.values()) { - try { - Logger.info(String.format("%9s %-40s = %s", f.getType().getSimpleName(), f.getName(), Logger.pretty(f.get(config)))); - } catch (Exception e) { - } - } - } - public HotSpotProviders getHostProviders() { return getHostBackend().getProviders(); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java Wed Sep 09 11:50:28 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalVMEventListener.java Wed Sep 09 21:31:22 2015 +0200 @@ -22,15 +22,23 @@ */ package com.oracle.graal.hotspot; -import java.lang.reflect.*; -import java.util.*; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Map; +import java.util.TreeMap; -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.logging.*; +import jdk.internal.jvmci.code.CompilationResult; +import jdk.internal.jvmci.code.InstalledCode; +import jdk.internal.jvmci.hotspot.HotSpotCodeCacheProvider; +import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime; +import jdk.internal.jvmci.hotspot.HotSpotVMConfig; +import jdk.internal.jvmci.hotspot.HotSpotVMEventListener; +import jdk.internal.jvmci.service.ServiceProvider; -import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.service.*; +import com.oracle.graal.debug.Debug; +import com.oracle.graal.debug.TTY; @ServiceProvider(HotSpotVMEventListener.class) public class HotSpotGraalVMEventListener implements HotSpotVMEventListener { @@ -51,31 +59,73 @@ } @Override - public CompilerToVM completeInitialization(HotSpotJVMCIRuntime runtime, CompilerToVM compilerToVM) { - CompilerToVM toVM = compilerToVM; - if (CountingProxy.ENABLED) { - toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); - } - - if (Boolean.valueOf(System.getProperty("jvmci.printconfig"))) { + public void completeInitialization(HotSpotJVMCIRuntime runtime) { + if (Boolean.valueOf(System.getProperty("jvmci.printconfig")) || Boolean.valueOf(System.getProperty("graal.printconfig"))) { printConfig(runtime.getConfig()); } - - return toVM; } private static void printConfig(HotSpotVMConfig config) { Field[] fields = config.getClass().getDeclaredFields(); Map<String, Field> sortedFields = new TreeMap<>(); for (Field f : fields) { - f.setAccessible(true); - sortedFields.put(f.getName(), f); + if (!f.isSynthetic() && !Modifier.isStatic(f.getModifiers())) { + f.setAccessible(true); + sortedFields.put(f.getName(), f); + } } for (Field f : sortedFields.values()) { try { - Logger.info(String.format("%9s %-40s = %s", f.getType().getSimpleName(), f.getName(), Logger.pretty(f.get(config)))); + TTY.print("%9s %-40s = %s%n", f.getType().getSimpleName(), f.getName(), pretty(f.get(config))); } catch (Exception e) { } } } + + private static String pretty(Object value) { + if (value == null) { + return "null"; + } + + Class<?> klass = value.getClass(); + if (value instanceof String) { + return "\"" + value + "\""; + } else if (value instanceof Method) { + return "method \"" + ((Method) value).getName() + "\""; + } else if (value instanceof Class<?>) { + return "class \"" + ((Class<?>) value).getSimpleName() + "\""; + } else if (value instanceof Integer) { + if ((Integer) value < 10) { + return value.toString(); + } + return value + " (0x" + Integer.toHexString((Integer) value) + ")"; + } else if (value instanceof Long) { + if ((Long) value < 10 && (Long) value > -10) { + return value + "l"; + } + return value + "l (0x" + Long.toHexString((Long) value) + "l)"; + } else if (klass.isArray()) { + StringBuilder str = new StringBuilder(); + int dimensions = 0; + while (klass.isArray()) { + dimensions++; + klass = klass.getComponentType(); + } + int length = Array.getLength(value); + str.append(klass.getSimpleName()).append('[').append(length).append(']'); + for (int i = 1; i < dimensions; i++) { + str.append("[]"); + } + str.append(" {"); + for (int i = 0; i < length; i++) { + str.append(pretty(Array.get(value, i))); + if (i < length - 1) { + str.append(", "); + } + } + str.append('}'); + return str.toString(); + } + return value.toString(); + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTTYStreamProvider.java Wed Sep 09 21:31:22 2015 +0200 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015, 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.hotspot; + +import java.io.PrintStream; + +import jdk.internal.jvmci.options.Option; +import jdk.internal.jvmci.options.OptionType; +import jdk.internal.jvmci.service.ServiceProvider; + +import com.oracle.graal.debug.TTYStreamProvider; + +@ServiceProvider(TTYStreamProvider.class) +class HotSpotTTYStreamProvider implements TTYStreamProvider { + + public static class Options { + + // @formatter:off + @Option(help = "File to which logging is sent. A %p in the name will be replaced with a string identifying the process, usually the process id.", type = OptionType.Expert) + public static final PrintStreamOption LogFile = new PrintStreamOption(); + // @formatter:on + } + + public PrintStream getStream() { + return Options.LogFile.getStream(); + } +}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java Wed Sep 09 11:50:28 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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.hotspot.logging; - -import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import com.oracle.graal.debug.*; - -/** - * A java.lang.reflect proxy that hierarchically logs all method invocations along with their - * parameters and return values. - */ -public class CountingProxy<T> implements InvocationHandler { - - public static final boolean ENABLED = Boolean.valueOf(System.getProperty("jvmci.countcalls")); - - private T delegate; - - private ConcurrentHashMap<Method, AtomicLong> calls = new ConcurrentHashMap<>(); - - public CountingProxy(T delegate) { - assert ENABLED; - TTY.println("Counting proxy for " + delegate.getClass().getSimpleName() + " created"); - this.delegate = delegate; - proxies.add(this); - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - int argCount = args == null ? 0 : args.length; - if (method.getParameterTypes().length != argCount) { - throw new RuntimeException("wrong parameter count"); - } - final Object result; - if (!calls.containsKey(method)) { - calls.putIfAbsent(method, new AtomicLong(0)); - } - AtomicLong count = calls.get(method); - count.incrementAndGet(); - try { - if (args == null) { - result = method.invoke(delegate); - } else { - result = method.invoke(delegate, args); - } - } catch (InvocationTargetException e) { - throw e.getCause(); - } - return result; - } - - public static <T> T getProxy(Class<T> interf, T delegate) { - Class<?>[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); - Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new CountingProxy<>(delegate)); - return interf.cast(obj); - } - - private static ArrayList<CountingProxy<?>> proxies = new ArrayList<>(); - - static { - if (ENABLED) { - Runtime.getRuntime().addShutdownHook(new Thread() { - - @Override - public void run() { - for (CountingProxy<?> proxy : proxies) { - proxy.print(); - } - } - }); - } - } - - protected void print() { - long sum = 0; - for (Map.Entry<Method, AtomicLong> entry : calls.entrySet()) { - Method method = entry.getKey(); - long count = entry.getValue().get(); - sum += count; - TTY.println(delegate.getClass().getSimpleName() + "." + method.getName() + ": " + count); - } - TTY.println(delegate.getClass().getSimpleName() + " calls: " + sum); - } -}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/HotSpotTTYStreamProvider.java Wed Sep 09 11:50:28 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2015, 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.hotspot.logging; - -import java.io.*; - -import jdk.internal.jvmci.options.*; -import jdk.internal.jvmci.service.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.*; - -@ServiceProvider(TTYStreamProvider.class) -class HotSpotTTYStreamProvider implements TTYStreamProvider { - - public static class Options { - - // @formatter:off - @Option(help = "File to which logging is sent. A %p in the name will be replaced with a string identifying the process, usually the process id.", type = OptionType.Expert) - public static final PrintStreamOption LogFile = new PrintStreamOption(); - // @formatter:on - } - - public PrintStream getStream() { - return Options.LogFile.getStream(); - } -}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java Wed Sep 09 11:50:28 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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.hotspot.logging; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.debug.*; - -import jdk.internal.jvmci.hotspot.*; - -/** - * Scoped logging class used to display the call hierarchy of {@link CompilerToVM} calls. - */ -public class Logger { - - public static final boolean ENABLED = Boolean.valueOf(System.getProperty("jvmci.debug")); - private static final int SPACING = 4; - private static final ThreadLocal<Logger> loggerTL; - - private Deque<Boolean> openStack = new LinkedList<>(); - private boolean open = false; - private int level = 0; - - private static final PrintStream out; - - static { - if (ENABLED) { - loggerTL = new ThreadLocal<Logger>() { - - @Override - protected Logger initialValue() { - return new Logger(); - } - }; - } else { - loggerTL = null; - } - - PrintStream ps = null; - String filename = System.getProperty("jvmci.info_file"); - if (filename != null && !"".equals(filename)) { - try { - ps = new PrintStream(new FileOutputStream(filename)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - ps = null; - } - } - out = ps; - if (out != null) { - out.println("start: " + new Date()); - } - } - - public static void info(String message) { - if (ENABLED) { - log(message); - } else { - TTY.println(message); - } - if (out != null) { - out.println(message); - out.flush(); - } - } - - public static void log(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - for (String line : message.split("\n")) { - if (logger.open) { - TTY.println("..."); - logger.open = false; - } - TTY.print(space(logger.level)); - TTY.println(line); - } - } - } - - public static void startScope(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - if (logger.open) { - TTY.println("..."); - logger.open = false; - } - TTY.print(space(logger.level)); - TTY.print(message); - logger.openStack.push(logger.open); - logger.open = true; - logger.level++; - } - } - - public static void endScope(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - logger.level--; - if (logger.open) { - TTY.println(message); - } else { - TTY.println(space(logger.level) + "..." + message); - } - logger.open = logger.openStack.pop(); - } - } - - private static String[] spaces = new String[50]; - - private static String space(int count) { - assert count >= 0; - String result; - if (count >= spaces.length || spaces[count] == null) { - StringBuilder str = new StringBuilder(); - for (int i = 0; i < count * SPACING; i++) { - str.append(' '); - } - result = str.toString(); - if (count < spaces.length) { - spaces[count] = result; - } - } else { - result = spaces[count]; - } - return result; - } - - public static String pretty(Object value) { - if (value == null) { - return "null"; - } - - Class<?> klass = value.getClass(); - if (value instanceof Void) { - return "void"; - } else if (value instanceof String) { - return "\"" + value + "\""; - } else if (value instanceof Method) { - return "method \"" + ((Method) value).getName() + "\""; - } else if (value instanceof Class<?>) { - return "class \"" + ((Class<?>) value).getSimpleName() + "\""; - } else if (value instanceof Integer) { - if ((Integer) value < 10) { - return value.toString(); - } - return value + " (0x" + Integer.toHexString((Integer) value) + ")"; - } else if (value instanceof Long) { - if ((Long) value < 10 && (Long) value > -10) { - return value + "l"; - } - return value + "l (0x" + Long.toHexString((Long) value) + "l)"; - } else if (klass.isArray()) { - StringBuilder str = new StringBuilder(); - int dimensions = 0; - while (klass.isArray()) { - dimensions++; - klass = klass.getComponentType(); - } - int length = Array.getLength(value); - str.append(klass.getSimpleName()).append('[').append(length).append(']'); - for (int i = 1; i < dimensions; i++) { - str.append("[]"); - } - str.append(" {"); - for (int i = 0; i < length; i++) { - str.append(pretty(Array.get(value, i))); - if (i < length - 1) { - str.append(", "); - } - } - str.append('}'); - return str.toString(); - } - - return value.toString(); - } -}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/ProxyUtil.java Wed Sep 09 11:50:28 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011, 2015, 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.hotspot.logging; - -import java.util.*; - -public final class ProxyUtil { - - public static Class<?>[] getAllInterfaces(Class<?> clazz) { - HashSet<Class<?>> interfaces = new HashSet<>(); - getAllInterfaces(clazz, interfaces); - return interfaces.toArray(new Class<?>[interfaces.size()]); - } - - private static void getAllInterfaces(Class<?> clazz, HashSet<Class<?>> interfaces) { - for (Class<?> iface : clazz.getInterfaces()) { - if (!interfaces.contains(iface)) { - interfaces.add(iface); - getAllInterfaces(iface, interfaces); - } - } - if (clazz.getSuperclass() != null) { - getAllInterfaces(clazz.getSuperclass(), interfaces); - } - } -}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/package-info.java Wed Sep 09 11:50:28 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/package-info.java Wed Sep 09 21:31:22 2015 +0200 @@ -20,10 +20,5 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/** - * Package containing the runtime interface (defined in the CRI project) implementation for HotSpot. - * There is a class that bridges from the C++ to the Java side (VMToCompilerImpl.java) and one that bridges - * from the Java to the C++ side (CompilerToVMImpl.java). - */ package com.oracle.graal.hotspot;