Mercurial > hg > graal-compiler
changeset 17333:fa821ca2611a
Cache converted classfile name in debug mode
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 02 Oct 2014 10:54:54 -0700 |
parents | 3c39e028b931 |
children | 0563b652c052 |
files | graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Oct 02 08:43:58 2014 -0700 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Oct 02 10:54:54 2014 -0700 @@ -1210,9 +1210,13 @@ return createTimer(format, arg1, arg2); } - public static Object convertFormatArg(Object arg) { - if (arg instanceof Class) { - Class<?> c = (Class<?>) arg; + /** + * There are paths where construction of formatted class names are common and the code below is + * surprisingly expensive, so compute it once and cache it. + */ + private static final ClassValue<String> formattedClassName = new ClassValue<String>() { + @Override + protected String computeValue(Class<?> c) { final String simpleName = c.getSimpleName(); Class<?> enclosingClass = c.getEnclosingClass(); if (enclosingClass != null) { @@ -1226,6 +1230,12 @@ return simpleName; } } + }; + + public static Object convertFormatArg(Object arg) { + if (arg instanceof Class) { + return formattedClassName.get((Class<?>) arg); + } return arg; }