Mercurial > hg > truffle
changeset 18288:feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 06 Nov 2014 13:57:43 +0100 |
parents | b7461f7fa8a0 |
children | 7acff34abbf7 |
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/phases/AheadOfTimeVerificationPhase.java |
diffstat | 3 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Thu Nov 06 13:55:47 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Thu Nov 06 13:57:43 2014 +0100 @@ -96,4 +96,9 @@ * @return {@code null} if this constant does not represent a {@link Class} object */ JavaConstant getCompositeValueClass(); + + /** + * Determines if this constant represents an {@linkplain String#intern() interned} string. + */ + boolean isInternedString(); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Thu Nov 06 13:55:47 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Thu Nov 06 13:57:43 2014 +0100 @@ -29,6 +29,8 @@ import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Represents a constant non-{@code null} object reference, within the compiler and across the * compiler/runtime interface. @@ -160,6 +162,15 @@ return null; } + @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "reference equality is what we want") + public boolean isInternedString() { + if (object instanceof String) { + String s = (String) object; + return s.intern() == s; + } + return false; + } + @Override public boolean isNull() { return false;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Thu Nov 06 13:55:47 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Thu Nov 06 13:57:43 2014 +0100 @@ -31,8 +31,6 @@ import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; -import edu.umd.cs.findbugs.annotations.*; - /** * Checks for illegal object constants in a graph processed for AOT compilation. The only legal * object constants are {@linkplain String#intern() interned} strings as they will be installed in @@ -74,18 +72,12 @@ return StampTool.typeOrNull(node).getName().startsWith("Ljava/lang/invoke/BoundMethodHandle"); } - @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "reference equality is what we want") private static boolean isInternedString(ConstantNode node) { if (!isObject(node)) { return false; } - Object o = HotSpotObjectConstantImpl.asObject(node.asJavaConstant()); - if (!(o instanceof String)) { - return false; - } - - String s = (String) o; - return s == s.intern(); + HotSpotObjectConstant c = (HotSpotObjectConstant) node.asConstant(); + return c.isInternedString(); } }