mirror of
https://github.com/corda/corda.git
synced 2025-02-09 04:11:50 +00:00
various bugfixes, especially concerning frame allocation and offset calculation
This commit is contained in:
parent
6957492c7a
commit
d7d3dd5055
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<int>
|
||||
(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<FrameResource*>
|
||||
(c.zone->allocate(sizeof(FrameResource) * frameResourceCount));
|
||||
|
@ -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<uint64_t>(0);
|
||||
*thunk = false;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user