# HG changeset patch # User Christian Haeubl # Date 1328645351 28800 # Node ID a0cca63cd366f0a107c168e8e4b375e235217625 # Parent 0e1f15ec0e9467cafc7062f30505fc6302072242 fixed exceptionSeen profiling information diff -r 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 12:09:11 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 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java Tue Feb 07 12:09:11 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 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedMethod.java Tue Feb 07 12:09:11 2012 -0800 @@ -211,4 +211,9 @@ * @return {@code true} if this method can be inlined */ boolean canBeInlined(); + + /** + * Dumps the recorded profiling information to TTY. + */ + void dumpProfile(); } diff -r 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Tue Feb 07 12:09:11 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; } } diff -r 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java Tue Feb 07 12:09:11 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 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Tue Feb 07 12:09:11 2012 -0800 @@ -242,8 +242,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 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java Tue Feb 07 12:09:11 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 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java Tue Feb 07 12:09:11 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 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java Tue Feb 07 12:09:11 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 0e1f15ec0e94 -r a0cca63cd366 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 Tue Feb 07 11:43:05 2012 -0800 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Tue Feb 07 12:09:11 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; } }