diff --git a/src/assembler.h b/src/assembler.h index fa2e9be88c..a36e98d350 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -266,6 +266,7 @@ class Assembler { virtual bool reserved(int register_) = 0; + virtual unsigned argumentFootprint(unsigned footprint) = 0; virtual unsigned argumentRegisterCount() = 0; virtual int argumentRegister(unsigned index) = 0; diff --git a/src/compile.cpp b/src/compile.cpp index 8a7d61518b..4ed92f0432 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -345,8 +345,7 @@ alignedFrameSize(MyThread* t, object method) (localSize(t, method) - methodParameterFootprint(t, method) + codeMaxStack(t, methodCode(t, method)) - + MaxNativeCallFootprint - - min(MaxNativeCallFootprint, t->arch->argumentRegisterCount())); + + t->arch->argumentFootprint(MaxNativeCallFootprint)); } unsigned diff --git a/src/compiler.cpp b/src/compiler.cpp index 61cfa0097d..08f65d4904 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -635,20 +635,25 @@ class Event { unsigned readCount; }; +unsigned +usableFrameSize(Context* c) +{ + return c->alignedFrameSize - c->arch->frameFooterSize(); +} + int frameIndex(Context* c, int index) { assert(c, static_cast - (c->alignedFrameSize + c->parameterFootprint - index - 1) - >= 0); + (usableFrameSize(c) + c->parameterFootprint - index - 1) >= 0); - return c->alignedFrameSize + c->parameterFootprint - index - 1; + return usableFrameSize(c) + c->parameterFootprint - index - 1; } unsigned frameIndexToOffset(Context* c, unsigned frameIndex) { - return ((frameIndex >= c->alignedFrameSize) ? + return ((frameIndex >= usableFrameSize(c)) ? (frameIndex + (c->arch->frameFooterSize() * 2) + c->arch->frameHeaderSize()) : @@ -662,7 +667,7 @@ offsetToFrameIndex(Context* c, unsigned offset) unsigned normalizedOffset = offset / BytesPerWord; return ((normalizedOffset - >= c->alignedFrameSize + >= usableFrameSize(c) + c->arch->frameFooterSize()) ? (normalizedOffset - (c->arch->frameFooterSize() * 2) @@ -2187,7 +2192,7 @@ saveLocals(Context* c, Event* e) if (DebugReads) { fprintf(stderr, "local save read %p at %d of %d\n", local->value, ::frameIndex(c, li), - c->alignedFrameSize + c->parameterFootprint); + usableFrameSize(c) + c->parameterFootprint); } addRead(c, e, local->value, read @@ -2272,7 +2277,7 @@ class CallEvent: public Event { if (DebugReads) { fprintf(stderr, "stack arg read %p at %d of %d\n", s->value, frameIndex, - c->alignedFrameSize + c->parameterFootprint); + usableFrameSize(c) + c->parameterFootprint); } addRead(c, this, s->value, read @@ -2284,7 +2289,7 @@ class CallEvent: public Event { if (DebugReads) { fprintf(stderr, "stack save read %p at %d of %d\n", s->value, logicalIndex, - c->alignedFrameSize + c->parameterFootprint); + usableFrameSize(c) + c->parameterFootprint); } addRead(c, this, s->value, read @@ -2307,7 +2312,7 @@ class CallEvent: public Event { } popIndex - = c->alignedFrameSize + = usableFrameSize(c) + c->parameterFootprint - (stackBefore ? stackBefore->index + 1 - stackArgumentFootprint : 0) - c->localFootprint; @@ -4540,7 +4545,7 @@ class MyCompiler: public Compiler { c.localFootprint = localFootprint; c.alignedFrameSize = alignedFrameSize; - unsigned frameResourceCount = alignedFrameSize + parameterFootprint; + unsigned frameResourceCount = usableFrameSize(&c) + parameterFootprint; c.frameResources = static_cast (c.zone->allocate(sizeof(FrameResource) * frameResourceCount)); diff --git a/src/powerpc.cpp b/src/powerpc.cpp index 18929f75e3..8b50add60b 100644 --- a/src/powerpc.cpp +++ b/src/powerpc.cpp @@ -651,6 +651,8 @@ void remainderR(Context* con, unsigned size, Reg* a, Reg* b, Reg* t) { void andC(Context* c, unsigned size, Assembler::Constant* a, Assembler::Register* b, Assembler::Register* dst) { + abort(c); // todo + int64_t v = a->value->value(); if(size == 8) { @@ -667,7 +669,7 @@ void andC(Context* c, unsigned size, Assembler::Constant* a, andC(c, 4, &ah, &bh, &dh); } else { issue(c, andi(dst->low, b->low, v)); - if (not isInt16(v)) { + if (v >> 16) { issue(c, andis(dst->low, b->low, v >> 16)); } } @@ -1209,6 +1211,10 @@ class MyArchitecture: public Assembler::Architecture { } } + virtual unsigned argumentFootprint(unsigned footprint) { + return footprint; + } + virtual unsigned argumentRegisterCount() { return 8; } @@ -1266,7 +1272,7 @@ class MyArchitecture: public Assembler::Architecture { unsigned, uint8_t* aTypeMask, uint64_t* aRegisterMask, bool* thunk) { - *aTypeMask = (1 << RegisterOperand); + *aTypeMask = (1 << RegisterOperand) | (1 << ConstantOperand); *aRegisterMask = ~static_cast(0); *thunk = false; } diff --git a/src/x86.cpp b/src/x86.cpp index 83167927ce..1a867ef706 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -2021,6 +2021,11 @@ class MyArchitecture: public Assembler::Architecture { } } + virtual unsigned argumentFootprint(unsigned footprint) { + return footprint > argumentRegisterCount() ? + footprint - argumentRegisterCount() : 0; + } + virtual unsigned argumentRegisterCount() { return (BytesPerWord == 4 ? 0 : 6); }