From d9fee1025c657864029ab6dd8a17ebde17b4a7ab Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 30 Apr 2014 20:01:14 -0600 Subject: [PATCH] use ir::Type in Compiler::return_ --- include/avian/codegen/compiler.h | 3 ++- src/codegen/compiler.cpp | 15 ++++++++++++--- src/compile.cpp | 22 ++++++++++++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/avian/codegen/compiler.h b/include/avian/codegen/compiler.h index f2962b9718..c9692be59d 100644 --- a/include/avian/codegen/compiler.h +++ b/include/avian/codegen/compiler.h @@ -106,7 +106,8 @@ class Compiler { OperandType resultType, unsigned argumentFootprint) = 0; - virtual void return_(unsigned size, Operand* value) = 0; + virtual void return_(ir::Type type, Operand* value) = 0; + virtual void return_() = 0; virtual void initLocal(unsigned size, unsigned index, OperandType type) = 0; virtual void initLocalsFromLogicalIp(unsigned logicalIp) = 0; diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index 97e39581b4..4e5cf2462d 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -2478,8 +2478,17 @@ class MyCompiler: public Compiler { return result; } - virtual void return_(unsigned size, Operand* value) { - appendReturn(&c, size, static_cast(value)); + virtual void return_(ir::Type type, Operand* value) + { + // TODO: once type information is flowed properly, enable this assert. + // Some time later, we can remove the parameter. + // assert(&c, static_cast(value)->type == type); + appendReturn(&c, type.size(), static_cast(value)); + } + + virtual void return_() + { + appendReturn(&c, 0, 0); } virtual void initLocal(unsigned footprint, unsigned index, OperandType type) @@ -2498,7 +2507,7 @@ class MyCompiler: public Compiler { lowIndex = index; } else { lowIndex = index + 1; - highIndex = index; + highIndex = index; } if (TargetBytesPerWord == 4) { diff --git a/src/compile.cpp b/src/compile.cpp index e1aa54d4eb..3a74746262 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -4290,7 +4290,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, case areturn: { handleExit(t, frame); - c->return_(TargetBytesPerWord, frame->popObject()); + c->return_(types.address, frame->popObject()); } goto next; case arraylength: { @@ -5179,10 +5179,15 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, frame->pushInt(c->binaryOp(lir::Remainder, 4, a, b)); } break; - case ireturn: + case ireturn: { + handleExit(t, frame); + c->return_(types.i4, frame->popInt()); + } + goto next; + case freturn: { handleExit(t, frame); - c->return_(4, frame->popInt()); + c->return_(types.f4, frame->popInt()); } goto next; case istore: @@ -5472,10 +5477,15 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, frame->pushLong(c->binaryOp(lir::Remainder, 8, a, b)); } break; - case lreturn: + case lreturn: { + handleExit(t, frame); + c->return_(types.i8, frame->popLong()); + } + goto next; + case dreturn: { handleExit(t, frame); - c->return_(8, frame->popLong()); + c->return_(types.f8, frame->popLong()); } goto next; case lshl: @@ -5887,7 +5897,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp, } handleExit(t, frame); - c->return_(0, 0); + c->return_(); goto next; case sipush: