# HG changeset patch # User Thomas Wuerthinger # Date 1339081662 -7200 # Node ID 13aee5aba8ccb1b5d8d2e114be0d7b0610d00348 # Parent d89b20486d8785925770105454233af51a55fa5c Moved RiConstant to cri.ri package. diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Thu Jun 07 17:07:42 2012 +0200 @@ -26,6 +26,7 @@ import java.util.Map.Entry; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.compiler.gen.LIRGenerator.LockScope; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java Thu Jun 07 17:07:42 2012 +0200 @@ -37,6 +37,7 @@ import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ci.CiTargetMethod.Mark; +import com.oracle.max.cri.ri.*; import com.oracle.max.cri.xir.*; import com.oracle.max.cri.xir.CiXirAssembler.RuntimeCallInformation; import com.oracle.max.cri.xir.CiXirAssembler.XirInstruction; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/types/NegateObjectTypeFeedback.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/types/NegateObjectTypeFeedback.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/types/NegateObjectTypeFeedback.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.compiler.types; -import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/types/NegateScalarTypeFeedback.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/types/NegateScalarTypeFeedback.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/types/NegateScalarTypeFeedback.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.graal.compiler.types; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.types.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrier.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrier.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrier.java Thu Jun 07 17:07:42 2012 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.nodes; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/server/ReplacingStreams.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/server/ReplacingStreams.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/server/ReplacingStreams.java Thu Jun 07 17:07:42 2012 +0200 @@ -27,6 +27,7 @@ import java.util.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.hotspot.*; public class ReplacingStreams { diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Thu Jun 07 17:07:42 2012 +0200 @@ -30,6 +30,7 @@ import com.oracle.max.asm.target.amd64.*; import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Thu Jun 07 17:07:42 2012 +0200 @@ -28,6 +28,7 @@ import com.oracle.max.asm.target.amd64.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Thu Jun 07 17:07:42 2012 +0200 @@ -31,6 +31,7 @@ import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -28,6 +28,7 @@ import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.type.GenericStamp.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; /** * This class represents a value within the graph, including local variables, phis, and diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -26,7 +26,6 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; /* TODO (thomaswue/gdub) For high-level optimization purpose the compare node should be a boolean *value* (it is currently only a helper node) diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Thu Jun 07 17:07:42 2012 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.nodes.calc; import com.oracle.graal.graph.*; -import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.max.cri.util.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -25,6 +25,7 @@ import static com.oracle.max.cri.ci.CiKind.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; @NodeInfo(shortName = "==") public final class IntegerEqualsNode extends CompareNode { diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerLessThanNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerLessThanNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerLessThanNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; @NodeInfo(shortName = "<") public final class IntegerLessThanNode extends CompareNode { diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IsNullNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IsNullNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IsNullNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; /** * An IsNullNode will be true if the supplied value is null, and false if it is non-null. diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.nodes.extended; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; /** * The ValueAnchor instruction keeps non-CFG (floating) nodes above a certain point in the graph. diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessIndexedNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessIndexedNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessIndexedNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.nodes.spi.types.*; import com.oracle.graal.nodes.type.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; /** * The {@code AccessIndexedNode} class is the base class of instructions that read or write diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.nodes.java; -import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.graal.cri.*; import com.oracle.graal.nodes.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/EscapeOp.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/EscapeOp.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/EscapeOp.java Thu Jun 07 17:07:42 2012 +0200 @@ -24,7 +24,7 @@ import java.util.*; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackStore.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackStore.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackStore.java Thu Jun 07 17:07:42 2012 +0200 @@ -24,7 +24,6 @@ import java.util.*; -import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackTool.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackTool.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.nodes.spi.types; -import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeQuery.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeQuery.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeQuery.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.nodes.spi.types; -import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeFeedbackStore.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeFeedbackStore.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeFeedbackStore.java Thu Jun 07 17:07:42 2012 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; public class ScalarTypeFeedbackStore extends TypeFeedbackStore implements ScalarTypeFeedbackTool, CloneableTypeFeedback { diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeFeedbackTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeFeedbackTool.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeFeedbackTool.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.graal.nodes.spi.types; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeQuery.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeQuery.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ScalarTypeQuery.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.graal.nodes.spi.types; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/nodes/MathIntrinsicNode.java --- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/nodes/MathIntrinsicNode.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/nodes/MathIntrinsicNode.java Thu Jun 07 17:07:42 2012 +0200 @@ -35,6 +35,7 @@ import com.oracle.graal.nodes.type.*; import com.oracle.graal.snippets.target.amd64.*; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; public class MathIntrinsicNode extends FloatingNode implements Canonicalizable, LIRGenLowerable { diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ConditionTest.java --- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ConditionTest.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ConditionTest.java Thu Jun 07 17:07:42 2012 +0200 @@ -28,7 +28,7 @@ import org.junit.*; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.calc.*; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/EscapeAnalysisTest.java --- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/EscapeAnalysisTest.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/EscapeAnalysisTest.java Thu Jun 07 17:07:42 2012 +0200 @@ -31,7 +31,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; /** * In these test cases the probability of all invokes is set to a high value, such that an InliningPhase should inline them all. diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.max.cri.ci; +import com.oracle.max.cri.ri.*; + public class CiValueUtil { public static boolean isIllegal(CiValue value) { assert value != null; diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/RiConstant.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/RiConstant.java Thu Jun 07 17:07:05 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,498 +0,0 @@ -/* - * Copyright (c) 2009, 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.max.cri.ci; - -/** - * Represents a constant (boxed) value, such as an integer, floating point number, or object reference, - * within the compiler and across the compiler/runtime interface. Exports a set of {@code CiConstant} - * instances that represent frequently used constant values, such as {@link #ZERO}. - */ -public final class RiConstant extends CiValue { - private static final long serialVersionUID = -6355452536852663986L; - - private static final RiConstant[] INT_CONSTANT_CACHE = new RiConstant[100]; - static { - for (int i = 0; i < INT_CONSTANT_CACHE.length; ++i) { - INT_CONSTANT_CACHE[i] = new RiConstant(CiKind.Int, i); - } - } - - public static final RiConstant NULL_OBJECT = new RiConstant(CiKind.Object, null); - public static final RiConstant INT_MINUS_1 = new RiConstant(CiKind.Int, -1); - public static final RiConstant INT_0 = forInt(0); - public static final RiConstant INT_1 = forInt(1); - public static final RiConstant INT_2 = forInt(2); - public static final RiConstant INT_3 = forInt(3); - public static final RiConstant INT_4 = forInt(4); - public static final RiConstant INT_5 = forInt(5); - public static final RiConstant LONG_0 = new RiConstant(CiKind.Long, 0L); - public static final RiConstant LONG_1 = new RiConstant(CiKind.Long, 1L); - public static final RiConstant FLOAT_0 = new RiConstant(CiKind.Float, Float.floatToRawIntBits(0.0F)); - public static final RiConstant FLOAT_1 = new RiConstant(CiKind.Float, Float.floatToRawIntBits(1.0F)); - public static final RiConstant FLOAT_2 = new RiConstant(CiKind.Float, Float.floatToRawIntBits(2.0F)); - public static final RiConstant DOUBLE_0 = new RiConstant(CiKind.Double, Double.doubleToRawLongBits(0.0D)); - public static final RiConstant DOUBLE_1 = new RiConstant(CiKind.Double, Double.doubleToRawLongBits(1.0D)); - public static final RiConstant TRUE = new RiConstant(CiKind.Boolean, 1L); - public static final RiConstant FALSE = new RiConstant(CiKind.Boolean, 0L); - - static { - assert NULL_OBJECT.isDefaultValue(); - assert INT_0.isDefaultValue(); - assert FLOAT_0.isDefaultValue(); - assert DOUBLE_0.isDefaultValue(); - assert FALSE.isDefaultValue(); - - // Ensure difference between 0.0f and -0.0f is preserved - assert FLOAT_0 != forFloat(-0.0F); - assert !forFloat(-0.0F).isDefaultValue(); - - // Ensure difference between 0.0d and -0.0d is preserved - assert DOUBLE_0 != forDouble(-0.0d); - assert !forDouble(-0.0D).isDefaultValue(); - - assert NULL_OBJECT.isNull(); - } - - /** - * The boxed object value. This is ignored iff {@code !kind.isObject()}. - */ - private final Object object; - - /** - * The boxed primitive value as a {@code long}. This is ignored iff {@code kind.isObject()}. - * For {@code float} and {@code double} values, this value is the result of - * {@link Float#floatToRawIntBits(float)} and {@link Double#doubleToRawLongBits(double)} respectively. - */ - private final long primitive; - - /** - * Create a new constant represented by the specified object reference. - * - * @param kind the type of this constant - * @param object the value of this constant - */ - private RiConstant(CiKind kind, Object object) { - super(kind); - this.object = object; - this.primitive = 0L; - } - - /** - * Create a new constant represented by the specified primitive. - * - * @param kind the type of this constant - * @param primitive the value of this constant - */ - public RiConstant(CiKind kind, long primitive) { - super(kind); - this.object = null; - this.primitive = primitive; - } - - /** - * Checks whether this constant is non-null. - * @return {@code true} if this constant is a primitive, or an object constant that is not null - */ - public boolean isNonNull() { - return !kind.isObject() || object != null; - } - - /** - * Checks whether this constant is null. - * @return {@code true} if this constant is the null constant - */ - public boolean isNull() { - return kind.isObject() && object == null; - } - - @Override - public String toString() { - return kind.javaName + "[" + kind.format(boxedValue()) + (kind != CiKind.Object ? "|0x" + Long.toHexString(primitive) : "") + "]"; - } - - /** - * Gets this constant's value as a string. - * - * @return this constant's value as a string - */ - public String valueString() { - if (kind.isPrimitive()) { - return boxedValue().toString(); - } else if (kind.isObject()) { - if (object == null) { - return "null"; - } else if (object instanceof String) { - return "\"" + object + "\""; - } else { - return ""; - } - } else if (kind.isJsr()) { - return "bci:" + boxedValue().toString(); - } else { - return "???"; - } - } - - /** - * Returns the value of this constant as a boxed Java value. - * @return the value of this constant - */ - public Object boxedValue() { - // Checkstyle: stop - switch (kind) { - case Byte: return (byte) asInt(); - case Boolean: return asInt() == 0 ? Boolean.FALSE : Boolean.TRUE; - case Short: return (short) asInt(); - case Char: return (char) asInt(); - case Jsr: return (int) primitive; - case Int: return asInt(); - case Long: return asLong(); - case Float: return asFloat(); - case Double: return asDouble(); - case Object: return object; - } - // Checkstyle: resume - throw new IllegalArgumentException(); - } - - private boolean valueEqual(RiConstant other, boolean ignoreKind) { - // must have equivalent kinds to be equal - if (!ignoreKind && kind != other.kind) { - return false; - } - if (kind.isObject()) { - return object == other.object; - } - return primitive == other.primitive; - } - - /** - * Converts this constant to a primitive int. - * @return the int value of this constant - */ - public int asInt() { - if (kind.stackKind().isInt() || kind.isJsr()) { - return (int) primitive; - } - throw new Error("Constant is not int: " + this); - } - - /** - * Converts this constant to a primitive boolean. - * @return the boolean value of this constant - */ - public boolean asBoolean() { - if (kind == CiKind.Boolean) { - return primitive != 0L; - } - throw new Error("Constant is not boolean: " + this); - } - - /** - * Converts this constant to a primitive long. - * @return the long value of this constant - */ - public long asLong() { - // Checkstyle: stop - switch (kind.stackKind()) { - case Jsr: - case Int: - case Long: return primitive; - case Float: return (long) asFloat(); - case Double: return (long) asDouble(); - default: throw new Error("Constant is not long: " + this); - } - // Checkstyle: resume - } - - /** - * Converts this constant to a primitive float. - * @return the float value of this constant - */ - public float asFloat() { - if (kind.isFloat()) { - return Float.intBitsToFloat((int) primitive); - } - throw new Error("Constant is not float: " + this); - } - - /** - * Converts this constant to a primitive double. - * @return the double value of this constant - */ - public double asDouble() { - if (kind.isFloat()) { - return Float.intBitsToFloat((int) primitive); - } - if (kind.isDouble()) { - return Double.longBitsToDouble(primitive); - } - throw new Error("Constant is not double: " + this); - } - - /** - * Converts this constant to the object reference it represents. - * @return the object which this constant represents - */ - public Object asObject() { - if (kind.isObject()) { - return object; - } - throw new Error("Constant is not object: " + this); - } - - /** - * Converts this constant to the jsr reference it represents. - * @return the object which this constant represents - */ - public int asJsr() { - if (kind.isJsr()) { - return (int) primitive; - } - throw new Error("Constant is not jsr: " + this); - } - - /** - * Unchecked access to a primitive value. - * @return - */ - public long asPrimitive() { - if (kind.isObject()) { - throw new Error("Constant is not primitive: " + this); - } - return primitive; - } - - /** - * Computes the hashcode of this constant. - * @return a suitable hashcode for this constant - */ - @Override - public int hashCode() { - if (kind.isObject()) { - return System.identityHashCode(object); - } - return (int) primitive; - } - - /** - * Checks whether this constant equals another object. This is only - * true if the other object is a constant and has the same value. - * @param o the object to compare equality - * @return {@code true} if this constant is equivalent to the specified object - */ - @Override - public boolean equals(Object o) { - return o == this || o instanceof RiConstant && valueEqual((RiConstant) o, false); - } - - /** - * Checks whether this constant is identical to another constant or has the same value as it. - * @param other the constant to compare for equality against this constant - * @return {@code true} if this constant is equivalent to {@code other} - */ - public boolean equivalent(RiConstant other) { - return other == this || valueEqual(other, false); - } - - /** - * Checks whether this constant is the default value for its type. - * @return {@code true} if the value is the default value for its type; {@code false} otherwise - */ - public boolean isDefaultValue() { - // Checkstyle: stop - switch (kind.stackKind()) { - case Int: return asInt() == 0; - case Long: return asLong() == 0; - case Float: return this == FLOAT_0; - case Double: return this == DOUBLE_0; - case Object: return object == null; - } - // Checkstyle: resume - throw new IllegalArgumentException("Cannot det default CiConstant for kind " + kind); - } - - /** - * Gets the default value for a given kind. - * - * @return the default value for {@code kind}'s {@linkplain CiKind#stackKind() stack kind} - */ - public static RiConstant defaultValue(CiKind kind) { - // Checkstyle: stop - switch (kind.stackKind()) { - case Int: return INT_0; - case Long: return LONG_0; - case Float: return FLOAT_0; - case Double: return DOUBLE_0; - case Object: return NULL_OBJECT; - } - // Checkstyle: resume - throw new IllegalArgumentException("Cannot get default CiConstant for kind " + kind); - } - - /** - * Creates a boxed double constant. - * @param d the double value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forDouble(double d) { - if (Double.compare(0.0D, d) == 0) { - return DOUBLE_0; - } - if (Double.compare(d, 1.0D) == 0) { - return DOUBLE_1; - } - return new RiConstant(CiKind.Double, Double.doubleToRawLongBits(d)); - } - - /** - * Creates a boxed float constant. - * @param f the float value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forFloat(float f) { - if (Float.compare(f, 0.0F) == 0) { - return FLOAT_0; - } - if (Float.compare(f, 1.0F) == 0) { - return FLOAT_1; - } - if (Float.compare(f, 2.0F) == 0) { - return FLOAT_2; - } - return new RiConstant(CiKind.Float, Float.floatToRawIntBits(f)); - } - - /** - * Creates a boxed long constant. - * @param i the long value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forLong(long i) { - return i == 0 ? LONG_0 : i == 1 ? LONG_1 : new RiConstant(CiKind.Long, i); - } - - /** - * Creates a boxed integer constant. - * @param i the integer value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forInt(int i) { - if (i == -1) { - return INT_MINUS_1; - } - if (i >= 0 && i < INT_CONSTANT_CACHE.length) { - return INT_CONSTANT_CACHE[i]; - } - return new RiConstant(CiKind.Int, i); - } - - /** - * Creates a boxed byte constant. - * @param i the byte value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forByte(byte i) { - return new RiConstant(CiKind.Byte, i); - } - - /** - * Creates a boxed boolean constant. - * @param i the boolean value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forBoolean(boolean i) { - return i ? TRUE : FALSE; - } - - /** - * Creates a boxed char constant. - * @param i the char value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forChar(char i) { - return new RiConstant(CiKind.Char, i); - } - - /** - * Creates a boxed short constant. - * @param i the short value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forShort(short i) { - return new RiConstant(CiKind.Short, i); - } - - /** - * Creates a boxed address (jsr/ret address) constant. - * @param i the address value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forJsr(int i) { - return new RiConstant(CiKind.Jsr, i); - } - - /** - * Creates a boxed object constant. - * @param o the object value to box - * @return a boxed copy of {@code value} - */ - public static RiConstant forObject(Object o) { - if (o == null) { - return NULL_OBJECT; - } - return new RiConstant(CiKind.Object, o); - } - - /** - * Creates a boxed constant for the given kind from an Object. - * The object needs to be of the Java boxed type corresponding to the kind. - * @param kind the kind of the constant to create - * @param value the Java boxed value: a Byte instance for CiKind Byte, etc. - * @return the boxed copy of {@code value} - */ - public static RiConstant forBoxed(CiKind kind, Object value) { - switch (kind) { - case Boolean: - return forBoolean((Boolean) value); - case Byte: - return forByte((Byte) value); - case Char: - return forChar((Character) value); - case Short: - return forShort((Short) value); - case Int: - return forInt((Integer) value); - case Long: - return forLong((Long) value); - case Float: - return forFloat((Float) value); - case Double: - return forDouble((Double) value); - case Object: - return forObject(value); - default: - throw new RuntimeException("cannot create CiConstant for boxed " + kind + " value"); - } - } -} diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/package-info.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/package-info.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/package-info.java Thu Jun 07 17:07:42 2012 +0200 @@ -36,7 +36,7 @@ * The compiler manipulates {@link com.oracle.max.cri.ci.CiValue} instances that have a {@link com.oracle.max.cri.ci.CiKind}, and are * immutable. A concrete {@link com.oracle.max.cri.ci.CiValue value} is one of the following subclasses: *
    - *
  • {@link com.oracle.max.cri.ci.RiConstant}: a constant value. + *
  • {@link com.oracle.max.cri.ri.RiConstant}: a constant value. *
  • {@link com.oracle.max.cri.ci.CiRegisterValue}: a value stored in a {@linkplain com.oracle.max.cri.ci.CiRegister target machine register}. *
  • {@link com.oracle.max.cri.ci.CiStackSlot}: a spill slot or an outgoing stack-based argument in a method's frame. *
  • {@link com.oracle.max.cri.ci.CiAddress}: an address in target machine memory. diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiConstant.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiConstant.java Thu Jun 07 17:07:42 2012 +0200 @@ -0,0 +1,500 @@ +/* + * Copyright (c) 2009, 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.max.cri.ri; + +import com.oracle.max.cri.ci.*; + +/** + * Represents a constant (boxed) value, such as an integer, floating point number, or object reference, + * within the compiler and across the compiler/runtime interface. Exports a set of {@code CiConstant} + * instances that represent frequently used constant values, such as {@link #ZERO}. + */ +public final class RiConstant extends CiValue { + private static final long serialVersionUID = -6355452536852663986L; + + private static final RiConstant[] INT_CONSTANT_CACHE = new RiConstant[100]; + static { + for (int i = 0; i < INT_CONSTANT_CACHE.length; ++i) { + INT_CONSTANT_CACHE[i] = new RiConstant(CiKind.Int, i); + } + } + + public static final RiConstant NULL_OBJECT = new RiConstant(CiKind.Object, null); + public static final RiConstant INT_MINUS_1 = new RiConstant(CiKind.Int, -1); + public static final RiConstant INT_0 = forInt(0); + public static final RiConstant INT_1 = forInt(1); + public static final RiConstant INT_2 = forInt(2); + public static final RiConstant INT_3 = forInt(3); + public static final RiConstant INT_4 = forInt(4); + public static final RiConstant INT_5 = forInt(5); + public static final RiConstant LONG_0 = new RiConstant(CiKind.Long, 0L); + public static final RiConstant LONG_1 = new RiConstant(CiKind.Long, 1L); + public static final RiConstant FLOAT_0 = new RiConstant(CiKind.Float, Float.floatToRawIntBits(0.0F)); + public static final RiConstant FLOAT_1 = new RiConstant(CiKind.Float, Float.floatToRawIntBits(1.0F)); + public static final RiConstant FLOAT_2 = new RiConstant(CiKind.Float, Float.floatToRawIntBits(2.0F)); + public static final RiConstant DOUBLE_0 = new RiConstant(CiKind.Double, Double.doubleToRawLongBits(0.0D)); + public static final RiConstant DOUBLE_1 = new RiConstant(CiKind.Double, Double.doubleToRawLongBits(1.0D)); + public static final RiConstant TRUE = new RiConstant(CiKind.Boolean, 1L); + public static final RiConstant FALSE = new RiConstant(CiKind.Boolean, 0L); + + static { + assert NULL_OBJECT.isDefaultValue(); + assert INT_0.isDefaultValue(); + assert FLOAT_0.isDefaultValue(); + assert DOUBLE_0.isDefaultValue(); + assert FALSE.isDefaultValue(); + + // Ensure difference between 0.0f and -0.0f is preserved + assert FLOAT_0 != forFloat(-0.0F); + assert !forFloat(-0.0F).isDefaultValue(); + + // Ensure difference between 0.0d and -0.0d is preserved + assert DOUBLE_0 != forDouble(-0.0d); + assert !forDouble(-0.0D).isDefaultValue(); + + assert NULL_OBJECT.isNull(); + } + + /** + * The boxed object value. This is ignored iff {@code !kind.isObject()}. + */ + private final Object object; + + /** + * The boxed primitive value as a {@code long}. This is ignored iff {@code kind.isObject()}. + * For {@code float} and {@code double} values, this value is the result of + * {@link Float#floatToRawIntBits(float)} and {@link Double#doubleToRawLongBits(double)} respectively. + */ + private final long primitive; + + /** + * Create a new constant represented by the specified object reference. + * + * @param kind the type of this constant + * @param object the value of this constant + */ + private RiConstant(CiKind kind, Object object) { + super(kind); + this.object = object; + this.primitive = 0L; + } + + /** + * Create a new constant represented by the specified primitive. + * + * @param kind the type of this constant + * @param primitive the value of this constant + */ + public RiConstant(CiKind kind, long primitive) { + super(kind); + this.object = null; + this.primitive = primitive; + } + + /** + * Checks whether this constant is non-null. + * @return {@code true} if this constant is a primitive, or an object constant that is not null + */ + public boolean isNonNull() { + return !kind.isObject() || object != null; + } + + /** + * Checks whether this constant is null. + * @return {@code true} if this constant is the null constant + */ + public boolean isNull() { + return kind.isObject() && object == null; + } + + @Override + public String toString() { + return kind.javaName + "[" + kind.format(boxedValue()) + (kind != CiKind.Object ? "|0x" + Long.toHexString(primitive) : "") + "]"; + } + + /** + * Gets this constant's value as a string. + * + * @return this constant's value as a string + */ + public String valueString() { + if (kind.isPrimitive()) { + return boxedValue().toString(); + } else if (kind.isObject()) { + if (object == null) { + return "null"; + } else if (object instanceof String) { + return "\"" + object + "\""; + } else { + return ""; + } + } else if (kind.isJsr()) { + return "bci:" + boxedValue().toString(); + } else { + return "???"; + } + } + + /** + * Returns the value of this constant as a boxed Java value. + * @return the value of this constant + */ + public Object boxedValue() { + // Checkstyle: stop + switch (kind) { + case Byte: return (byte) asInt(); + case Boolean: return asInt() == 0 ? Boolean.FALSE : Boolean.TRUE; + case Short: return (short) asInt(); + case Char: return (char) asInt(); + case Jsr: return (int) primitive; + case Int: return asInt(); + case Long: return asLong(); + case Float: return asFloat(); + case Double: return asDouble(); + case Object: return object; + } + // Checkstyle: resume + throw new IllegalArgumentException(); + } + + private boolean valueEqual(RiConstant other, boolean ignoreKind) { + // must have equivalent kinds to be equal + if (!ignoreKind && kind != other.kind) { + return false; + } + if (kind.isObject()) { + return object == other.object; + } + return primitive == other.primitive; + } + + /** + * Converts this constant to a primitive int. + * @return the int value of this constant + */ + public int asInt() { + if (kind.stackKind().isInt() || kind.isJsr()) { + return (int) primitive; + } + throw new Error("Constant is not int: " + this); + } + + /** + * Converts this constant to a primitive boolean. + * @return the boolean value of this constant + */ + public boolean asBoolean() { + if (kind == CiKind.Boolean) { + return primitive != 0L; + } + throw new Error("Constant is not boolean: " + this); + } + + /** + * Converts this constant to a primitive long. + * @return the long value of this constant + */ + public long asLong() { + // Checkstyle: stop + switch (kind.stackKind()) { + case Jsr: + case Int: + case Long: return primitive; + case Float: return (long) asFloat(); + case Double: return (long) asDouble(); + default: throw new Error("Constant is not long: " + this); + } + // Checkstyle: resume + } + + /** + * Converts this constant to a primitive float. + * @return the float value of this constant + */ + public float asFloat() { + if (kind.isFloat()) { + return Float.intBitsToFloat((int) primitive); + } + throw new Error("Constant is not float: " + this); + } + + /** + * Converts this constant to a primitive double. + * @return the double value of this constant + */ + public double asDouble() { + if (kind.isFloat()) { + return Float.intBitsToFloat((int) primitive); + } + if (kind.isDouble()) { + return Double.longBitsToDouble(primitive); + } + throw new Error("Constant is not double: " + this); + } + + /** + * Converts this constant to the object reference it represents. + * @return the object which this constant represents + */ + public Object asObject() { + if (kind.isObject()) { + return object; + } + throw new Error("Constant is not object: " + this); + } + + /** + * Converts this constant to the jsr reference it represents. + * @return the object which this constant represents + */ + public int asJsr() { + if (kind.isJsr()) { + return (int) primitive; + } + throw new Error("Constant is not jsr: " + this); + } + + /** + * Unchecked access to a primitive value. + * @return + */ + public long asPrimitive() { + if (kind.isObject()) { + throw new Error("Constant is not primitive: " + this); + } + return primitive; + } + + /** + * Computes the hashcode of this constant. + * @return a suitable hashcode for this constant + */ + @Override + public int hashCode() { + if (kind.isObject()) { + return System.identityHashCode(object); + } + return (int) primitive; + } + + /** + * Checks whether this constant equals another object. This is only + * true if the other object is a constant and has the same value. + * @param o the object to compare equality + * @return {@code true} if this constant is equivalent to the specified object + */ + @Override + public boolean equals(Object o) { + return o == this || o instanceof RiConstant && valueEqual((RiConstant) o, false); + } + + /** + * Checks whether this constant is identical to another constant or has the same value as it. + * @param other the constant to compare for equality against this constant + * @return {@code true} if this constant is equivalent to {@code other} + */ + public boolean equivalent(RiConstant other) { + return other == this || valueEqual(other, false); + } + + /** + * Checks whether this constant is the default value for its type. + * @return {@code true} if the value is the default value for its type; {@code false} otherwise + */ + public boolean isDefaultValue() { + // Checkstyle: stop + switch (kind.stackKind()) { + case Int: return asInt() == 0; + case Long: return asLong() == 0; + case Float: return this == FLOAT_0; + case Double: return this == DOUBLE_0; + case Object: return object == null; + } + // Checkstyle: resume + throw new IllegalArgumentException("Cannot det default CiConstant for kind " + kind); + } + + /** + * Gets the default value for a given kind. + * + * @return the default value for {@code kind}'s {@linkplain CiKind#stackKind() stack kind} + */ + public static RiConstant defaultValue(CiKind kind) { + // Checkstyle: stop + switch (kind.stackKind()) { + case Int: return INT_0; + case Long: return LONG_0; + case Float: return FLOAT_0; + case Double: return DOUBLE_0; + case Object: return NULL_OBJECT; + } + // Checkstyle: resume + throw new IllegalArgumentException("Cannot get default CiConstant for kind " + kind); + } + + /** + * Creates a boxed double constant. + * @param d the double value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forDouble(double d) { + if (Double.compare(0.0D, d) == 0) { + return DOUBLE_0; + } + if (Double.compare(d, 1.0D) == 0) { + return DOUBLE_1; + } + return new RiConstant(CiKind.Double, Double.doubleToRawLongBits(d)); + } + + /** + * Creates a boxed float constant. + * @param f the float value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forFloat(float f) { + if (Float.compare(f, 0.0F) == 0) { + return FLOAT_0; + } + if (Float.compare(f, 1.0F) == 0) { + return FLOAT_1; + } + if (Float.compare(f, 2.0F) == 0) { + return FLOAT_2; + } + return new RiConstant(CiKind.Float, Float.floatToRawIntBits(f)); + } + + /** + * Creates a boxed long constant. + * @param i the long value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forLong(long i) { + return i == 0 ? LONG_0 : i == 1 ? LONG_1 : new RiConstant(CiKind.Long, i); + } + + /** + * Creates a boxed integer constant. + * @param i the integer value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forInt(int i) { + if (i == -1) { + return INT_MINUS_1; + } + if (i >= 0 && i < INT_CONSTANT_CACHE.length) { + return INT_CONSTANT_CACHE[i]; + } + return new RiConstant(CiKind.Int, i); + } + + /** + * Creates a boxed byte constant. + * @param i the byte value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forByte(byte i) { + return new RiConstant(CiKind.Byte, i); + } + + /** + * Creates a boxed boolean constant. + * @param i the boolean value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forBoolean(boolean i) { + return i ? TRUE : FALSE; + } + + /** + * Creates a boxed char constant. + * @param i the char value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forChar(char i) { + return new RiConstant(CiKind.Char, i); + } + + /** + * Creates a boxed short constant. + * @param i the short value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forShort(short i) { + return new RiConstant(CiKind.Short, i); + } + + /** + * Creates a boxed address (jsr/ret address) constant. + * @param i the address value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forJsr(int i) { + return new RiConstant(CiKind.Jsr, i); + } + + /** + * Creates a boxed object constant. + * @param o the object value to box + * @return a boxed copy of {@code value} + */ + public static RiConstant forObject(Object o) { + if (o == null) { + return NULL_OBJECT; + } + return new RiConstant(CiKind.Object, o); + } + + /** + * Creates a boxed constant for the given kind from an Object. + * The object needs to be of the Java boxed type corresponding to the kind. + * @param kind the kind of the constant to create + * @param value the Java boxed value: a Byte instance for CiKind Byte, etc. + * @return the boxed copy of {@code value} + */ + public static RiConstant forBoxed(CiKind kind, Object value) { + switch (kind) { + case Boolean: + return forBoolean((Boolean) value); + case Byte: + return forByte((Byte) value); + case Char: + return forChar((Character) value); + case Short: + return forShort((Short) value); + case Int: + return forInt((Integer) value); + case Long: + return forLong((Long) value); + case Float: + return forFloat((Float) value); + case Double: + return forDouble((Double) value); + case Object: + return forObject(value); + default: + throw new RuntimeException("cannot create CiConstant for boxed " + kind + " value"); + } + } +} diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedField.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedField.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiResolvedField.java Thu Jun 07 17:07:42 2012 +0200 @@ -25,8 +25,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; -import com.oracle.max.cri.ci.*; - /** * Represents a reference to a resolved field. Fields, like methods and types, are * resolved through {@link RiConstantPool constant pools}, and their actual implementation is provided by the diff -r d89b20486d87 -r 13aee5aba8cc graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirArgument.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirArgument.java Thu Jun 07 17:07:05 2012 +0200 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirArgument.java Thu Jun 07 17:07:42 2012 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.max.cri.xir; -import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; /** * Represents an argument to an {@link XirSnippet}.