From 6c532e2ba43c6d92e6c99efb7bfc4011b84d9d3d Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 22 Dec 2007 17:15:46 -0700 Subject: [PATCH] fix register allocation bugs in floating point instructions --- makefile | 2 +- src/compile.cpp | 78 ++++++++++++++++++++++++------------------------ src/compiler.cpp | 2 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/makefile b/makefile index 1a701994ca..f624112c05 100644 --- a/makefile +++ b/makefile @@ -28,7 +28,7 @@ src = src classpath = classpath test = test -input = $(test-build)/Exceptions.class +input = $(test-build)/Floats.class build-cxx = g++ build-cc = gcc diff --git a/src/compile.cpp b/src/compile.cpp index 5c9ad91a3f..021160a910 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -18,7 +18,7 @@ vmJump(void* address, void* base, void* stack, void* thread); namespace { -const bool Verbose = false; +const bool Verbose = true; const bool DebugTraces = false; class MyThread: public Thread { @@ -1523,11 +1523,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(doubleToFloat)), 1, a); + c->release(a); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); } break; case d2i: { @@ -1535,11 +1535,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(doubleToInt)), 1, a); + c->release(a); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); } break; case d2l: { @@ -1547,11 +1547,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(doubleToLong)), 1, a); + c->release(a); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); } break; case dadd: { @@ -1560,12 +1560,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(addDouble)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); - c->release(b); } break; case dcmpg: { @@ -1574,12 +1574,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(compareDoublesG)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case dcmpl: { @@ -1588,20 +1588,20 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(compareDoublesL)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case dconst_0: - frame->pushLong(c->constant(doubleToBits(0.0))); + frame->pushLong(c->select8(c->constant(doubleToBits(0.0)))); break; case dconst_1: - frame->pushLong(c->constant(doubleToBits(1.0))); + frame->pushLong(c->select8(c->constant(doubleToBits(1.0)))); break; case ddiv: { @@ -1610,12 +1610,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(divideDouble)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); - c->release(b); } break; case dmul: { @@ -1624,12 +1624,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(multiplyDouble)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); - c->release(b); } break; case dneg: { @@ -1637,11 +1637,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(negateDouble)), 1, a); + c->release(a); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); } break; case vm::drem: { @@ -1650,12 +1650,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(moduloDouble)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); - c->release(b); } break; case dsub: { @@ -1664,12 +1664,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(subtractDouble)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); - c->release(b); } break; case dup: @@ -1701,11 +1701,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(floatToDouble)), 1, a); + c->release(a); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); } break; case f2i: { @@ -1713,11 +1713,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(floatToInt)), 1, a); + c->release(a); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); } break; case f2l: { @@ -1725,11 +1725,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(floatToLong)), 1, a); + c->release(a); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); } break; case fadd: { @@ -1738,12 +1738,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(addFloat)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case fcmpg: { @@ -1752,12 +1752,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(compareFloatsG)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case fcmpl: { @@ -1766,12 +1766,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(compareFloatsL)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case fconst_0: @@ -1792,12 +1792,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(divideFloat)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case fmul: { @@ -1806,12 +1806,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(multiplyFloat)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case fneg: { @@ -1819,11 +1819,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(negateFloat)), 1, a); + c->release(a); Operand* result = c->select8(c->result()); frame->pushLong(result); c->release(result); - c->release(a); } break; case vm::frem: { @@ -1832,12 +1832,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(moduloFloat)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case fsub: { @@ -1846,12 +1846,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) c->directCall (c->constant(reinterpret_cast(subtractFloat)), 2, a, b); + c->release(a); + c->release(b); Operand* result = c->select4(c->result()); frame->pushInt(result); c->release(result); - c->release(a); - c->release(b); } break; case getfield: diff --git a/src/compiler.cpp b/src/compiler.cpp index 31f4b06c8b..5f1814653d 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -2428,7 +2428,7 @@ class MyCompiler: public Compiler { } virtual void return_(Operand* v) { - mov(v, register_(&c, rax)); + mov(v, register_(&c, rax, rdx)); epilogue(); ret(); }