Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java @ 9760:c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Fri, 17 May 2013 15:38:22 +0200 |
parents | 5c258c1feb82 |
children | 51545c49083a |
comparison
equal
deleted
inserted
replaced
9759:580faa2ee288 | 9760:c76b43ed5089 |
---|---|
26 | 26 |
27 import java.lang.annotation.*; | 27 import java.lang.annotation.*; |
28 import java.lang.reflect.*; | 28 import java.lang.reflect.*; |
29 import java.util.*; | 29 import java.util.*; |
30 | 30 |
31 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; | |
32 import com.oracle.graal.api.meta.ProfilingInfo.TriState; | 31 import com.oracle.graal.api.meta.ProfilingInfo.TriState; |
33 | 32 |
34 /** | 33 /** |
35 * Miscellaneous collection of utility methods used by {@code com.oracle.graal.api.meta} and its | 34 * Miscellaneous collection of utility methods used by {@code com.oracle.graal.api.meta} and its |
36 * clients. | 35 * clients. |
544 if (info.getNullSeen(i) == TriState.TRUE) { | 543 if (info.getNullSeen(i) == TriState.TRUE) { |
545 buf.append(String.format("nullSeen@%d: %s%s", i, info.getNullSeen(i).name(), sep)); | 544 buf.append(String.format("nullSeen@%d: %s%s", i, info.getNullSeen(i).name(), sep)); |
546 } | 545 } |
547 | 546 |
548 JavaTypeProfile typeProfile = info.getTypeProfile(i); | 547 JavaTypeProfile typeProfile = info.getTypeProfile(i); |
549 if (typeProfile != null) { | 548 appendProfile(buf, typeProfile, i, "types", sep); |
550 ProfiledType[] ptypes = typeProfile.getTypes(); | 549 |
551 if (ptypes != null) { | 550 JavaMethodProfile methodProfile = info.getMethodProfile(i); |
552 buf.append(String.format("types@%d:", i)); | 551 appendProfile(buf, methodProfile, i, "methods", sep); |
553 for (int j = 0; j < ptypes.length; j++) { | |
554 ProfiledType ptype = ptypes[j]; | |
555 buf.append(String.format(" %.6f (%s)%s", ptype.getProbability(), ptype.getType(), sep)); | |
556 } | |
557 if (typeProfile.getNotRecordedProbability() != 0) { | |
558 buf.append(String.format(" %.6f <other types>%s", typeProfile.getNotRecordedProbability(), sep)); | |
559 } else { | |
560 buf.append(String.format(" <no other types>%s", sep)); | |
561 } | |
562 } | |
563 } | |
564 } | 552 } |
565 | 553 |
566 boolean firstDeoptReason = true; | 554 boolean firstDeoptReason = true; |
567 for (DeoptimizationReason reason : DeoptimizationReason.values()) { | 555 for (DeoptimizationReason reason : DeoptimizationReason.values()) { |
568 int count = info.getDeoptimizationCount(reason); | 556 int count = info.getDeoptimizationCount(reason); |
580 String s = buf.toString(); | 568 String s = buf.toString(); |
581 assert s.endsWith(sep); | 569 assert s.endsWith(sep); |
582 return s.substring(0, s.length() - sep.length()); | 570 return s.substring(0, s.length() - sep.length()); |
583 } | 571 } |
584 | 572 |
573 private static void appendProfile(StringBuilder buf, AbstractJavaProfile profile, int bci, String kind, String sep) { | |
574 if (profile != null) { | |
575 AbstractProfiledItem[] pitems = profile.getItems(); | |
576 if (pitems != null) { | |
577 buf.append(String.format("%s@%d:", kind, bci)); | |
578 for (int j = 0; j < pitems.length; j++) { | |
579 AbstractProfiledItem pitem = pitems[j]; | |
580 buf.append(String.format(" %.6f (%s)%s", pitem.getProbability(), pitem.getItem(), sep)); | |
581 } | |
582 if (profile.getNotRecordedProbability() != 0) { | |
583 buf.append(String.format(" %.6f <other %s>%s", profile.getNotRecordedProbability(), kind, sep)); | |
584 } else { | |
585 buf.append(String.format(" <no other %s>%s", kind, sep)); | |
586 } | |
587 } | |
588 } | |
589 } | |
590 | |
585 /** | 591 /** |
586 * Converts a Java source-language class name into the internal form. | 592 * Converts a Java source-language class name into the internal form. |
587 * | 593 * |
588 * @param className the class name | 594 * @param className the class name |
589 * @return the internal name form of the class name | 595 * @return the internal name form of the class name |