# HG changeset patch # User Tom Rodriguez # Date 1385499820 28800 # Node ID 57ea5bfec214499efec03789b3c1793e6d3c843f # Parent 85b60abfd11faf8f310c7f7803f4e183f0b3ae86# Parent bc868f83bcec413de3eef8898381e805e4288a81 Merge diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaMethodProfile.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaMethodProfile.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaMethodProfile.java Tue Nov 26 13:03:40 2013 -0800 @@ -45,8 +45,8 @@ private static final long serialVersionUID = 5418813647187024693L; - public ProfiledMethod(ResolvedJavaMethod item, double probability) { - super(item, probability); + public ProfiledMethod(ResolvedJavaMethod method, double probability) { + super(method, probability); } /** diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Tue Nov 26 13:03:40 2013 -0800 @@ -22,6 +22,8 @@ */ package com.oracle.graal.api.meta; +import static java.lang.reflect.Modifier.*; + import java.util.*; import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; @@ -142,8 +144,9 @@ private static final long serialVersionUID = 1481773321889860837L; - public ProfiledType(ResolvedJavaType item, double probability) { - super(item, probability); + public ProfiledType(ResolvedJavaType type, double probability) { + super(type, probability); + assert type.isArray() || !isAbstract(type.getModifiers()) : type; } /** diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java --- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java Tue Nov 26 13:03:40 2013 -0800 @@ -88,7 +88,7 @@ static { logger = Logger.getLogger(propPkgName); - logLevel = Level.parse(System.getProperty("kerneltester.logLevel", "SEVERE")); + logLevel = Level.parse(System.getProperty("kerneltester.logLevel", "OFF")); // This block configure the logger with handler and formatter. consoleHandler = new ConsoleHandler(); diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java Tue Nov 26 13:03:40 2013 -0800 @@ -331,10 +331,15 @@ out[gid] = val; } - private void test(String snippet) { - StructuredGraph graph = parse(snippet); - HSAILCompilationResult compResult = HSAILCompilationResult.getHSAILCompilationResult(graph); - TTY.println("code generated for " + snippet + ":\n" + compResult.getHSAILCode()); + private void test(final String snippet) { + Debug.scope("HSAILTestCode", new Runnable() { + StructuredGraph graph = parse(snippet); + + public void run() { + HSAILCompilationResult compResult = HSAILCompilationResult.getHSAILCompilationResult(graph); + Debug.log("HSAIL code generated for %s:%n%s", snippet, compResult.getHSAILCode()); + } + }); } public static void nBodySpill(float[] inxyz, float[] outxyz, float[] invxyz, float[] outvxyz, int gid) { diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethod16InArraysTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethod16InArraysTest.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethod16InArraysTest.java Tue Nov 26 13:03:40 2013 -0800 @@ -23,7 +23,10 @@ package com.oracle.graal.compiler.hsail.test; -import org.junit.Test; +import org.junit.*; + +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.internal.*; /** * Tests the addition of elements from sixteen input arrays. @@ -60,7 +63,17 @@ */ @Test(expected = java.lang.ClassCastException.class) public void test() { - testGeneratedHsail(); + DebugConfig debugConfig = DebugScope.getConfig(); + DebugConfig noInterceptConfig = new DelegatingDebugConfig(debugConfig) { + @Override + public RuntimeException interceptException(Throwable e) { + return null; + } + }; + + try (DebugConfigScope s = Debug.setConfig(noInterceptConfig)) { + testGeneratedHsail(); + } } } diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Tue Nov 26 13:03:40 2013 -0800 @@ -107,7 +107,8 @@ public static void sandbox(String name, DebugConfig config, Runnable runnable) { if (ENABLED) { - DebugScope.getInstance().scope(name, runnable, null, true, config, new Object[0]); + DebugConfig sandboxConfig = config == null ? DebugScope.getConfig() : config; + DebugScope.getInstance().scope(name, runnable, null, sandboxConfig, new Object[0]); } else { runnable.run(); } @@ -124,7 +125,8 @@ */ public static void sandbox(String name, Object[] context, DebugConfig config, Runnable runnable) { if (ENABLED) { - DebugScope.getInstance().scope(name, runnable, null, true, config, context); + DebugConfig sandboxConfig = config == null ? DebugScope.getConfig() : config; + DebugScope.getInstance().scope(name, runnable, null, sandboxConfig, context); } else { runnable.run(); } @@ -141,7 +143,8 @@ */ public static T sandbox(String name, Object[] context, DebugConfig config, Callable callable) { if (ENABLED) { - return DebugScope.getInstance().scope(name, null, callable, true, config, context); + DebugConfig sandboxConfig = config == null ? DebugScope.getConfig() : config; + return DebugScope.getInstance().scope(name, null, callable, sandboxConfig, context); } else { return DebugScope.call(callable); } @@ -161,7 +164,7 @@ public static void scope(String name, Object[] context, Runnable runnable) { if (ENABLED) { - DebugScope.getInstance().scope(name, runnable, null, false, null, context); + DebugScope.getInstance().scope(name, runnable, null, null, context); } else { runnable.run(); } @@ -181,7 +184,7 @@ public static T scope(String name, Object[] context, Callable callable) { if (ENABLED) { - return DebugScope.getInstance().scope(name, null, callable, false, null, context); + return DebugScope.getInstance().scope(name, null, callable, null, context); } else { return DebugScope.call(callable); } @@ -376,9 +379,19 @@ } } - public static void setConfig(DebugConfig config) { + /** + * Changes the debug configuration for the current thread. + * + * @param config new configuration to use for the current thread + * @return an object that when {@linkplain DebugConfigScope#close() closed} will restore the + * debug configuration for the current thread to what it was before this method was + * called + */ + public static DebugConfigScope setConfig(DebugConfig config) { if (ENABLED) { - DebugScope.getInstance().setConfig(config); + return new DebugConfigScope(config); + } else { + return null; } } diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfigScope.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfigScope.java Tue Nov 26 13:03:40 2013 -0800 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012, 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.debug; + +import com.oracle.graal.debug.internal.*; + +/** + * A utility for scoping a change to the current debug + * {@linkplain DebugScope#setConfig(DebugConfig) configuration}. For example: + * + *
+ *     DebugConfig config = ...;
+ *     try (DebugConfigScope s = new DebugConfigScope(config)) {
+ *         // ...
+ *     }
+ * 
+ */ +public class DebugConfigScope implements AutoCloseable { + + private final DebugConfig current; + + /** + * Sets the current debug {@linkplain DebugScope#setConfig(DebugConfig) configuration} to a + * given value and creates an object that when {@linkplain #close() closed} resets the + * configuration to the {@linkplain DebugScope#getConfig() current} configuration. + */ + public DebugConfigScope(DebugConfig config) { + this.current = DebugScope.getConfig(); + DebugScope.getInstance().setConfig(config); + } + + public void close() { + DebugScope.getInstance().setConfig(current); + } +} diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DelegatingDebugConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DelegatingDebugConfig.java Tue Nov 26 13:03:40 2013 -0800 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2013, 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.debug; + +import java.io.*; +import java.util.*; + +public class DelegatingDebugConfig implements DebugConfig { + + protected final DebugConfig delegate; + + public DelegatingDebugConfig(DebugConfig delegate) { + this.delegate = delegate; + } + + @Override + public boolean isLogEnabled() { + return delegate.isLogEnabled(); + } + + @Override + public boolean isMeterEnabled() { + return delegate.isMeterEnabled(); + } + + @Override + public boolean isDumpEnabled() { + return delegate.isDumpEnabled(); + } + + @Override + public boolean isTimeEnabled() { + return delegate.isTimeEnabled(); + } + + @Override + public RuntimeException interceptException(Throwable e) { + return delegate.interceptException(e); + } + + @Override + public Collection dumpHandlers() { + return delegate.dumpHandlers(); + } + + @Override + public PrintStream output() { + return delegate.output(); + } + + @Override + public void addToContext(Object o) { + delegate.addToContext(o); + } + + @Override + public void removeFromContext(Object o) { + delegate.removeFromContext(o); + } +} diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Tue Nov 26 13:03:40 2013 -0800 @@ -28,7 +28,7 @@ import com.oracle.graal.debug.*; -public final class DebugScope { +public final class DebugScope implements AutoCloseable { private final class IndentImpl implements Indent { @@ -99,6 +99,8 @@ private static ThreadLocal lastExceptionThrownTL = new ThreadLocal<>(); private final DebugScope parent; + private final DebugConfig parentConfig; + private final boolean sandbox; private IndentImpl lastUsedIndent; private boolean logScopeName; @@ -118,7 +120,7 @@ public static DebugScope getInstance() { DebugScope result = instanceTL.get(); if (result == null) { - DebugScope topLevelDebugScope = new DebugScope(Thread.currentThread().getName(), "", null); + DebugScope topLevelDebugScope = new DebugScope(Thread.currentThread().getName(), "", null, false); instanceTL.set(topLevelDebugScope); DebugValueMap.registerTopLevel(topLevelDebugScope.getValueMap()); return topLevelDebugScope; @@ -131,8 +133,10 @@ return configTL.get(); } - private DebugScope(String name, String qualifiedName, DebugScope parent, Object... context) { + private DebugScope(String name, String qualifiedName, DebugScope parent, boolean sandbox, Object... context) { this.parent = parent; + this.sandbox = sandbox; + this.parentConfig = getConfig(); this.context = context; this.qualifiedName = qualifiedName; if (parent != null) { @@ -162,6 +166,12 @@ } } + public void close() { + context = null; + instanceTL.set(parent); + setConfig(parentConfig); + } + public boolean isDumpEnabled() { return dumpEnabled; } @@ -227,32 +237,28 @@ * @param newName the name of the new scope * @param runnable the task to run (must be null iff {@code callable} is not null) * @param callable the task to run (must be null iff {@code runnable} is not null) - * @param sandbox specifies if the scope is a child of the current scope or a top level scope - * @param sandboxConfig the config to use of a new top level scope (ignored if - * {@code sandbox == false}) + * @param sandboxConfig if non-null, a new top level scope is entered with this configuration * @param newContext context objects of the new scope * @return the value returned by the task */ - public T scope(String newName, Runnable runnable, Callable callable, boolean sandbox, DebugConfig sandboxConfig, Object[] newContext) { - DebugScope oldContext = getInstance(); - DebugConfig oldConfig = getConfig(); - DebugScope newChild = null; - if (sandbox) { - newChild = new DebugScope(newName, newName, null, newContext); + public T scope(String newName, Runnable runnable, Callable callable, DebugConfig sandboxConfig, Object[] newContext) { + try (DebugScope s = openScope(newName, sandboxConfig, newContext)) { + return executeScope(runnable, callable); + } + } + + public DebugScope openScope(String newName, DebugConfig sandboxConfig, Object... newContext) { + DebugScope newScope = null; + if (sandboxConfig != null) { + newScope = new DebugScope(newName, newName, this, true, newContext); setConfig(sandboxConfig); } else { - newChild = oldContext.createChild(newName, newContext); + newScope = this.createChild(newName, newContext); } - instanceTL.set(newChild); - newChild.setLogEnabled(oldContext.isLogEnabled()); - newChild.updateFlags(); - try { - return executeScope(runnable, callable); - } finally { - newChild.context = null; - instanceTL.set(oldContext); - setConfig(oldConfig); - } + instanceTL.set(newScope); + newScope.setLogEnabled(this.isLogEnabled()); + newScope.updateFlags(); + return newScope; } private T executeScope(Runnable runnable, Callable callable) { @@ -315,7 +321,7 @@ return new RuntimeException("Exception while intercepting exception", t); } } - }, false, null, new Object[]{e}); + }, null, new Object[]{e}); } return null; } @@ -337,7 +343,7 @@ if (this.qualifiedName.length() > 0) { newQualifiedName = this.qualifiedName + SCOPE_SEP + newName; } - DebugScope result = new DebugScope(newName, newQualifiedName, this, newContext); + DebugScope result = new DebugScope(newName, newQualifiedName, this, false, newContext); return result; } @@ -360,7 +366,7 @@ private void selectScope() { while (currentScope != null && currentScope.context.length <= objectIndex) { - currentScope = currentScope.parent; + currentScope = currentScope.sandbox ? null : currentScope.parent; objectIndex = 0; } } diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Tue Nov 26 13:03:40 2013 -0800 @@ -693,9 +693,9 @@ }; DebugConfig debugConfig = DebugScope.getConfig(); - try { + DebugConfig fixedConfig = Debug.fixedConfig(false, false, false, false, debugConfig.dumpHandlers(), debugConfig.output()); + try (DebugConfigScope s = Debug.setConfig(fixedConfig)) { ReentrantNodeIterator.apply(closure, graph.start(), false, null); - Debug.setConfig(Debug.fixedConfig(false, false, false, false, debugConfig.dumpHandlers(), debugConfig.output())); new WriteBarrierVerificationPhase().apply(graph); } catch (AssertionError error) { /* @@ -704,8 +704,6 @@ */ Assert.assertTrue(error.getMessage().contains("Write barrier must be present")); return error; - } finally { - Debug.setConfig(debugConfig); } return null; } diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Tue Nov 26 13:03:40 2013 -0800 @@ -209,8 +209,15 @@ if (config.compileTheWorldStopAt != Integer.MAX_VALUE) { GraalOptions.CompileTheWorldStopAt.setValue(config.compileTheWorldStopAt); } - GraalOptions.HotSpotPrintCompilation.setValue(config.printCompilation); - GraalOptions.HotSpotPrintInlining.setValue(config.printInlining); + + // Only set HotSpotPrintCompilation and HotSpotPrintInlining if they still have their + // default value (false). + if (GraalOptions.HotSpotPrintCompilation.getValue() == false) { + GraalOptions.HotSpotPrintCompilation.setValue(config.printCompilation); + } + if (GraalOptions.HotSpotPrintInlining.getValue() == false) { + GraalOptions.HotSpotPrintInlining.setValue(config.printInlining); + } if (Boolean.valueOf(System.getProperty("graal.printconfig"))) { printConfig(config); diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue Nov 26 13:03:40 2013 -0800 @@ -1143,6 +1143,11 @@ @HotSpotVMConstant(name = "vmIntrinsics::_linkToSpecial") @Stable public int vmIntrinsicLinkToSpecial; @HotSpotVMConstant(name = "vmIntrinsics::_linkToInterface") @Stable public int vmIntrinsicLinkToInterface; + @HotSpotVMConstant(name = "GraalEnv::ok") @Stable public int codeInstallResultOk; + @HotSpotVMConstant(name = "GraalEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; + @HotSpotVMConstant(name = "GraalEnv::cache_full") @Stable public int codeInstallResultCacheFull; + @HotSpotVMConstant(name = "GraalEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge; + public boolean check() { for (Field f : getClass().getDeclaredFields()) { int modifiers = f.getModifiers(); diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Tue Nov 26 13:03:40 2013 -0800 @@ -27,6 +27,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; @@ -132,9 +133,49 @@ Object lookupAppendixInPool(HotSpotResolvedObjectType pool, int cpi, byte opcode); - // Must be kept in sync with enum in graalEnv.hpp public enum CodeInstallResult { - OK, DEPENDENCIES_FAILED, CACHE_FULL, CODE_TOO_LARGE + OK("ok"), DEPENDENCIES_FAILED("dependencies failed"), CACHE_FULL("code cache is full"), CODE_TOO_LARGE("code is too large"); + + private int value; + private String message; + + private CodeInstallResult(String name) { + HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); + switch (name) { + case "ok": + this.value = config.codeInstallResultOk; + break; + case "dependencies failed": + this.value = config.codeInstallResultDependenciesFailed; + break; + case "code cache is full": + this.value = config.codeInstallResultCacheFull; + break; + case "code is too large": + this.value = config.codeInstallResultCodeTooLarge; + break; + default: + throw GraalInternalError.shouldNotReachHere("unknown enum name " + name); + } + this.message = name; + } + + /** + * Returns the enum object for the given value. + */ + public static CodeInstallResult getEnum(int value) { + for (CodeInstallResult e : values()) { + if (e.value == value) { + return e; + } + } + throw GraalInternalError.shouldNotReachHere("unknown enum value " + value); + } + + @Override + public String toString() { + return message; + } } /** diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Tue Nov 26 13:03:40 2013 -0800 @@ -39,7 +39,7 @@ @Override public CodeInstallResult installCode(HotSpotCompiledCode compiledCode, HotSpotInstalledCode code, SpeculationLog speculationLog) { - return CodeInstallResult.values()[installCode0(compiledCode, code, (speculationLog == null) ? null : speculationLog.getRawMap())]; + return CodeInstallResult.getEnum(installCode0(compiledCode, code, (speculationLog == null) ? null : speculationLog.getRawMap())); } @Override diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Tue Nov 26 13:03:40 2013 -0800 @@ -214,7 +214,7 @@ private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor { /** - * Corresponds to DS_RECOMPILE_BIT defined in deoptimization.cpp. + * Corresponds to {@code exception_seen_flag}. */ private static final int EXCEPTIONS_MASK = 0x2; @@ -287,17 +287,7 @@ return 0; } - public StringBuilder appendFlagsTo(StringBuilder sb, HotSpotMethodData data, int pos) { - int flags = getFlags(data, pos); - if (flags != 0) { - sb.append(format("flags(0x%02x)", flags)); - } - return sb; - } - - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return appendFlagsTo(sb, data, pos); - } + public abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); } private static class NoMethodData extends AbstractMethodData { @@ -321,6 +311,11 @@ public TriState getExceptionSeen(HotSpotMethodData data, int position) { return exceptionSeen; } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + return sb; + } } private static class BitData extends AbstractMethodData { @@ -341,6 +336,11 @@ public TriState getNullSeen(HotSpotMethodData data, int position) { return TriState.get((getFlags(data, position) & BIT_DATA_NULL_SEEN_FLAG) != 0); } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + return sb.append(format("exception_seen(%s)", getExceptionSeen(data, pos))); + } } private static class CounterData extends BitData { @@ -368,7 +368,7 @@ @Override public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return appendFlagsTo(sb, data, pos).append(format("count(%d)", getCounterValue(data, pos))); + return sb.append(format("count(%d)", getCounterValue(data, pos))); } } @@ -403,7 +403,7 @@ @Override public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return appendFlagsTo(sb, data, pos).append(format("taken(%d) displacement(%d)", getExecutionCount(data, pos), getTakenDisplacement(data, pos))); + return sb.append(format("taken(%d) displacement(%d)", getExecutionCount(data, pos), getTakenDisplacement(data, pos))); } } @@ -494,9 +494,9 @@ @Override public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - super.appendTo(sb, data, pos); RawItemProfile profile = getRawTypeProfile(data, pos); - sb.append(format("nonprofiled_count(%d) entries(%d)", getTypesNotRecordedExecutionCount(data, pos), profile.entries)); + TriState nullSeen = getNullSeen(data, pos); + sb.append(format("count(%d) null_seen(%s) nonprofiled_count(%d) entries(%d)", getCounterValue(data, pos), nullSeen, getTypesNotRecordedExecutionCount(data, pos), profile.entries)); for (int i = 0; i < profile.entries; i++) { long count = profile.counts[i]; sb.append(format("%n %s (%d, %4.2f)", MetaUtil.toJavaName(profile.items[i]), count, (double) count / profile.totalCount)); @@ -619,7 +619,7 @@ @Override public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { RawItemProfile profile = getRawMethodProfile(data, pos); - super.appendTo(sb, data, pos).append(format("%nmethod_entries(%d)", profile.entries)); + super.appendTo(sb.append(format("exception_seen(%s) ", getExceptionSeen(data, pos))), data, pos).append(format("%nmethod_entries(%d)", profile.entries)); for (int i = 0; i < profile.entries; i++) { long count = profile.counts[i]; sb.append(format("%n %s (%d, %4.2f)", MetaUtil.format("%H.%n(%p)", profile.items[i]), count, (double) count / profile.totalCount)); @@ -669,8 +669,7 @@ long taken = data.readUnsignedInt(pos, TAKEN_COUNT_OFFSET); long notTaken = data.readUnsignedInt(pos, NOT_TAKEN_COUNT_OFFSET); double takenProbability = getBranchTakenProbability(data, pos); - return appendFlagsTo(sb, data, pos).append( - format("taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)", taken, takenProbability, notTaken, 1.0D - takenProbability, getTakenDisplacement(data, pos))); + return sb.append(format("taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)", taken, takenProbability, notTaken, 1.0D - takenProbability, getTakenDisplacement(data, pos))); } } diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue Nov 26 13:03:40 2013 -0800 @@ -34,6 +34,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.ProfilingInfo.TriState; +import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.debug.*; @@ -282,6 +283,8 @@ return getCompiledCodeSize() > 0; } + private static final String TraceMethodDataFilter = System.getProperty("graal.traceMethodDataFilter"); + @Override public ProfilingInfo getProfilingInfo() { ProfilingInfo info; @@ -290,6 +293,10 @@ long metaspaceMethodData = unsafeReadWord(metaspaceMethod + runtime().getConfig().methodDataOffset); if (metaspaceMethodData != 0) { methodData = new HotSpotMethodData(metaspaceMethodData); + if (TraceMethodDataFilter != null && MetaUtil.format("%H.%n", this).contains(TraceMethodDataFilter)) { + TTY.println("Raw method data for " + MetaUtil.format("%H.%n(%p)", this) + ":"); + TTY.println(methodData.toString()); + } } } diff -r 85b60abfd11f -r 57ea5bfec214 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Mon Nov 25 15:31:20 2013 -0800 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue Nov 26 13:03:40 2013 -0800 @@ -1139,10 +1139,7 @@ } ResolvedJavaType type = ptypes[0].getType(); - if (isAbstract(type.getModifiers())) { - // In TieredCompilation mode, C1 can generate profiles containing abstract types - return null; - } + assert !isAbstract(type.getModifiers()); ResolvedJavaMethod concrete = type.resolveMethod(targetMethod); if (!checkTargetConditions(data, replacements, invoke, concrete, optimisticOpts)) { return null; @@ -1213,10 +1210,8 @@ int index = concreteMethods.indexOf(concrete); if (index == -1) { notRecordedTypeProbability += type.getProbability(); - } else if (isAbstract(type.getType().getModifiers())) { - // In TieredCompilation mode, C1 can generate profiles containing abstract types - notRecordedTypeProbability += type.getProbability(); } else { + assert !isAbstract(type.getType().getModifiers()); usedTypes.add(type); typesToConcretes.add(index); } diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/c1/c1_GraphBuilder.cpp --- a/src/share/vm/c1/c1_GraphBuilder.cpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Tue Nov 26 13:03:40 2013 -0800 @@ -4340,11 +4340,15 @@ #endif // PRODUCT void GraphBuilder::profile_call(ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined) { - // A default method's holder is an interface - if (known_holder != NULL && known_holder->is_interface()) { - assert(known_holder->is_instance_klass() && ((ciInstanceKlass*)known_holder)->has_default_methods(), "should be default method"); - known_holder = NULL; + assert(known_holder == NULL || (known_holder->is_instance_klass() && + (!known_holder->is_interface() || + ((ciInstanceKlass*)known_holder)->has_default_methods())), "should be default method"); + if (known_holder != NULL) { + if (known_holder->exact_klass() == NULL) { + known_holder = compilation()->cha_exact_type(known_holder); + } } + append(new ProfileCall(method(), bci(), callee, recv, known_holder, obj_args, inlined)); } diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Tue Nov 26 13:03:40 2013 -0800 @@ -361,8 +361,13 @@ // constructor used to create a method CodeInstaller::CodeInstaller(Handle& compiled_code, GraalEnv::CodeInstallResult& result, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations) { - GraalCompiler::initialize_buffer_blob(); - CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); + BufferBlob* buffer_blob = GraalCompiler::initialize_buffer_blob(); + if (buffer_blob == NULL) { + result = GraalEnv::cache_full; + return; + } + + CodeBuffer buffer(buffer_blob); jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); initialize_assumptions(JNIHandles::resolve(compiled_code_obj)); diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/graal/graalCompiler.cpp Tue Nov 26 13:03:40 2013 -0800 @@ -56,7 +56,13 @@ _deopted_leaf_graph_count = 0; - initialize_buffer_blob(); + BufferBlob* buffer_blob = initialize_buffer_blob(); + if (buffer_blob == NULL) { + // If we are called from JNI_CreateJavaVM we cannot use set_state yet because it takes a lock. + // set_state(failed); + } else { + // set_state(initialized); + } JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment(); jclass klass = env->FindClass("com/oracle/graal/hotspot/bridge/CompilerToVMImpl"); @@ -106,10 +112,12 @@ _initialized = true; CompilationPolicy::completed_vm_startup(); if (bootstrap) { + // Avoid -Xcomp and -Xbatch problems by turning on interpreter and background compilation for bootstrapping. + FlagSetting a(UseInterpreter, true); + FlagSetting b(BackgroundCompilation, true); VMToCompiler::bootstrap(); } - #ifndef PRODUCT if (CompileTheWorld) { // We turn off CompileTheWorld so that Graal can @@ -163,14 +171,16 @@ return array; } -void GraalCompiler::initialize_buffer_blob() { - +BufferBlob* GraalCompiler::initialize_buffer_blob() { JavaThread* THREAD = JavaThread::current(); - if (THREAD->get_buffer_blob() == NULL) { - BufferBlob* blob = BufferBlob::create("Graal thread-local CodeBuffer", GraalNMethodSizeLimit); - guarantee(blob != NULL, "must create code buffer"); - THREAD->set_buffer_blob(blob); + BufferBlob* buffer_blob = THREAD->get_buffer_blob(); + if (buffer_blob == NULL) { + buffer_blob = BufferBlob::create("Graal thread-local CodeBuffer", GraalNMethodSizeLimit); + if (buffer_blob != NULL) { + THREAD->set_buffer_blob(buffer_blob); + } } + return buffer_blob; } void GraalCompiler::compile_method(methodHandle method, int entry_bci, jboolean blocking) { diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/graal/graalCompiler.hpp Tue Nov 26 13:03:40 2013 -0800 @@ -105,7 +105,7 @@ return cp_index; } - static void initialize_buffer_blob(); + static BufferBlob* initialize_buffer_blob(); }; // Tracing macros diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/graal/graalCompilerToGPU.cpp --- a/src/share/vm/graal/graalCompilerToGPU.cpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/graal/graalCompilerToGPU.cpp Tue Nov 26 13:03:40 2013 -0800 @@ -177,7 +177,9 @@ C2V_VMENTRY(jboolean, deviceInit, (JNIEnv *env, jobject)) if (gpu::is_available() == false || gpu::has_gpu_linkage() == false) { - tty->print_cr("deviceInit - not available / no linkage"); + if (TraceGPUInteraction) { + tty->print_cr("deviceInit - not available / no linkage"); + } return false; } if (gpu::is_initialized()) { @@ -190,7 +192,9 @@ C2V_VMENTRY(jint, availableProcessors, (JNIEnv *env, jobject)) if (gpu::is_available() == false || gpu::has_gpu_linkage() == false) { - tty->print_cr("deviceInit - not available / no linkage"); + if (TraceGPUInteraction) { + tty->print_cr("deviceInit - not available / no linkage"); + } return false; } return gpu::available_processors(); diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/graal/graalEnv.hpp --- a/src/share/vm/graal/graalEnv.hpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/graal/graalEnv.hpp Tue Nov 26 13:03:40 2013 -0800 @@ -58,7 +58,6 @@ public: - // Must be kept in sync with the enum in the HotSpot implementation of CompilerToVM enum CodeInstallResult { ok, dependencies_failed, diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/graal/vmStructs_graal.hpp --- a/src/share/vm/graal/vmStructs_graal.hpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/graal/vmStructs_graal.hpp Tue Nov 26 13:03:40 2013 -0800 @@ -26,14 +26,18 @@ #define SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP #include "compiler/abstractCompiler.hpp" +#include "graal/graalEnv.hpp" #define VM_STRUCTS_GRAAL(nonstatic_field, static_field) \ - \ static_field(java_lang_Class, _graal_mirror_offset, int) \ - \ #define VM_TYPES_GRAAL(declare_type, declare_toplevel_type) \ - \ +#define VM_INT_CONSTANTS_GRAAL(declare_constant) \ + declare_constant(Deoptimization::Reason_aliasing) \ + declare_constant(GraalEnv::ok) \ + declare_constant(GraalEnv::dependencies_failed) \ + declare_constant(GraalEnv::cache_full) \ + declare_constant(GraalEnv::code_too_large) \ #endif // SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/runtime/deoptimization.cpp --- a/src/share/vm/runtime/deoptimization.cpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/runtime/deoptimization.cpp Tue Nov 26 13:03:40 2013 -0800 @@ -1948,7 +1948,8 @@ "div0_check", "age" GRAAL_ONLY("|jsr_mismatch"), "predicate", - "loop_limit_check" + "loop_limit_check", + GRAAL_ONLY("aliasing") }; const char* Deoptimization::_trap_action_name[Action_LIMIT] = { // Note: Keep this in sync. with enum DeoptAction. diff -r 85b60abfd11f -r 57ea5bfec214 src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Mon Nov 25 15:31:20 2013 -0800 +++ b/src/share/vm/runtime/vmStructs.cpp Tue Nov 26 13:03:40 2013 -0800 @@ -2196,8 +2196,7 @@ declare_preprocessor_constant, \ declare_c1_constant, \ declare_c2_constant, \ - declare_c2_preprocessor_constant, \ - declare_graal_constant) \ + declare_c2_preprocessor_constant) \ \ /******************/ \ /* Useful globals */ \ @@ -2506,7 +2505,6 @@ declare_constant(Deoptimization::Reason_age) \ declare_constant(Deoptimization::Reason_predicate) \ declare_constant(Deoptimization::Reason_loop_limit_check) \ - declare_graal_constant(Deoptimization::Reason_aliasing) \ declare_constant(Deoptimization::Reason_LIMIT) \ declare_constant(Deoptimization::Reason_RECORDED_LIMIT) \ \ @@ -2869,13 +2867,6 @@ # define GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY(name, value) #endif /* COMPILER1 */ -// Generate an int constant for a Graal build -#ifdef GRAAL -# define GENERATE_GRAAL_VM_INT_CONSTANT_ENTRY(name) GENERATE_VM_INT_CONSTANT_ENTRY(name) -#else -# define GENERATE_GRAAL_VM_INT_CONSTANT_ENTRY(name) -#endif - //-------------------------------------------------------------------------------- // VMLongConstantEntry macros // @@ -3018,8 +3009,11 @@ GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY, GENERATE_C1_VM_INT_CONSTANT_ENTRY, GENERATE_C2_VM_INT_CONSTANT_ENTRY, - GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY, - GENERATE_GRAAL_VM_INT_CONSTANT_ENTRY) + GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) + +#ifdef GRAAL + VM_INT_CONSTANTS_GRAAL(GENERATE_VM_INT_CONSTANT_ENTRY) +#endif #if INCLUDE_ALL_GCS VM_INT_CONSTANTS_CMS(GENERATE_VM_INT_CONSTANT_ENTRY)