# HG changeset patch # User Doug Simon # Date 1426140785 -3600 # Node ID 2e6e20ac56b4ac953f31ec4e986e9e285babe764 # Parent c59d8ba9ced5c506dc3f01e0ba964e7a65b891c5 moved WordTypes from c.o.g.word.phases to c.o.g.word diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Thu Mar 12 07:13:05 2015 +0100 @@ -43,7 +43,7 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.options.*; import com.oracle.graal.replacements.*; -import com.oracle.graal.word.phases.*; +import com.oracle.graal.word.*; /** * Defines the {@link Plugins} used when running on HotSpot. diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotParameterPlugin.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotParameterPlugin.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotParameterPlugin.java Thu Mar 12 07:13:05 2015 +0100 @@ -29,7 +29,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.type.*; -import com.oracle.graal.word.phases.*; +import com.oracle.graal.word.*; public final class HotSpotParameterPlugin implements ParameterPlugin { private final WordTypes wordTypes; diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotWordOperationPlugin.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotWordOperationPlugin.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotWordOperationPlugin.java Thu Mar 12 07:13:05 2015 +0100 @@ -39,7 +39,7 @@ import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.replacements.*; -import com.oracle.graal.word.phases.*; +import com.oracle.graal.word.*; /** * Extends {@link WordOperationPlugin} to handle {@linkplain HotSpotOperation HotSpot word diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Thu Mar 12 07:13:05 2015 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.word.*; -import com.oracle.graal.word.phases.*; /** * Intrinsic for opening a scope binding a stack-based lock with an object. A lock scope must be diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java Thu Mar 12 07:13:05 2015 +0100 @@ -29,7 +29,6 @@ import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.word.*; -import com.oracle.graal.word.phases.*; /** * Converts a compile-time constant Java string into a C string installed with the generated code. diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Thu Mar 12 07:13:05 2015 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.word.*; -import com.oracle.graal.word.phases.*; /** * Gets the address of the C++ JavaThread object for the current thread. diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Thu Mar 12 07:13:05 2015 +0100 @@ -31,7 +31,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.word.*; -import com.oracle.graal.word.phases.*; /** * Intrinsic for getting the lock in the current {@linkplain BeginLockScopeNode lock scope}. diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Thu Mar 12 07:13:05 2015 +0100 @@ -35,7 +35,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.word.*; -import com.oracle.graal.word.phases.*; /** * Intrinsic for allocating an on-stack array of integers to hold the dimensions of a multianewarray diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Thu Mar 12 07:13:05 2015 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.word.*; -import com.oracle.graal.word.phases.*; /** * Node that is used to maintain a stack based counter of how many locks are currently held. diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Thu Mar 12 07:13:05 2015 +0100 @@ -38,7 +38,6 @@ import com.oracle.graal.replacements.*; import com.oracle.graal.replacements.nodes.*; import com.oracle.graal.word.*; -import com.oracle.graal.word.phases.*; /** * A {@linkplain #getGraph() generated} stub for a {@link Transition non-leaf} foreign call from diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotWordTypes.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotWordTypes.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotWordTypes.java Thu Mar 12 07:13:05 2015 +0100 @@ -25,7 +25,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.hotspot.nodes.type.*; -import com.oracle.graal.word.phases.*; +import com.oracle.graal.word.*; /** * Extends {@link WordTypes} with information about HotSpot metaspace pointer types. diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultGenericInvocationPlugin.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultGenericInvocationPlugin.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultGenericInvocationPlugin.java Thu Mar 12 07:13:05 2015 +0100 @@ -35,7 +35,7 @@ import com.oracle.graal.java.GraphBuilderPlugin.GenericInvocationPlugin; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.word.phases.*; +import com.oracle.graal.word.*; /** * An {@link GenericInvocationPlugin} that handles methods annotated by {@link Fold}, diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Thu Mar 12 07:13:05 2015 +0100 @@ -38,7 +38,7 @@ import com.oracle.graal.phases.common.inlining.*; import com.oracle.graal.phases.util.*; import com.oracle.graal.replacements.ReplacementsImpl.FrameStateProcessing; -import com.oracle.graal.word.phases.*; +import com.oracle.graal.word.*; /** * A utility for manually creating a graph. This will be expanded as necessary to support all diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/WordOperationPlugin.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/WordOperationPlugin.java Thu Mar 12 01:11:22 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/WordOperationPlugin.java Thu Mar 12 07:13:05 2015 +0100 @@ -42,7 +42,6 @@ import com.oracle.graal.word.Word.Opcode; import com.oracle.graal.word.Word.Operation; import com.oracle.graal.word.nodes.*; -import com.oracle.graal.word.phases.*; /** * A {@link GenericInvocationPlugin} for calls to {@linkplain Operation word operations}. diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.word/src/com/oracle/graal/word/WordTypes.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/WordTypes.java Thu Mar 12 07:13:05 2015 +0100 @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2012, 2014, 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.word; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.type.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; +import com.oracle.graal.word.Word.Operation; + +/** + * Encapsulates information for Java types representing raw words (as opposed to Objects). + */ +public class WordTypes { + + /** + * Resolved type for {@link WordBase}. + */ + private final ResolvedJavaType wordBaseType; + + /** + * Resolved type for {@link Word}. + */ + private final ResolvedJavaType wordImplType; + + /** + * Resolved type for {@link ObjectAccess}. + */ + private final ResolvedJavaType objectAccessType; + + /** + * Resolved type for {@link BarrieredAccess}. + */ + private final ResolvedJavaType barrieredAccessType; + + private final Kind wordKind; + + public WordTypes(MetaAccessProvider metaAccess, Kind wordKind) { + this.wordKind = wordKind; + this.wordBaseType = metaAccess.lookupJavaType(WordBase.class); + this.wordImplType = metaAccess.lookupJavaType(Word.class); + this.objectAccessType = metaAccess.lookupJavaType(ObjectAccess.class); + this.barrieredAccessType = metaAccess.lookupJavaType(BarrieredAccess.class); + } + + /** + * Determines if a given method denotes a word operation. + */ + public boolean isWordOperation(ResolvedJavaMethod targetMethod) { + final boolean isObjectAccess = objectAccessType.equals(targetMethod.getDeclaringClass()); + final boolean isBarrieredAccess = barrieredAccessType.equals(targetMethod.getDeclaringClass()); + if (isObjectAccess || isBarrieredAccess) { + assert targetMethod.getAnnotation(Operation.class) != null : targetMethod + " should be annotated with @" + Operation.class.getSimpleName(); + return true; + } + return isWord(targetMethod.getDeclaringClass()); + } + + /** + * Gets the method annotated with {@link Operation} based on a given method that represents a + * word operation (but may not necessarily have the annotation). + * + * @param callingContextType the {@linkplain ResolvedJavaType type} from which + * {@code targetMethod} is invoked + * @return the {@link Operation} method resolved for {@code targetMethod} if any + */ + public ResolvedJavaMethod getWordOperation(ResolvedJavaMethod targetMethod, ResolvedJavaType callingContextType) { + final boolean isWordBase = wordBaseType.isAssignableFrom(targetMethod.getDeclaringClass()); + ResolvedJavaMethod wordMethod = targetMethod; + if (isWordBase && !targetMethod.isStatic()) { + assert wordImplType.isLinked(); + wordMethod = wordImplType.resolveConcreteMethod(targetMethod, callingContextType); + } + assert wordMethod.getAnnotation(Operation.class) != null : wordMethod; + return wordMethod; + } + + /** + * Determines if a given node has a word type. + */ + public boolean isWord(ValueNode node) { + return isWord(StampTool.typeOrNull(node)); + } + + /** + * Determines if a given type is a word type. + */ + public boolean isWord(ResolvedJavaType type) { + return type != null && wordBaseType.isAssignableFrom(type); + } + + /** + * Gets the kind for a given type, returning the {@linkplain #getWordKind() word kind} if + * {@code type} is a {@linkplain #isWord(ResolvedJavaType) word type}. + */ + public Kind asKind(JavaType type) { + if (type instanceof ResolvedJavaType && isWord((ResolvedJavaType) type)) { + return wordKind; + } else { + return type.getKind(); + } + } + + public Kind getWordKind() { + return wordKind; + } + + /** + * Gets the stamp for a given {@linkplain #isWord(ResolvedJavaType) word type}. + */ + public Stamp getWordStamp(ResolvedJavaType type) { + assert isWord(type); + return StampFactory.forKind(wordKind); + } + + public ResolvedJavaType getWordImplType() { + return wordImplType; + } +} diff -r c59d8ba9ced5 -r 2e6e20ac56b4 graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypes.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypes.java Thu Mar 12 01:11:22 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2012, 2014, 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.word.phases; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.type.*; -import com.oracle.graal.word.*; -import com.oracle.graal.word.Word.Operation; - -/** - * Encapsulates information for Java types representing raw words (as opposed to Objects). - */ -public class WordTypes { - - /** - * Resolved type for {@link WordBase}. - */ - private final ResolvedJavaType wordBaseType; - - /** - * Resolved type for {@link Word}. - */ - private final ResolvedJavaType wordImplType; - - /** - * Resolved type for {@link ObjectAccess}. - */ - private final ResolvedJavaType objectAccessType; - - /** - * Resolved type for {@link BarrieredAccess}. - */ - private final ResolvedJavaType barrieredAccessType; - - private final Kind wordKind; - - public WordTypes(MetaAccessProvider metaAccess, Kind wordKind) { - this.wordKind = wordKind; - this.wordBaseType = metaAccess.lookupJavaType(WordBase.class); - this.wordImplType = metaAccess.lookupJavaType(Word.class); - this.objectAccessType = metaAccess.lookupJavaType(ObjectAccess.class); - this.barrieredAccessType = metaAccess.lookupJavaType(BarrieredAccess.class); - } - - /** - * Determines if a given method denotes a word operation. - */ - public boolean isWordOperation(ResolvedJavaMethod targetMethod) { - final boolean isObjectAccess = objectAccessType.equals(targetMethod.getDeclaringClass()); - final boolean isBarrieredAccess = barrieredAccessType.equals(targetMethod.getDeclaringClass()); - if (isObjectAccess || isBarrieredAccess) { - assert targetMethod.getAnnotation(Operation.class) != null : targetMethod + " should be annotated with @" + Operation.class.getSimpleName(); - return true; - } - return isWord(targetMethod.getDeclaringClass()); - } - - /** - * Gets the method annotated with {@link Operation} based on a given method that represents a - * word operation (but may not necessarily have the annotation). - * - * @param callingContextType the {@linkplain ResolvedJavaType type} from which - * {@code targetMethod} is invoked - * @return the {@link Operation} method resolved for {@code targetMethod} if any - */ - public ResolvedJavaMethod getWordOperation(ResolvedJavaMethod targetMethod, ResolvedJavaType callingContextType) { - final boolean isWordBase = wordBaseType.isAssignableFrom(targetMethod.getDeclaringClass()); - ResolvedJavaMethod wordMethod = targetMethod; - if (isWordBase && !targetMethod.isStatic()) { - assert wordImplType.isLinked(); - wordMethod = wordImplType.resolveConcreteMethod(targetMethod, callingContextType); - } - assert wordMethod.getAnnotation(Operation.class) != null : wordMethod; - return wordMethod; - } - - /** - * Determines if a given node has a word type. - */ - public boolean isWord(ValueNode node) { - return isWord(StampTool.typeOrNull(node)); - } - - /** - * Determines if a given type is a word type. - */ - public boolean isWord(ResolvedJavaType type) { - return type != null && wordBaseType.isAssignableFrom(type); - } - - /** - * Gets the kind for a given type, returning the {@linkplain #getWordKind() word kind} if - * {@code type} is a {@linkplain #isWord(ResolvedJavaType) word type}. - */ - public Kind asKind(JavaType type) { - if (type instanceof ResolvedJavaType && isWord((ResolvedJavaType) type)) { - return wordKind; - } else { - return type.getKind(); - } - } - - public Kind getWordKind() { - return wordKind; - } - - /** - * Gets the stamp for a given {@linkplain #isWord(ResolvedJavaType) word type}. - */ - public Stamp getWordStamp(ResolvedJavaType type) { - assert isWord(type); - return StampFactory.forKind(wordKind); - } - - public ResolvedJavaType getWordImplType() { - return wordImplType; - } -}