# HG changeset patch # User Doug Simon # Date 1415278663 -3600 # Node ID feef9ed5fc56024124ffb6d2ea52c8766a93debd # Parent b7461f7fa8a0c5f7182c177da20be36933bb88d6 added HotSpotObjectConstant.isInternedString() diff -r b7461f7fa8a0 -r feef9ed5fc56 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java --- 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(); } diff -r b7461f7fa8a0 -r feef9ed5fc56 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java --- 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; diff -r b7461f7fa8a0 -r feef9ed5fc56 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java --- 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(); } }