# HG changeset patch # User Christian Haeubl # Date 1327443820 28800 # Node ID 00a04b57a046c2a82ca7d428b457032bdd0d02b9 # Parent 48756b901156929a4fb9a566cbd3a009a12607fc bugfix diff -r 48756b901156 -r 00a04b57a046 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 Jan 24 13:25:16 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * 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.graal.hotspot.ri; - -import com.oracle.max.cri.ri.*; -import com.oracle.max.graal.hotspot.*; -import com.oracle.max.graal.hotspot.Compiler; - - -public final class HotSpotNoProfilingInfo extends CompilerObject implements RiProfilingInfo { - /** - * - */ - private static final long serialVersionUID = 4357945025049704109L; - private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoDataAccessor(); - - public HotSpotNoProfilingInfo(Compiler compiler) { - super(compiler); - } - - @Override - public RiTypeProfile getTypeProfile(int bci) { - return noData.getTypeProfile(null, -1); - } - - @Override - public double getBranchTakenProbability(int bci) { - return noData.getBranchTakenProbability(null, -1); - } - - @Override - public double[] getSwitchProbabilities(int bci) { - return noData.getSwitchProbabilities(null, -1); - } - - @Override - public boolean getImplicitExceptionSeen(int bci) { - return noData.getImplicitExceptionSeen(null, -1); - } - - @Override - public int getExecutionCount(int bci) { - return noData.getExecutionCount(null, -1); - } -} diff -r 48756b901156 -r 00a04b57a046 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 Jan 24 13:25:16 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HOTSPOTPROFILINGINFO.JAVA Tue Jan 24 14:23:40 2012 -0800 @@ -122,7 +122,7 @@ } private void noDataFound() { - setCurrentData(HotSpotMethodData.getNoDataAccessor(), -1); + setCurrentData(HotSpotMethodData.getNoMethodData(), -1); } private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) { diff -r 48756b901156 -r 00a04b57a046 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 Jan 24 13:25:16 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Tue Jan 24 14:23:40 2012 -0800 @@ -42,7 +42,7 @@ // TODO (ch) use same logic as in NodeClass? private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static final HotSpotMethodDataAccessor NO_DATA_ACCESSOR = new NoDataAccessor(); + private static final HotSpotMethodDataAccessor NO_DATA_ACCESSOR = new NoMethodData(); private static final HotSpotVMConfig config; private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = { null, new BitData(), new CounterData(), new JumpData(), @@ -55,8 +55,6 @@ private int extraDataSize; private boolean mature; - // TODO (ch) how are we going to handle methodData->is_mature() - private HotSpotMethodData(Compiler compiler) { super(compiler); throw new IllegalStateException("this constructor is never actually called, because the objects are allocated from within the VM"); @@ -98,13 +96,13 @@ return getData(position, normalDataSize); } - public static HotSpotMethodDataAccessor getNoDataAccessor() { + public static HotSpotMethodDataAccessor getNoMethodData() { return NO_DATA_ACCESSOR; } private HotSpotMethodDataAccessor getData(int position, int displacement) { assert position >= 0 : "out of bounds"; - int tag = AbstractMethodDataAccessor.readTag(this, displacement + position); + int tag = AbstractMethodData.readTag(this, displacement + position); assert tag >= 0 && tag < PROFILE_DATA_ACCESSORS.length : "illegal tag"; return PROFILE_DATA_ACCESSORS[tag]; } @@ -155,13 +153,13 @@ return cells * config.dataLayoutCellSize; } - private abstract static class AbstractMethodDataAccessor implements HotSpotMethodDataAccessor { + private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor { private static final int IMPLICIT_EXCEPTIONS_MASK = 0x0E; private final int tag; private final int staticSize; - protected AbstractMethodDataAccessor(int tag, int staticSize) { + protected AbstractMethodData(int tag, int staticSize) { this.tag = tag; this.staticSize = staticSize; } @@ -218,17 +216,13 @@ protected int getDynamicSize(@SuppressWarnings("unused") HotSpotMethodData data, @SuppressWarnings("unused") int position) { return 0; } - - protected static int addressData(int offset) { - return config.dataLayoutHeaderSize + offset; - } } - private static class NoDataAccessor extends AbstractMethodDataAccessor { + private static class NoMethodData extends AbstractMethodData { private static final int NO_DATA_TAG = 0; private static final int NO_DATA_SIZE = cellIndexToOffset(0); - protected NoDataAccessor() { + protected NoMethodData() { super(NO_DATA_TAG, NO_DATA_SIZE); } @@ -244,7 +238,7 @@ } } - private static class BitData extends AbstractMethodDataAccessor { + private static class BitData extends AbstractMethodData { private static final int BIT_DATA_TAG = 1; private static final int BIT_DATA_SIZE = cellIndexToOffset(0); private static final int BIT_DATA_NULL_SEEN_FLAG = 0x01; @@ -285,7 +279,7 @@ } } - private static class JumpData extends AbstractMethodDataAccessor { + private static class JumpData extends AbstractMethodData { private static final int JUMP_DATA_TAG = 3; private static final int JUMP_DATA_SIZE = cellIndexToOffset(2); protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(0); @@ -308,10 +302,6 @@ public int getExecutionCount(HotSpotMethodData data, int position) { return data.readUnsignedIntAsSignedInt(position, TAKEN_COUNT_OFFSET); } - - public int getDisplacement(HotSpotMethodData data, int position) { - return data.readInt(position, TAKEN_DISPLACEMENT_OFFSET); - } } private static class AbstractTypeData extends CounterData { @@ -342,24 +332,26 @@ graalMirror = CompilerImpl.getInstance().getVMEntries().getType(javaClass); assert graalMirror != null : "must not return null"; } + sparseTypes[entries] = (RiResolvedType) graalMirror; long count = data.readUnsignedInt(position, getCountOffset(i)); - if (count > 0) { - totalCount += count; - counts[entries] = count; - entries++; - } + totalCount += count; + counts[entries] = count; - sparseTypes[i] = (RiResolvedType) graalMirror; + entries++; } } + return createRiTypeProfile(sparseTypes, counts, totalCount, entries); + } + + private static RiTypeProfile createRiTypeProfile(RiResolvedType[] sparseTypes, double[] counts, long totalCount, int entries) { RiResolvedType[] types; double[] probabilities; if (entries <= 0) { return null; - } else if (entries < typeProfileWidth) { + } else if (entries < sparseTypes.length) { RiResolvedType[] compactedTypes = new RiResolvedType[entries]; System.arraycopy(sparseTypes, 0, compactedTypes, 0, entries); types = compactedTypes; @@ -458,7 +450,7 @@ } } - private static class ArrayData extends AbstractMethodDataAccessor { + private static class ArrayData extends AbstractMethodData { private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(0); protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(1); @@ -498,15 +490,13 @@ long totalCount = 0; double[] result = new double[length]; - // default case is expected as last entry - int offset = getCountOffset(0); - long count = data.readUnsignedInt(position, offset); + // default case is first in HotSpot but last for the compiler + long count = readCount(data, position, 0); totalCount += count; result[length - 1] = count; for (int i = 1; i < length; i++) { - offset = getCountOffset(i); - count = data.readUnsignedInt(position, offset); + count = readCount(data, position, i); totalCount += count; result[i - 1] = count; } @@ -521,6 +511,14 @@ } } + private static long readCount(HotSpotMethodData data, int position, int i) { + int offset; + long count; + offset = getCountOffset(i); + count = data.readUnsignedInt(position, offset); + return count; + } + @Override public int getExecutionCount(HotSpotMethodData data, int position) { int arrayLength = getLength(data, position); diff -r 48756b901156 -r 00a04b57a046 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 Jan 24 13:25:16 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Tue Jan 24 14:23:40 2012 -0800 @@ -196,9 +196,6 @@ public RiProfilingInfo profilingInfo() { if (methodData == null) { methodData = compiler.getVMEntries().RiMethod_methodData(this); - if (methodData != null) { - dumpProfile(); - } } if (methodData == null || !methodData.isMature()) { diff -r 48756b901156 -r 00a04b57a046 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java Tue Jan 24 14:23:40 2012 -0800 @@ -0,0 +1,65 @@ +/* + * 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.graal.hotspot.ri; + +import com.oracle.max.cri.ri.*; +import com.oracle.max.graal.hotspot.*; +import com.oracle.max.graal.hotspot.Compiler; + + +public final class HotSpotNoProfilingInfo extends CompilerObject implements RiProfilingInfo { + /** + * + */ + private static final long serialVersionUID = 4357945025049704109L; + private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoMethodData(); + + public HotSpotNoProfilingInfo(Compiler compiler) { + super(compiler); + } + + @Override + public RiTypeProfile getTypeProfile(int bci) { + return noData.getTypeProfile(null, -1); + } + + @Override + public double getBranchTakenProbability(int bci) { + return noData.getBranchTakenProbability(null, -1); + } + + @Override + public double[] getSwitchProbabilities(int bci) { + return noData.getSwitchProbabilities(null, -1); + } + + @Override + public boolean getImplicitExceptionSeen(int bci) { + return noData.getImplicitExceptionSeen(null, -1); + } + + @Override + public int getExecutionCount(int bci) { + return noData.getExecutionCount(null, -1); + } +}