changeset 4173:15b9402dc018

Canonicalize the incoming and outgoing parameters to stack-kinds
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Thu, 29 Dec 2011 15:47:15 -0800
parents 9c060d6f5f11
children 79c91d220d73
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java
diffstat 1 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Thu Dec 29 14:06:59 2011 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Thu Dec 29 15:47:15 2011 -0800
@@ -346,10 +346,9 @@
         CiCallingConvention args = compilation.frameMap().incomingArguments();
         for (LocalNode local : compilation.graph.getNodes(LocalNode.class)) {
             int i = local.index();
-            CiValue src = args.locations[i];
+            CiValue src = toStackKind(args.locations[i]);
             CiVariable dest = emitMove(src);
-            assert src.isLegal() : "check";
-            assert src.kind.stackKind() == local.kind().stackKind() : "local type check failed";
+            assert src.kind == local.kind().stackKind() : "local type check failed";
             setResult(local, dest);
         }
     }
@@ -776,31 +775,32 @@
         }
     }
 
+    private static CiValue toStackKind(CiValue value) {
+        if (value.kind.stackKind() != value.kind) {
+            // We only have stack-kinds in the LIR, so convert the operand kind for values from the calling convention.
+            if (isRegister(value)) {
+                return asRegister(value).asValue(value.kind.stackKind());
+            } else if (isStackSlot(value)) {
+                return CiStackSlot.get(value.kind.stackKind(), asStackSlot(value).index(), asStackSlot(value).inCallerFrame());
+            } else {
+                throw Util.shouldNotReachHere();
+            }
+        }
+        return value;
+    }
+
     public List<CiValue> visitInvokeArguments(CiCallingConvention cc, Iterable<ValueNode> arguments, List<CiStackSlot> pointerSlots) {
         // for each argument, load it into the correct location
         List<CiValue> argList = new ArrayList<>();
         int j = 0;
         for (ValueNode arg : arguments) {
             if (arg != null) {
-                CiValue operand = cc.locations[j++];
-                if (isRegister(operand)) {
-                    if (operand.kind.stackKind() != operand.kind) {
-                        // We only have stack-kinds in the LIR, so convert the operand kind.
-                        operand = asRegister(operand).asValue(operand.kind.stackKind());
-                    }
+                CiValue operand = toStackKind(cc.locations[j++]);
 
-                } else if (isStackSlot(operand)) {
+                if (isStackSlot(operand) && operand.kind == CiKind.Object && pointerSlots != null) {
                     assert !asStackSlot(operand).inCallerFrame();
-                    if (operand.kind == CiKind.Object && pointerSlots != null) {
-                        // This slot must be marked explicitly in the pointer map.
-                        pointerSlots.add(asStackSlot(operand));
-                    }
-                    if (operand.kind.stackKind() != operand.kind) {
-                        // We only have stack-kinds in the LIR, so convert the operand kind.
-                        operand = CiStackSlot.get(operand.kind.stackKind(), asStackSlot(operand).index());
-                    }
-                } else {
-                    throw Util.shouldNotReachHere();
+                    // This slot must be marked explicitly in the pointer map.
+                    pointerSlots.add(asStackSlot(operand));
                 }
 
                 emitMove(operand(arg), operand);