Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java @ 4456:f4c82dd4619e
inlining bugfixes and cleanup
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Tue, 31 Jan 2012 11:37:16 -0800 |
parents | b788ebbb7ef8 |
children | 5acf4a974e4a |
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Mon Jan 30 17:02:27 2012 -0800 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java Tue Jan 31 11:37:16 2012 -0800 @@ -316,7 +316,7 @@ } } - private static class AbstractTypeData extends CounterData { + private abstract static class AbstractTypeData extends CounterData { private static final int RECEIVER_TYPE_DATA_ROW_SIZE = cellsToBytes(2); private static final int RECEIVER_TYPE_DATA_SIZE = cellIndexToOffset(1) + RECEIVER_TYPE_DATA_ROW_SIZE * config.typeProfileWidth; private static final int RECEIVER_TYPE_DATA_FIRST_RECEIVER_OFFSET = cellIndexToOffset(1); @@ -328,8 +328,6 @@ @Override public RiTypeProfile getTypeProfile(HotSpotMethodData data, int position) { - // TODO (ch) detect polymorphic case and return null and document interface accordingly - // is it really the best solution to return null? int typeProfileWidth = config.typeProfileWidth; RiResolvedType[] sparseTypes = new RiResolvedType[typeProfileWidth]; @@ -356,9 +354,12 @@ } } + totalCount += getTypesNotRecordedExecutionCount(data, position); return createRiTypeProfile(sparseTypes, counts, totalCount, entries); } + protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position); + private static RiTypeProfile createRiTypeProfile(RiResolvedType[] sparseTypes, double[] counts, long totalCount, int entries) { RiResolvedType[] types; double[] probabilities; @@ -375,10 +376,15 @@ probabilities = counts; } + double totalProbability = 0.0; for (int i = 0; i < entries; i++) { - probabilities[i] = counts[i] / totalCount; + double p = counts[i] / totalCount; + probabilities[i] = p; + totalProbability += p; } - return new RiTypeProfile(types, probabilities); + + double notRecordedTypeProbability = entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); + return new RiTypeProfile(types, notRecordedTypeProbability, probabilities); } private static int getReceiverOffset(int row) { @@ -401,6 +407,12 @@ 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 { @@ -422,6 +434,11 @@ 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 {