# HG changeset patch # User Tom Rodriguez # Date 1437686416 25200 # Node ID bcbb9745d7954b4061a84266fac6f63455b34198 # Parent baa6dc00fd5cd0464d5b1188bf7336154d6cb5c1 Pull NamedLocationIdentity back into Graal diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Thu Jul 23 15:59:59 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Thu Jul 23 14:20:16 2015 -0700 @@ -41,10 +41,10 @@ import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*; import static com.oracle.graal.hotspot.stubs.StubUtil.*; import static com.oracle.graal.hotspot.stubs.UnwindExceptionToCallerStub.*; +import static com.oracle.graal.nodes.NamedLocationIdentity.*; import static com.oracle.graal.nodes.java.ForeignCallDescriptors.*; import static com.oracle.graal.replacements.Log.*; import static jdk.internal.jvmci.code.CallingConvention.Type.*; -import static jdk.internal.jvmci.meta.LocationIdentity.*; import java.util.*; @@ -55,6 +55,7 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.stubs.*; +import com.oracle.graal.nodes.*; import com.oracle.graal.word.*; /** diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java Thu Jul 23 15:59:59 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java Thu Jul 23 14:20:16 2015 -0700 @@ -22,13 +22,13 @@ */ package com.oracle.graal.hotspot.phases; +import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; +import static com.oracle.graal.nodes.ConstantNode.*; +import static com.oracle.graal.nodes.NamedLocationIdentity.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.hotspot.HotSpotVMConfig.*; +import jdk.internal.jvmci.hotspot.HotSpotVMConfig.CompressEncoding; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; -import static com.oracle.graal.nodes.ConstantNode.*; -import static jdk.internal.jvmci.meta.LocationIdentity.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.hotspot.nodes.*; diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/UnsafeArrayCopySnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/UnsafeArrayCopySnippets.java Thu Jul 23 15:59:59 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/UnsafeArrayCopySnippets.java Thu Jul 23 14:20:16 2015 -0700 @@ -22,18 +22,19 @@ */ package com.oracle.graal.hotspot.replacements.arraycopy; -import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.meta.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; +import static com.oracle.graal.nodes.NamedLocationIdentity.*; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*; import static com.oracle.graal.replacements.SnippetTemplate.*; -import static jdk.internal.jvmci.meta.LocationIdentity.*; +import jdk.internal.jvmci.code.*; +import jdk.internal.jvmci.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.asm.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.phases.*; +import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.replacements.*; diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UncommonTrapStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UncommonTrapStub.java Thu Jul 23 15:59:59 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UncommonTrapStub.java Thu Jul 23 14:20:16 2015 -0700 @@ -22,12 +22,12 @@ */ package com.oracle.graal.hotspot.stubs; +import static com.oracle.graal.hotspot.HotSpotBackend.*; +import static com.oracle.graal.hotspot.HotSpotBackend.Options.*; +import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.hotspot.HotSpotBackend.*; -import static com.oracle.graal.hotspot.HotSpotBackend.Options.*; -import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.asm.*; @@ -36,6 +36,7 @@ import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; +import com.oracle.graal.nodes.*; import com.oracle.graal.replacements.*; import com.oracle.graal.replacements.Snippet.ConstantParameter; import com.oracle.graal.word.*; diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/NamedLocationIdentity.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/NamedLocationIdentity.java Thu Jul 23 14:20:16 2015 -0700 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes; + +import java.util.*; + +import jdk.internal.jvmci.meta.*; +import jdk.internal.jvmci.meta.Kind.FormatWithToString; + +/** + * A {@link LocationIdentity} with a name. + */ +public class NamedLocationIdentity extends LocationIdentity implements FormatWithToString { + + /** + * Map for asserting all {@link NamedLocationIdentity} instances have a unique name. + */ + static class DB { + private static final HashSet map = new HashSet<>(); + + static boolean checkUnique(String name) { + if (!map.add(name)) { + throw new AssertionError("identity " + name + " already exists"); + } + return true; + } + } + + /** + * Denotes the location of a value that is guaranteed to be unchanging. + */ + public static final LocationIdentity FINAL_LOCATION = NamedLocationIdentity.immutable("FINAL_LOCATION"); + + /** + * Denotes the location of the length field of a Java array. + */ + public static final LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length"); + + public static LocationIdentity any() { + return ANY_LOCATION; + } + + private final String name; + private final boolean immutable; + + protected NamedLocationIdentity(String name, boolean immutable) { + this.name = name; + this.immutable = immutable; + assert DB.checkUnique(name); + } + + /** + * Creates a named unique location identity for read and write operations against mutable + * memory. + * + * @param name the name of the new location identity + */ + public static NamedLocationIdentity mutable(String name) { + return create(name, false); + } + + /** + * Creates a named unique location identity for read operations against immutable memory. + * Immutable memory will never have a visible write in the graph, which is more restictive than + * Java final. + * + * @param name the name of the new location identity + */ + public static NamedLocationIdentity immutable(String name) { + return create(name, true); + } + + /** + * Creates a named unique location identity for read and write operations. + * + * @param name the name of the new location identity + * @param immutable true if the location is immutable + */ + private static NamedLocationIdentity create(String name, boolean immutable) { + return new NamedLocationIdentity(name, immutable); + } + + @Override + public boolean isImmutable() { + return immutable; + } + + @Override + public String toString() { + return name + (isImmutable() ? ":final" : ""); + } + + /** + * Returns the named location identity for an array of the given element kind. Array accesses of + * the same kind must have the same location identity unless an alias analysis guarantees that + * two distinct arrays are accessed. + */ + public static LocationIdentity getArrayLocation(Kind elementKind) { + return ARRAY_LOCATIONS.get(elementKind); + } + + private static final EnumMap ARRAY_LOCATIONS = initArrayLocations(); + + private static EnumMap initArrayLocations() { + EnumMap result = new EnumMap<>(Kind.class); + for (Kind kind : Kind.values()) { + result.put(kind, NamedLocationIdentity.mutable("Array: " + kind.getJavaName())); + } + return result; + } +} diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/memory/ReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/memory/ReadNode.java Thu Jul 23 15:59:59 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/memory/ReadNode.java Thu Jul 23 14:20:16 2015 -0700 @@ -22,6 +22,7 @@ */ package com.oracle.graal.nodes.memory; +import static com.oracle.graal.nodes.NamedLocationIdentity.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.meta.*; @@ -126,7 +127,7 @@ return ConstantNode.forConstant(read.stamp(), constant, metaAccess); } } - if (locationIdentity.equals(LocationIdentity.ARRAY_LENGTH_LOCATION)) { + if (locationIdentity.equals(ARRAY_LENGTH_LOCATION)) { ValueNode length = GraphUtil.arrayLength(object); if (length != null) { // TODO Does this need a PiCastNode to the positive range? diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Thu Jul 23 15:59:59 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Thu Jul 23 14:20:16 2015 -0700 @@ -22,11 +22,11 @@ */ package com.oracle.graal.replacements; +import static com.oracle.graal.nodes.NamedLocationIdentity.*; import static com.oracle.graal.nodes.java.ArrayLengthNode.*; import static jdk.internal.jvmci.code.MemoryBarriers.*; import static jdk.internal.jvmci.meta.DeoptimizationAction.*; import static jdk.internal.jvmci.meta.DeoptimizationReason.*; -import static jdk.internal.jvmci.meta.LocationIdentity.*; import java.util.*; diff -r baa6dc00fd5c -r bcbb9745d795 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Thu Jul 23 15:59:59 2015 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Thu Jul 23 14:20:16 2015 -0700 @@ -22,7 +22,7 @@ */ package com.oracle.graal.virtual.phases.ea; -import static jdk.internal.jvmci.meta.LocationIdentity.*; +import static com.oracle.graal.nodes.NamedLocationIdentity.*; import java.util.*; diff -r baa6dc00fd5c -r bcbb9745d795 jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/LocationIdentity.java --- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/LocationIdentity.java Thu Jul 23 15:59:59 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/LocationIdentity.java Thu Jul 23 14:20:16 2015 -0700 @@ -27,9 +27,8 @@ // JaCoCo Exclude /** - * Marker interface for location identities. Apart from the special values {@link #ANY_LOCATION} and - * {@link #FINAL_LOCATION}, a different location identity of two memory accesses guarantees that the - * two accesses do not interfere. + * Marker interface for location identities. A different location identity of two memory accesses + * guarantees that the two accesses do not interfere. * * Clients of {@link LocationIdentity} must use {@link #equals(Object)}, not {@code ==}, when * comparing two {@link LocationIdentity} values for equality. Likewise, they must not use @@ -37,22 +36,19 @@ */ public abstract class LocationIdentity { - /** - * Denotes any location. A write to such a location kills all values in a memory map during an - * analysis of memory accesses. A read from this location cannot be moved or coalesced with - * other reads because its interaction with other reads is not known. - */ - private static final LocationIdentity ANY_LOCATION = NamedLocationIdentity.mutable("ANY_LOCATION"); + private static final class AnyLocationIdentity extends LocationIdentity { + @Override + public boolean isImmutable() { + return false; + } - /** - * Denotes the location of a value that is guaranteed to be unchanging. - */ - public static final LocationIdentity FINAL_LOCATION = NamedLocationIdentity.immutable("FINAL_LOCATION"); + @Override + public String toString() { + return "ANY_LOCATION"; + } + } - /** - * Denotes the location of the length field of a Java array. - */ - public static final LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length"); + public static final LocationIdentity ANY_LOCATION = new AnyLocationIdentity(); public static LocationIdentity any() { return ANY_LOCATION; diff -r baa6dc00fd5c -r bcbb9745d795 jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/NamedLocationIdentity.java --- a/jvmci/jdk.internal.jvmci.meta/src/jdk/internal/jvmci/meta/NamedLocationIdentity.java Thu Jul 23 15:59:59 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.jvmci.meta; - -import java.util.*; - -import jdk.internal.jvmci.meta.Kind.*; - -/** - * A {@link LocationIdentity} with a name. - */ -public class NamedLocationIdentity extends LocationIdentity implements FormatWithToString { - - /** - * Map for asserting all {@link NamedLocationIdentity} instances have a unique name. - */ - static class DB { - private static final HashSet map = new HashSet<>(); - - static boolean checkUnique(String name) { - if (!map.add(name)) { - throw new AssertionError("identity " + name + " already exists"); - } - return true; - } - } - - private final String name; - private final boolean immutable; - - protected NamedLocationIdentity(String name, boolean immutable) { - this.name = name; - this.immutable = immutable; - assert DB.checkUnique(name); - } - - /** - * Creates a named unique location identity for read and write operations against mutable - * memory. - * - * @param name the name of the new location identity - */ - public static NamedLocationIdentity mutable(String name) { - return create(name, false); - } - - /** - * Creates a named unique location identity for read operations against immutable memory. - * Immutable memory will never have a visible write in the graph, which is more restictive than - * Java final. - * - * @param name the name of the new location identity - */ - public static NamedLocationIdentity immutable(String name) { - return create(name, true); - } - - /** - * Creates a named unique location identity for read and write operations. - * - * @param name the name of the new location identity - * @param immutable true if the location is immutable - */ - private static NamedLocationIdentity create(String name, boolean immutable) { - return new NamedLocationIdentity(name, immutable); - } - - @Override - public boolean isImmutable() { - return immutable; - } - - @Override - public String toString() { - return name + (isImmutable() ? ":final" : ""); - } - - /** - * Returns the named location identity for an array of the given element kind. Array accesses of - * the same kind must have the same location identity unless an alias analysis guarantees that - * two distinct arrays are accessed. - */ - public static LocationIdentity getArrayLocation(Kind elementKind) { - return ARRAY_LOCATIONS.get(elementKind); - } - - private static final EnumMap ARRAY_LOCATIONS = initArrayLocations(); - - private static EnumMap initArrayLocations() { - EnumMap result = new EnumMap<>(Kind.class); - for (Kind kind : Kind.values()) { - result.put(kind, NamedLocationIdentity.mutable("Array: " + kind.getJavaName())); - } - return result; - } -}