changeset 22632:8b18c68ac486

Explicitly pass return kind to LIRGenerator.emitReturn.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 15 Sep 2015 15:36:07 +0200
parents 9dc01668ba32
children bd57042c2da5
files graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java
diffstat 7 files changed, 33 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Tue Sep 15 15:50:36 2015 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Tue Sep 15 15:36:07 2015 +0200
@@ -1451,10 +1451,10 @@
     }
 
     @Override
-    public void emitReturn(Value input) {
+    public void emitReturn(JavaKind kind, Value input) {
         AllocatableValue operand = Value.ILLEGAL;
         if (input != null) {
-            operand = resultOperandFor(input.getLIRKind());
+            operand = resultOperandFor(kind, input.getLIRKind());
             emitMove(operand, input);
         }
         append(new ReturnOp(operand));
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Tue Sep 15 15:50:36 2015 +0200
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Tue Sep 15 15:36:07 2015 +0200
@@ -204,10 +204,10 @@
     }
 
     @Override
-    public void emitReturn(Value input) {
+    public void emitReturn(JavaKind javaKind, Value input) {
         AllocatableValue operand = Value.ILLEGAL;
         if (input != null) {
-            operand = resultOperandFor(input.getLIRKind());
+            operand = resultOperandFor(javaKind, input.getLIRKind());
             emitMove(operand, input);
         }
         append(new ReturnOp(operand));
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Tue Sep 15 15:50:36 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Tue Sep 15 15:36:07 2015 +0200
@@ -255,10 +255,10 @@
     private Register pollOnReturnScratchRegister;
 
     @Override
-    public void emitReturn(Value input) {
+    public void emitReturn(JavaKind kind, Value input) {
         AllocatableValue operand = Value.ILLEGAL;
         if (input != null) {
-            operand = resultOperandFor(input.getLIRKind());
+            operand = resultOperandFor(kind, input.getLIRKind());
             emitMove(operand, input);
         }
         if (pollOnReturnScratchRegister == null) {
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Tue Sep 15 15:50:36 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Tue Sep 15 15:36:07 2015 +0200
@@ -155,10 +155,10 @@
     }
 
     @Override
-    public void emitReturn(Value input) {
+    public void emitReturn(JavaKind javaKind, Value input) {
         AllocatableValue operand = Value.ILLEGAL;
         if (input != null) {
-            operand = resultOperandFor(input.getLIRKind());
+            operand = resultOperandFor(javaKind, input.getLIRKind());
             emitMove(operand, input);
         }
         append(new SPARCHotSpotReturnOp(operand, getStub() != null, runtime().getConfig(), getSafepointAddressValue()));
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java	Tue Sep 15 15:50:36 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java	Tue Sep 15 15:36:07 2015 +0200
@@ -192,12 +192,15 @@
     /**
      * Gets the ABI specific operand used to return a value of a given kind from a method.
      *
-     * @param kind the kind of value being returned
+     * @param javaKind the kind of value being returned
+     * @param lirKind the backend type of the value being returned
      * @return the operand representing the ABI defined location used return a value of kind
      *         {@code kind}
      */
-    public AllocatableValue resultOperandFor(LIRKind kind) {
-        return res.getFrameMapBuilder().getRegisterConfig().getReturnRegister((JavaKind) kind.getPlatformKind()).asValue(kind);
+    public AllocatableValue resultOperandFor(JavaKind javaKind, LIRKind lirKind) {
+        Register reg = res.getFrameMapBuilder().getRegisterConfig().getReturnRegister(javaKind);
+        assert target().arch.canStoreValue(reg.getRegisterCategory(), lirKind.getPlatformKind());
+        return reg.asValue(lirKind);
     }
 
     public <I extends LIRInstruction> I append(I op) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java	Tue Sep 15 15:50:36 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java	Tue Sep 15 15:36:07 2015 +0200
@@ -158,7 +158,7 @@
      * Emits a return instruction. Implementations need to insert a move if the input is not in the
      * correct location.
      */
-    void emitReturn(Value input);
+    void emitReturn(JavaKind javaKind, Value input);
 
     AllocatableValue asAllocatable(Value value);
 
@@ -174,11 +174,12 @@
     /**
      * Gets the ABI specific operand used to return a value of a given kind from a method.
      *
-     * @param kind the kind of value being returned
+     * @param javaKind the {@link JavaKind} of value being returned
+     * @param lirKind the backend type of the value being returned
      * @return the operand representing the ABI defined location used return a value of kind
      *         {@code kind}
      */
-    AllocatableValue resultOperandFor(LIRKind kind);
+    AllocatableValue resultOperandFor(JavaKind javaKind, LIRKind lirKind);
 
     <I extends LIRInstruction> I append(I op);
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java	Tue Sep 15 15:50:36 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java	Tue Sep 15 15:36:07 2015 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.nodes;
 
+import jdk.internal.jvmci.meta.*;
+
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodeinfo.*;
@@ -51,10 +53,10 @@
 
     @Override
     public void generate(NodeLIRBuilderTool gen) {
-        if (this.result() == null) {
-            gen.getLIRGeneratorTool().emitReturn(null);
+        if (result == null) {
+            gen.getLIRGeneratorTool().emitReturn(JavaKind.Void, null);
         } else {
-            gen.getLIRGeneratorTool().emitReturn(gen.operand(this.result()));
+            gen.getLIRGeneratorTool().emitReturn(result.getStackKind(), gen.operand(result));
         }
     }
 
@@ -66,4 +68,14 @@
     public MemoryMapNode getMemoryMap() {
         return memoryMap;
     }
+
+    @Override
+    public boolean verify() {
+        if (graph().method() != null) {
+            JavaKind actual = result == null ? JavaKind.Void : result.getStackKind();
+            JavaKind expected = graph().method().getSignature().getReturnKind().getStackKind();
+            assertTrue(actual == expected, "return kind doesn't match: actual " + actual + ", expected: " + expected);
+        }
+        return super.verify();
+    }
 }