# HG changeset patch # User Christian Haeubl # Date 1328764500 28800 # Node ID 3a309467fc8e747cbb9e35924b5e76103ca3f7eb # Parent 6c6cb7be1324dbba0c747cccf366e272e8332acc# Parent 681e969888a7b18769aec862452fe0a890cab588 Merge diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiExceptionSeen.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiExceptionSeen.java Wed Feb 08 21:15:00 2012 -0800 @@ -0,0 +1,37 @@ +/* + * 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.max.cri.ri; + + +/** + * Represents the three possibilities that an exception was seen at a specific BCI. + */ +public enum RiExceptionSeen { + TRUE, + FALSE, + UNKNOWN; + + public static RiExceptionSeen get(boolean value) { + return value ? TRUE : FALSE; + } +} diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java Wed Feb 08 21:15:00 2012 -0800 @@ -50,10 +50,12 @@ RiTypeProfile getTypeProfile(int bci); /** - * Returns true if the instruction at least once an exception was thrown at the given BCI. - * @return true if an exception was encountered during profiling, false otherwise. + * Returns information if the given BCI did ever throw an exception. + * @return @link{RiExceptionSeen.TRUE} if the instruction has thrown an exception at least once, + * @link{RiExceptionSeen.FALSE} if it never threw an exception, and @link{RiExceptionSeen.UNKNOWN} + * if this information was not recorded. */ - boolean getExceptionSeen(int bci); + RiExceptionSeen getExceptionSeen(int bci); /** * Returns an estimate how often the current BCI was executed. Avoid comparing execution counts to each other, diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedMethod.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedMethod.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedMethod.java Wed Feb 08 21:15:00 2012 -0800 @@ -49,6 +49,12 @@ int codeSize(); /** + * Gets the size of the compiled machine code. + * @return the size of the compiled machine code in bytes, or 0 if no compiled code exists. + */ + int compiledCodeSize(); + + /** * Gets the symbol used to link this method if it is native, otherwise {@code null}. */ String jniSymbol(); @@ -211,4 +217,9 @@ * @return {@code true} if this method can be inlined */ boolean canBeInlined(); + + /** + * Dumps the recorded profiling information to TTY. + */ + void dumpProfile(); } diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Wed Feb 08 21:15:00 2012 -0800 @@ -44,18 +44,23 @@ public static boolean CacheGraphs = ____; public static boolean InlineMonomorphicCalls = true; public static boolean InlinePolymorphicCalls = true; + public static boolean InlineMegamorphicCalls = true; public static int InliningPolicy = 0; - public static int MaximumInlineSize = 35; - public static int MaximumFreqInlineSize = 300; - public static float NestedInliningSizeRatio = 0.9f; - public static int FreqInlineRatio = 20; public static int MaximumTrivialSize = 6; public static int MaximumInlineLevel = 30; public static int MaximumDesiredSize = 6000; + // WeightBasedInliningPolicy (0) public static boolean ParseBeforeInlining = ____; public static float InliningSizePenaltyExp = 20; public static float MaximumInlineWeight = 1.25f; public static float InliningSizePenalty = 1; + // StaticSizeBasedInliningPolicy (1), DynamicSizeBasedInliningPolicy (2), GreedySizeBasedInlining (3) + public static int MaximumInlineSize = 35; + public static float NestedInliningSizeRatio = 0.9f; + public static float BoostInliningForEscapeAnalysis = 2f; + public static float ProbabilityCapForInlining = 1f; + public static int MaximumGreedyInlineSize = 250; + public static int SmallCompiledCodeSize = 1500; // escape analysis settings public static boolean EscapeAnalysis = true; @@ -129,7 +134,7 @@ public static int MatureInvocationCount = 100; public static boolean GenSafepoints = true; public static boolean GenLoopSafepoints = true; - public static boolean UseInstanceOfHints = true; + public static boolean UseTypeCheckHints = true; public static boolean GenAssertionCode = ____; public static boolean AlignCallsForPatching = true; diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Wed Feb 08 21:15:00 2012 -0800 @@ -191,7 +191,11 @@ if (GraalOptions.InliningPolicy == 0) { return new WeightBasedInliningPolicy(); } else if (GraalOptions.InliningPolicy == 1) { - return new SizeBasedInliningPolicy(); + return new StaticSizeBasedInliningPolicy(); + } else if (GraalOptions.InliningPolicy == 2) { + return new DynamicSizeBasedInliningPolicy(); + } else if (GraalOptions.InliningPolicy == 3) { + return new GreedySizeBasedInliningPolicy(); } else { GraalInternalError.shouldNotReachHere(); return null; @@ -272,14 +276,14 @@ } } - private class SizeBasedInliningPolicy implements InliningPolicy { + private class StaticSizeBasedInliningPolicy implements InliningPolicy { @Override public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) { + double codeSize = method.codeSize(); if (preferredInvoke) { - return method.codeSize() / 2; - } else { - return method.codeSize(); + codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis; } + return codeSize; } @Override @@ -288,4 +292,51 @@ return info.weight <= maxSize; } } + + private class DynamicSizeBasedInliningPolicy implements InliningPolicy { + @Override + public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) { + double codeSize = method.codeSize(); + if (preferredInvoke) { + codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis; + } + return codeSize; + } + + @Override + public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { + assert GraalOptions.ProbabilityAnalysis; + if (info.compiledCodeSize() <= GraalOptions.SmallCompiledCodeSize) { + double inlineBoost = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()); + double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize; + maxSize = maxSize + maxSize * inlineBoost; + maxSize = Math.max(GraalOptions.MaximumTrivialSize, maxSize); + return info.weight <= maxSize; + } + return false; + } + } + + private class GreedySizeBasedInliningPolicy implements InliningPolicy { + @Override + public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) { + double codeSize = method.codeSize(); + if (preferredInvoke) { + codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis; + } + return codeSize; + } + + @Override + public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { + assert GraalOptions.ProbabilityAnalysis; + if (info.compiledCodeSize() <= GraalOptions.SmallCompiledCodeSize) { + double inlineRatio = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()); + double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumGreedyInlineSize * inlineRatio; + maxSize = Math.max(maxSize, GraalOptions.MaximumInlineSize); + return info.weight <= maxSize; + } + return false; + } + } } diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java Wed Feb 08 21:15:00 2012 -0800 @@ -82,6 +82,8 @@ this.level = level; } + public abstract int compiledCodeSize(); + @Override public int compareTo(InlineInfo o) { return (weight < o.weight) ? -1 : (weight > o.weight) ? 1 : 0; @@ -128,6 +130,11 @@ } @Override + public int compiledCodeSize() { + return concrete.compiledCodeSize(); + } + + @Override public String toString() { return "exact inlining " + CiUtil.format("%H.%n(%p):%r", concrete); } @@ -153,6 +160,11 @@ } @Override + public int compiledCodeSize() { + return concrete.compiledCodeSize(); + } + + @Override public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { // receiver null check must be before the type check InliningUtil.receiverNullCheck(invoke); @@ -206,6 +218,15 @@ } @Override + public int compiledCodeSize() { + int result = 0; + for (RiResolvedMethod m: concretes) { + result += m.compiledCodeSize(); + } + return result; + } + + @Override public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { int numberOfMethods = concretes.size(); boolean hasReturnValue = invoke.node().kind() != CiKind.Void; @@ -384,9 +405,12 @@ InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; BeginNode exceptionEdge = invokeWithException.exceptionEdge(); ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); + FrameState stateAfter = exceptionObject.stateAfter(); BeginNode newExceptionEdge = (BeginNode) exceptionEdge.copyWithInputs(); ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs(); + // set new state (pop old exception object, push new one) + newExceptionObject.setStateAfter(stateAfter.duplicateModified(stateAfter.bci, stateAfter.rethrowException(), CiKind.Object, newExceptionObject)); newExceptionEdge.setNext(newExceptionObject); EndNode endNode = graph.add(new EndNode()); @@ -401,7 +425,7 @@ @Override public String toString() { - StringBuilder builder = new StringBuilder(String.format("type-checked inlining of %d methods with %d type checks: ", concretes.size(), types.length)); + StringBuilder builder = new StringBuilder(String.format("inlining %d methods with %d type checks: ", concretes.size(), types.length)); for (int i = 0; i < concretes.size(); i++) { builder.append(CiUtil.format(" %H.%n(%p):%r", concretes.get(i))); } @@ -518,7 +542,7 @@ if (GraalOptions.InlineMonomorphicCalls) { RiResolvedType type = types[0]; RiResolvedMethod concrete = type.resolveMethodImpl(callTarget.targetMethod()); - if (concrete != null && checkTargetConditions(concrete)) { + if (checkTargetConditions(concrete)) { double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke); return new TypeGuardInlineInfo(invoke, weight, level, concrete, type); } @@ -530,7 +554,7 @@ return null; } } else { - if (GraalOptions.InlinePolymorphicCalls) { + if (GraalOptions.InlinePolymorphicCalls && notRecordedTypeProbability == 0 || GraalOptions.InlineMegamorphicCalls && notRecordedTypeProbability > 0) { // TODO (ch) inlining of multiple methods should work differently // 1. check which methods can be inlined // 2. for those methods, use weight and probability to compute which of them should be inlined @@ -556,7 +580,7 @@ double totalWeight = 0; boolean canInline = true; for (RiResolvedMethod concrete: concreteMethods) { - if (concrete == null || !checkTargetConditions(concrete)) { + if (!checkTargetConditions(concrete)) { canInline = false; break; } @@ -613,6 +637,10 @@ } private static boolean checkTargetConditions(RiMethod method) { + if (method == null) { + Debug.log("method not resolved"); + return false; + } if (!(method instanceof RiResolvedMethod)) { Debug.log("not inlining %s because it is unresolved", method.toString()); return false; @@ -738,6 +766,7 @@ frameState.replaceAndDelete(stateAfter); } else if (frameState.bci == FrameState.AFTER_EXCEPTION_BCI) { if (frameState.isAlive()) { + // TODO (ch) it happens sometimes that we have a FrameState.AFTER_EXCEPTION_BCI but no stateAtExceptionEdge assert stateAtExceptionEdge != null; frameState.replaceAndDelete(stateAtExceptionEdge); } else { diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java Wed Feb 08 21:15:00 2012 -0800 @@ -99,6 +99,8 @@ boolean RiMethod_hasCompiledCode(HotSpotMethodResolved method); + int RiMethod_getCompiledCodeSize(HotSpotMethodResolved method); + RiMethod getRiMethod(Method reflectionMethod); long getMaxCallTargetOffset(CiRuntimeCall rtcall); diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java Wed Feb 08 21:15:00 2012 -0800 @@ -145,6 +145,9 @@ public native boolean RiMethod_hasCompiledCode(HotSpotMethodResolved method); @Override + public native int RiMethod_getCompiledCodeSize(HotSpotMethodResolved method); + + @Override public native long getMaxCallTargetOffset(CiRuntimeCall rtcall); @Override diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Wed Feb 08 21:15:00 2012 -0800 @@ -44,7 +44,8 @@ // TODO (ch) use same logic as in NodeClass? private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static final HotSpotMethodDataAccessor NO_DATA_ACCESSOR = new NoMethodData(); + private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(RiExceptionSeen.FALSE); + private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLE_ACCESSOR = new NoMethodData(RiExceptionSeen.UNKNOWN); private static final HotSpotVMConfig config; // sorted by tag private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = { @@ -109,8 +110,12 @@ return getData(position); } - public static HotSpotMethodDataAccessor getNoMethodData() { - return NO_DATA_ACCESSOR; + public static HotSpotMethodDataAccessor getNoDataNoExceptionAccessor() { + return NO_DATA_NO_EXCEPTION_ACCESSOR; + } + + public static HotSpotMethodDataAccessor getNoDataExceptionPossibleAccessor() { + return NO_DATA_EXCEPTION_POSSIBLE_ACCESSOR; } private HotSpotMethodDataAccessor getData(int position) { @@ -196,8 +201,8 @@ } @Override - public boolean getExceptionSeen(HotSpotMethodData data, int position) { - return (getFlags(data, position) & EXCEPTIONS_MASK) != 0; + public RiExceptionSeen getExceptionSeen(HotSpotMethodData data, int position) { + return RiExceptionSeen.get((getFlags(data, position) & EXCEPTIONS_MASK) != 0); } @Override @@ -233,8 +238,11 @@ private static final int NO_DATA_TAG = 0; private static final int NO_DATA_SIZE = cellIndexToOffset(0); - protected NoMethodData() { + private final RiExceptionSeen exceptionSeen; + + protected NoMethodData(RiExceptionSeen exceptionSeen) { super(NO_DATA_TAG, NO_DATA_SIZE); + this.exceptionSeen = exceptionSeen; } @Override @@ -244,8 +252,8 @@ @Override - public boolean getExceptionSeen(HotSpotMethodData data, int position) { - return false; + public RiExceptionSeen getExceptionSeen(HotSpotMethodData data, int position) { + return exceptionSeen; } } @@ -363,7 +371,11 @@ return createRiTypeProfile(sparseTypes, counts, totalCount, entries); } - protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position); + protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { + // checkcast/aastore/instanceof profiling in the HotSpot template-based interpreter was adjusted so that the counter + // is incremented to indicate the polymorphic case instead of decrementing it for failed type checks + return getCounterValue(data, position); + } private static RiTypeProfile createRiTypeProfile(RiResolvedType[] sparseTypes, double[] counts, long totalCount, int entries) { RiResolvedType[] types; @@ -410,12 +422,6 @@ public int getExecutionCount(HotSpotMethodData data, int position) { return -1; } - - @Override - protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { - // TODO (ch) if types do not fit, profiling is skipped for typechecks - return 0; - } } private static class VirtualCallData extends AbstractTypeData { @@ -437,11 +443,6 @@ total += getCounterValue(data, position); return truncateLongToInt(total); } - - @Override - protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { - return getCounterValue(data, position); - } } private static class RetData extends CounterData { diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java Wed Feb 08 21:15:00 2012 -0800 @@ -51,6 +51,6 @@ RiTypeProfile getTypeProfile(HotSpotMethodData data, int position); double getBranchTakenProbability(HotSpotMethodData data, int position); double[] getSwitchProbabilities(HotSpotMethodData data, int position); - boolean getExceptionSeen(HotSpotMethodData data, int position); + RiExceptionSeen getExceptionSeen(HotSpotMethodData data, int position); int getExecutionCount(HotSpotMethodData data, int position); } diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Wed Feb 08 21:15:00 2012 -0800 @@ -178,6 +178,10 @@ return compiler.getVMEntries().RiMethod_hasCompiledCode(this); } + public int compiledCodeSize() { + return compiler.getVMEntries().RiMethod_getCompiledCodeSize(this); + } + @Override public RiResolvedType accessor() { return null; @@ -242,8 +246,8 @@ TTY.println(); } - if (profilingInfo.getExceptionSeen(i)) { - TTY.println(" exceptionSeen@%d: true", i); + if (profilingInfo.getExceptionSeen(i) != RiExceptionSeen.FALSE) { + TTY.println(" exceptionSeen@%d: %s", i, profilingInfo.getExceptionSeen(i).name()); } RiTypeProfile typeProfile = profilingInfo.getTypeProfile(i); diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java Wed Feb 08 21:15:00 2012 -0800 @@ -32,7 +32,7 @@ * */ private static final long serialVersionUID = 4357945025049704109L; - private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoMethodData(); + private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoDataExceptionPossibleAccessor(); public HotSpotNoProfilingInfo(Compiler compiler) { super(compiler); @@ -54,7 +54,7 @@ } @Override - public boolean getExceptionSeen(int bci) { + public RiExceptionSeen getExceptionSeen(int bci) { return noData.getExceptionSeen(null, -1); } diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java Wed Feb 08 21:15:00 2012 -0800 @@ -66,7 +66,7 @@ } @Override - public boolean getExceptionSeen(int bci) { + public RiExceptionSeen getExceptionSeen(int bci) { findBCI(bci, true); return dataAccessor.getExceptionSeen(methodData, position); } @@ -95,6 +95,7 @@ } } + boolean exceptionPossiblyNotRecorded = false; if (searchExtraData && methodData.hasExtraData()) { int currentPosition = methodData.getExtraDataBeginOffset(); HotSpotMethodDataAccessor currentAccessor; @@ -106,11 +107,11 @@ } currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); } + + exceptionPossiblyNotRecorded = !methodData.isWithin(currentPosition); } - // TODO (ch) getExceptionSeen() should return UNKNOWN if not enough extra data - - noDataFound(); + noDataFound(exceptionPossiblyNotRecorded); } private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) { @@ -123,8 +124,9 @@ setCurrentData(data, pos); } - private void noDataFound() { - setCurrentData(HotSpotMethodData.getNoMethodData(), -1); + private void noDataFound(boolean exceptionPossible) { + HotSpotMethodDataAccessor accessor = exceptionPossible ? HotSpotMethodData.getNoDataNoExceptionAccessor() : HotSpotMethodData.getNoDataNoExceptionAccessor(); + setCurrentData(accessor, -1); } private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) { diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java Wed Feb 08 21:15:00 2012 -0800 @@ -1185,7 +1185,7 @@ } asm.mov(checkHub, hub); - // if we get an exact match: continue + // if we get an exact match: continue. asm.jneq(falseSucc, objHub, checkHub); return asm.finishTemplate("typeCheck"); diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java --- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java Wed Feb 08 21:15:00 2012 -0800 @@ -388,7 +388,7 @@ case PUTFIELD: case GETFIELD: { if (GraalOptions.AllowExplicitExceptionChecks) { - return profilingInfo.getExceptionSeen(bci); + return profilingInfo.getExceptionSeen(bci) != RiExceptionSeen.FALSE; } } } diff -r 681e969888a7 -r 3a309467fc8e graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Wed Feb 08 19:25:29 2012 -0800 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Wed Feb 08 21:15:00 2012 -0800 @@ -323,7 +323,8 @@ assert bci == FrameState.BEFORE_BCI || bci == bci() : "invalid bci"; if (GraalOptions.UseExceptionProbability && method.invocationCount() > GraalOptions.MatureInvocationCount) { - if (bci != FrameState.BEFORE_BCI && exceptionObject == null && !profilingInfo.getExceptionSeen(bci)) { + // be conservative if information was not recorded (could result in endless recompiles otherwise) + if (bci != FrameState.BEFORE_BCI && exceptionObject == null && profilingInfo.getExceptionSeen(bci) == RiExceptionSeen.FALSE) { return null; } } @@ -691,7 +692,7 @@ private static final RiResolvedType[] EMPTY_TYPE_ARRAY = new RiResolvedType[0]; private RiResolvedType[] getTypeCheckHints(RiResolvedType type, int maxHints) { - if (!GraalOptions.UseInstanceOfHints || Util.isFinalClass(type)) { + if (!GraalOptions.UseTypeCheckHints || Util.isFinalClass(type)) { return new RiResolvedType[] {type}; } else { RiResolvedType uniqueSubtype = type.uniqueConcreteSubtype(); diff -r 681e969888a7 -r 3a309467fc8e src/cpu/x86/vm/interp_masm_x86_64.cpp --- a/src/cpu/x86/vm/interp_masm_x86_64.cpp Wed Feb 08 19:25:29 2012 -0800 +++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp Wed Feb 08 21:15:00 2012 -0800 @@ -1126,8 +1126,11 @@ Register receiver, Register mdp, Register reg2, int start_row, Label& done, bool is_virtual_call) { + // change for GRAAL (use counter to indicate polymorphic case instead of failed typechecks) + bool use_counter_for_polymorphic_case = is_virtual_call || UseGraal; + if (TypeProfileWidth == 0) { - if (is_virtual_call) { + if (use_counter_for_polymorphic_case) { increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); } return; @@ -1164,7 +1167,7 @@ testptr(reg2, reg2); if (start_row == last_row) { // The only thing left to do is handle the null case. - if (is_virtual_call) { + if (use_counter_for_polymorphic_case) { jccb(Assembler::zero, found_null); // Receiver did not match any saved receiver and there is no empty row for it. // Increment total counter to indicate polymorphic case. @@ -1297,7 +1300,8 @@ void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) { - if (ProfileInterpreter && TypeProfileCasts) { + // changed for GRAAL (use counter to indicate polymorphism instead of failed typechecks) + if (ProfileInterpreter && TypeProfileCasts && !UseGraal) { Label profile_continue; // If no method data exists, go to profile_continue. diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveCookie.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/customLeftWsmode.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.png diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.png diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.png diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.png diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/build-impl.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Bundle.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/onlyControlFlow.filter diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/LookupHistory.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/BoundedZoomAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewer.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.form diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ExportCookie.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ExtendedSatelliteComponent.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/GraphViewerImplementation.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/CustomizablePanAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExportAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/NextDiagramAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/OverviewAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PanModeAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PrevDiagramAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/SelectionModeAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ShowAllAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomInAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomOutAction.java diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/export.png diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/next_diagram.png diff -r 681e969888a7 -r 3a309467fc8e src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/prev_diagram.png diff -r 681e969888a7 -r 3a309467fc8e src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Wed Feb 08 19:25:29 2012 -0800 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Wed Feb 08 21:15:00 2012 -0800 @@ -239,6 +239,13 @@ return getMethodFromHotSpotMethod(hotspot_method)->has_compiled_code(); } +// public native int RiMethod_getCompiledCodeSize(HotSpotMethodResolved method); +JNIEXPORT jint JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_RiMethod_1getCompiledCodeSize(JNIEnv *env, jobject, jobject hotspot_method) { + TRACE_graal_3("CompilerToVM::RiMethod_getCompiledCodeSize"); + nmethod* code = getMethodFromHotSpotMethod(hotspot_method)->code(); + return code == NULL ? 0 : code->insts_size(); +} + // public RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass); JNIEXPORT jobject JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve) { TRACE_graal_3("CompilerToVM::RiSignature_lookupType"); @@ -939,6 +946,7 @@ {CC"HotSpotMethodData_isMature", CC"("METHOD_DATA")Z", FN_PTR(HotSpotMethodData_1isMature)}, {CC"RiMethod_invocationCount", CC"("RESOLVED_METHOD")I", FN_PTR(RiMethod_1invocationCount)}, {CC"RiMethod_hasCompiledCode", CC"("RESOLVED_METHOD")Z", FN_PTR(RiMethod_1hasCompiledCode)}, + {CC"RiMethod_getCompiledCodeSize", CC"("RESOLVED_METHOD")I", FN_PTR(RiMethod_1getCompiledCodeSize)}, {CC"RiSignature_lookupType", CC"("STRING RESOLVED_TYPE"Z)"TYPE, FN_PTR(RiSignature_1lookupType)}, {CC"RiConstantPool_lookupConstant", CC"("RESOLVED_TYPE"I)"OBJECT, FN_PTR(RiConstantPool_1lookupConstant)}, {CC"RiConstantPool_lookupMethod", CC"("RESOLVED_TYPE"IB)"METHOD, FN_PTR(RiConstantPool_1lookupMethod)},