fix ARM tails=true build

This requires adding LinkRegister to the list of reserved registers,
since it must be preserved in the thunk code generated by
compileDirectInvoke.  An alternative would be to explicitly preserve
it in that special case, but that would complicate the code quite a
bit.
This commit is contained in:
Joel Dice 2010-11-08 00:41:44 +00:00
parent cfc09f8fdb
commit 5d5dbd860b

View File

@ -171,7 +171,6 @@ const unsigned StackAlignmentInBytes = 8;
const unsigned StackAlignmentInWords = StackAlignmentInBytes / BytesPerWord; const unsigned StackAlignmentInWords = StackAlignmentInBytes / BytesPerWord;
const int ThreadRegister = 8; const int ThreadRegister = 8;
const int BaseRegister = 11;
const int StackRegister = 13; const int StackRegister = 13;
const int LinkRegister = 14; const int LinkRegister = 14;
const int ProgramCounter = 15; const int ProgramCounter = 15;
@ -914,7 +913,7 @@ moveAndUpdateRM(Context* c, unsigned srcSize UNUSED, Assembler::Register* src,
assert(c, dst->offset == 0); assert(c, dst->offset == 0);
assert(c, dst->scale == 1); assert(c, dst->scale == 1);
emit(c, str(src->low, dst->base, dst->index, dst->offset ? 1 : 0)); emit(c, str(src->low, dst->base, dst->index, 1));
} }
} }
@ -1599,6 +1598,7 @@ class MyArchitecture: public Assembler::Architecture {
virtual bool reserved(int register_) { virtual bool reserved(int register_) {
switch (register_) { switch (register_) {
case LinkRegister:
case StackRegister: case StackRegister:
case ThreadRegister: case ThreadRegister:
case ProgramCounter: case ProgramCounter:
@ -1624,7 +1624,7 @@ class MyArchitecture: public Assembler::Architecture {
virtual int argumentRegister(unsigned index) { virtual int argumentRegister(unsigned index) {
assert(&c, index < argumentRegisterCount()); assert(&c, index < argumentRegisterCount());
return index + 0; return index;
} }
virtual unsigned stackAlignmentInWords() { virtual unsigned stackAlignmentInWords() {
@ -1968,7 +1968,7 @@ class MyAssembler: public Assembler {
} }
virtual void adjustFrame(unsigned footprint) { virtual void adjustFrame(unsigned footprint) {
Register nextStack(0); Register nextStack(5);
Memory stackSrc(StackRegister, 0); Memory stackSrc(StackRegister, 0);
moveMR(&c, BytesPerWord, &stackSrc, BytesPerWord, &nextStack); moveMR(&c, BytesPerWord, &stackSrc, BytesPerWord, &nextStack);
@ -1993,23 +1993,25 @@ class MyAssembler: public Assembler {
{ {
if (TailCalls) { if (TailCalls) {
if (offset) { if (offset) {
Register tmp(0); Register link(LinkRegister);
Memory returnAddressSrc(StackRegister, 8 + (footprint * BytesPerWord)); Memory returnAddressSrc
moveMR(&c, BytesPerWord, &returnAddressSrc, BytesPerWord, &tmp); (StackRegister, BytesPerWord + (footprint * BytesPerWord));
moveMR(&c, BytesPerWord, &returnAddressSrc, BytesPerWord, &link);
emit(&c, mov(LinkRegister, tmp.low)); Register tmp(c.client->acquireTemporary());
Memory stackSrc(StackRegister, footprint * BytesPerWord); Memory stackSrc(StackRegister, footprint * BytesPerWord);
moveMR(&c, BytesPerWord, &stackSrc, BytesPerWord, &tmp); moveMR(&c, BytesPerWord, &stackSrc, BytesPerWord, &tmp);
Memory stackDst(StackRegister, (footprint - offset) * BytesPerWord); Memory stackDst(StackRegister, (footprint - offset) * BytesPerWord);
moveAndUpdateRM(&c, BytesPerWord, &tmp, BytesPerWord, &stackDst); moveAndUpdateRM(&c, BytesPerWord, &tmp, BytesPerWord, &stackDst);
c.client->releaseTemporary(tmp.low);
if (returnAddressSurrogate != NoRegister) { if (returnAddressSurrogate != NoRegister) {
assert(&c, offset > 0); assert(&c, offset > 0);
Register ras(returnAddressSurrogate); Register ras(returnAddressSurrogate);
Memory dst(StackRegister, 8 + (offset * BytesPerWord)); Memory dst(StackRegister, BytesPerWord + (offset * BytesPerWord));
moveRM(&c, BytesPerWord, &ras, BytesPerWord, &dst); moveRM(&c, BytesPerWord, &ras, BytesPerWord, &dst);
} }
@ -2035,7 +2037,7 @@ class MyAssembler: public Assembler {
assert(&c, (argumentFootprint % StackAlignmentInWords) == 0); assert(&c, (argumentFootprint % StackAlignmentInWords) == 0);
if (TailCalls and argumentFootprint > StackAlignmentInWords) { if (TailCalls and argumentFootprint > StackAlignmentInWords) {
Register tmp(0); Register tmp(5);
Memory stackSrc(StackRegister, 0); Memory stackSrc(StackRegister, 0);
moveMR(&c, BytesPerWord, &stackSrc, BytesPerWord, &tmp); moveMR(&c, BytesPerWord, &stackSrc, BytesPerWord, &tmp);