Mercurial > hg > truffle
changeset 18282:ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 06 Nov 2014 13:24:16 +0100 |
parents | cffcb119fdba |
children | b2eb7302706c |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemIdentityHashCodeNode.java |
diffstat | 3 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Thu Nov 06 13:22:00 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Thu Nov 06 13:24:16 2014 +0100 @@ -40,5 +40,13 @@ * * @return {@code null} if this constant does not represent a {@link Class} object */ + @PureFunction JavaConstant getClassLoader(); + + /** + * Gets the {@linkplain System#identityHashCode(Object) identity} has code for the object + * represented by this constant. + */ + @PureFunction + int getIdentityHashCode(); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Thu Nov 06 13:22:00 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Thu Nov 06 13:24:16 2014 +0100 @@ -105,6 +105,10 @@ return null; } + public int getIdentityHashCode() { + return System.identityHashCode(object); + } + @Override public boolean isNull() { return false;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemIdentityHashCodeNode.java Thu Nov 06 13:22:00 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemIdentityHashCodeNode.java Thu Nov 06 13:24:16 2014 +0100 @@ -43,6 +43,10 @@ @Override protected JavaConstant evaluate(JavaConstant param, MetaAccessProvider metaAccess) { - return ImmutableCode.getValue() || param.isNull() ? null : JavaConstant.forInt(System.identityHashCode(HotSpotObjectConstantImpl.asObject(param))); + if (ImmutableCode.getValue() || param.isNull()) { + return null; + } + HotSpotObjectConstant c = (HotSpotObjectConstant) param; + return JavaConstant.forInt(c.getIdentityHashCode()); } }