# HG changeset patch # User Doug Simon # Date 1365177115 -7200 # Node ID bc7bb895e359ae341fb3a16b37fb8e161a6bbd9f # Parent e18f7f7ce7a9829af97a482721b514875b59eb18 incorporated null-seen information into JavaTypeProfile diff -r e18f7f7ce7a9 -r bc7bb895e359 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Fri Apr 05 17:37:27 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Fri Apr 05 17:51:55 2013 +0200 @@ -57,9 +57,9 @@ * @param profile the profiling information available for the instruction (if any) * @param assumptions the object in which speculations are recorded. This is null if * speculations are not supported. - * @param minHintHitProbability if the probability that the type check will hit one the profiled - * types (up to {@code maxHints}) is below this value, then {@link #types} will be - * null + * @param minHintHitProbability if the probability that the type check will hit one of the + * profiled types (up to {@code maxHints}) is below this value, then {@link #types} + * will be null * @param maxHints the maximum length of {@link #types} */ public TypeCheckHints(ResolvedJavaType type, JavaTypeProfile profile, Assumptions assumptions, double minHintHitProbability, int maxHints) { diff -r e18f7f7ce7a9 -r bc7bb895e359 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 Fri Apr 05 17:37:27 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Fri Apr 05 17:51:55 2013 +0200 @@ -24,6 +24,8 @@ import java.io.*; +import com.oracle.graal.api.meta.ProfilingInfo.*; + /** * This profile object represents the type profile at a specific BCI. The precision of the supplied * values may vary, but a runtime that provides this information should be aware that it will be @@ -78,6 +80,7 @@ } } + private final TriState nullSeen; private final double notRecordedProbability; private final ProfiledType[] ptypes; @@ -94,7 +97,8 @@ return true; } - public JavaTypeProfile(double notRecordedProbability, ProfiledType... ptypes) { + public JavaTypeProfile(TriState nullSeen, double notRecordedProbability, ProfiledType... ptypes) { + this.nullSeen = nullSeen; this.ptypes = ptypes; this.notRecordedProbability = notRecordedProbability; assert isSorted(ptypes); @@ -111,6 +115,13 @@ } /** + * Returns whether a null value was at the type check. + */ + public TriState getNullSeen() { + return nullSeen; + } + + /** * A list of types for which the runtime has recorded probability information. */ public ProfiledType[] getTypes() { diff -r e18f7f7ce7a9 -r bc7bb895e359 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 Fri Apr 05 17:37:27 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Fri Apr 05 17:51:55 2013 +0200 @@ -364,12 +364,12 @@ } totalCount += getTypesNotRecordedExecutionCount(data, position); - return createTypeProfile(types, counts, totalCount, entries); + return createTypeProfile(getNullSeen(data, position), types, counts, totalCount, entries); } protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position); - private static JavaTypeProfile createTypeProfile(ResolvedJavaType[] types, long[] counts, long totalCount, int entries) { + private static JavaTypeProfile createTypeProfile(TriState nullSeen, ResolvedJavaType[] types, long[] counts, long totalCount, int entries) { if (entries <= 0 || totalCount < GraalOptions.MatureExecutionsTypeProfile) { return null; } @@ -387,7 +387,7 @@ double notRecordedTypeProbability = entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); assert notRecordedTypeProbability == 0 || entries == config.typeProfileWidth; - return new JavaTypeProfile(notRecordedTypeProbability, ptypes); + return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes); } private static int getReceiverOffset(int row) { diff -r e18f7f7ce7a9 -r bc7bb895e359 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Fri Apr 05 17:37:27 2013 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Fri Apr 05 17:51:55 2013 +0200 @@ -776,7 +776,7 @@ } else { ResolvedJavaType uniqueSubtype = type.findUniqueConcreteSubtype(); if (uniqueSubtype != null) { - return new JavaTypeProfile(0.0D, new ProfiledType(uniqueSubtype, 1.0D)); + return new JavaTypeProfile(profilingInfo.getNullSeen(bci()), 0.0D, new ProfiledType(uniqueSubtype, 1.0D)); } else { return profilingInfo.getTypeProfile(bci()); } diff -r e18f7f7ce7a9 -r bc7bb895e359 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/TypeCheckTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/TypeCheckTest.java Fri Apr 05 17:37:27 2013 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/TypeCheckTest.java Fri Apr 05 17:51:55 2013 +0200 @@ -25,6 +25,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; +import com.oracle.graal.api.meta.ProfilingInfo.TriState; import com.oracle.graal.compiler.test.*; import com.oracle.graal.nodes.*; @@ -48,6 +49,10 @@ } protected JavaTypeProfile profile(Class... types) { + return profile(TriState.UNKNOWN, types); + } + + protected JavaTypeProfile profile(TriState nullSeen, Class... types) { if (types.length == 0) { return null; } @@ -55,7 +60,7 @@ for (int i = 0; i < types.length; i++) { ptypes[i] = new ProfiledType(runtime.lookupJavaType(types[i]), 1.0D / types.length); } - return new JavaTypeProfile(0.0D, ptypes); + return new JavaTypeProfile(nullSeen, 0.0D, ptypes); } protected void test(String name, JavaTypeProfile profile, Object... args) {