changeset 23390:de7387a91cea

materialized value of a linear scan interval can be any Constant, remove unnecessary restriction that it must be a JavaConstant
author Christian Wimmer <christian.wimmer@oracle.com>
date Thu, 04 Feb 2016 17:19:14 -0800
parents 69a9c45e2143
children 814e83e82d16
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/Interval.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java
diffstat 3 files changed, 22 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/Interval.java	Thu Feb 04 17:18:03 2016 -0800
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/Interval.java	Thu Feb 04 17:19:14 2016 -0800
@@ -41,7 +41,7 @@
 import jdk.vm.ci.code.StackSlot;
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.AllocatableValue;
-import jdk.vm.ci.meta.JavaConstant;
+import jdk.vm.ci.meta.Constant;
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.Value;
 
@@ -547,10 +547,10 @@
      * The value with which a spilled child interval can be re-materialized. Currently this must be
      * a Constant.
      */
-    private JavaConstant materializedValue;
+    private Constant materializedValue;
 
     /**
-     * The number of times {@link #addMaterializationValue(JavaConstant)} is called.
+     * The number of times {@link #addMaterializationValue(Constant)} is called.
      */
     private int numMaterializationValuesAdded;
 
@@ -755,7 +755,7 @@
     /**
      * Sets the value which is used for re-materialization.
      */
-    public void addMaterializationValue(JavaConstant value) {
+    public void addMaterializationValue(Constant value) {
         if (numMaterializationValuesAdded == 0) {
             materializedValue = value;
         } else {
@@ -776,7 +776,7 @@
     /**
      * Returns a value which can be moved to a register instead of a restore-move from stack.
      */
-    public JavaConstant getMaterializedValue() {
+    public Constant getMaterializedValue() {
         return splitParent().materializedValue;
     }
 
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java	Thu Feb 04 17:18:03 2016 -0800
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java	Thu Feb 04 17:19:14 2016 -0800
@@ -44,6 +44,7 @@
 import jdk.vm.ci.code.TargetDescription;
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.AllocatableValue;
+import jdk.vm.ci.meta.Constant;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.Value;
@@ -823,29 +824,27 @@
      *         reload-locations in case the interval of this instruction is spilled. Currently this
      *         can only be a {@link JavaConstant}.
      */
-    protected JavaConstant getMaterializedValue(LIRInstruction op, Value operand, Interval interval) {
+    protected Constant getMaterializedValue(LIRInstruction op, Value operand, Interval interval) {
         if (op instanceof LoadConstantOp) {
             LoadConstantOp move = (LoadConstantOp) op;
-            if (move.getConstant() instanceof JavaConstant) {
 
-                if (!allocator.neverSpillConstants()) {
-                    /*
-                     * Check if the interval has any uses which would accept an stack location
-                     * (priority == ShouldHaveRegister). Rematerialization of such intervals can
-                     * result in a degradation, because rematerialization always inserts a constant
-                     * load, even if the value is not needed in a register.
-                     */
-                    Interval.UsePosList usePosList = interval.usePosList();
-                    int numUsePos = usePosList.size();
-                    for (int useIdx = 0; useIdx < numUsePos; useIdx++) {
-                        Interval.RegisterPriority priority = usePosList.registerPriority(useIdx);
-                        if (priority == Interval.RegisterPriority.ShouldHaveRegister) {
-                            return null;
-                        }
+            if (!allocator.neverSpillConstants()) {
+                /*
+                 * Check if the interval has any uses which would accept an stack location (priority
+                 * == ShouldHaveRegister). Rematerialization of such intervals can result in a
+                 * degradation, because rematerialization always inserts a constant load, even if
+                 * the value is not needed in a register.
+                 */
+                Interval.UsePosList usePosList = interval.usePosList();
+                int numUsePos = usePosList.size();
+                for (int useIdx = 0; useIdx < numUsePos; useIdx++) {
+                    Interval.RegisterPriority priority = usePosList.registerPriority(useIdx);
+                    if (priority == Interval.RegisterPriority.ShouldHaveRegister) {
+                        return null;
                     }
                 }
-                return (JavaConstant) move.getConstant();
             }
+            return move.getConstant();
         }
         return null;
     }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java	Thu Feb 04 17:18:03 2016 -0800
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java	Thu Feb 04 17:19:14 2016 -0800
@@ -33,7 +33,6 @@
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.AllocatableValue;
 import jdk.vm.ci.meta.Constant;
-import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.Value;
 
@@ -451,7 +450,7 @@
         }
         if (isIllegal(fromInterval.location()) && fromInterval.canMaterialize()) {
             // Instead of a reload, re-materialize the value
-            JavaConstant rematValue = fromInterval.getMaterializedValue();
+            Constant rematValue = fromInterval.getMaterializedValue();
             addMapping(rematValue, toInterval);
             return;
         }