Mercurial > hg > graal-compiler
changeset 15828:34c99f83795b
Cache result of toJava and toJavaConstructor, since it is an expensive operation
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 20 May 2014 18:54:09 -0700 |
parents | 4e770fa50889 |
children | af16872a18f1 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue May 20 18:53:31 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue May 20 18:54:09 2014 -0700 @@ -56,6 +56,7 @@ private final HotSpotSignature signature; private HotSpotMethodData methodData; private byte[] code; + private Member toJavaCache; /** * Gets the holder of a HotSpot metaspace method native object. @@ -505,16 +506,26 @@ } private Method toJava() { + if (toJavaCache != null) { + return (Method) toJavaCache; + } try { - return holder.mirror().getDeclaredMethod(name, signatureToTypes()); + Method result = holder.mirror().getDeclaredMethod(name, signatureToTypes()); + toJavaCache = result; + return result; } catch (NoSuchMethodException e) { return null; } } private Constructor<?> toJavaConstructor() { + if (toJavaCache != null) { + return (Constructor<?>) toJavaCache; + } try { - return holder.mirror().getDeclaredConstructor(signatureToTypes()); + Constructor<?> result = holder.mirror().getDeclaredConstructor(signatureToTypes()); + toJavaCache = result; + return result; } catch (NoSuchMethodException e) { return null; }