mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
various bugfixes
This commit is contained in:
parent
3d1ef68001
commit
57cec2d068
@ -738,13 +738,6 @@ translateLocalIndex(Context* context, unsigned footprint, unsigned index)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
initLocal(Context* context, unsigned footprint, unsigned index)
|
||||
{
|
||||
context->compiler->initLocal
|
||||
(footprint, translateLocalIndex(context, footprint, index));
|
||||
}
|
||||
|
||||
Compiler::Operand*
|
||||
loadLocal(Context* context, unsigned footprint, unsigned index)
|
||||
{
|
||||
@ -1105,13 +1098,7 @@ class Frame {
|
||||
|
||||
void pop(unsigned count) {
|
||||
popped(count);
|
||||
|
||||
for (unsigned i = count; i;) {
|
||||
Compiler::StackElement* s = c->top();
|
||||
unsigned footprint = c->footprint(s);
|
||||
c->popped(footprint);
|
||||
i -= footprint;
|
||||
}
|
||||
c->popped(count);
|
||||
}
|
||||
|
||||
Compiler::Operand* popInt() {
|
||||
@ -3261,8 +3248,9 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
||||
uint8_t index = codeBody(t, code, ip++);
|
||||
int8_t count = codeBody(t, code, ip++);
|
||||
|
||||
c->storeLocal
|
||||
(1, c->add(4, c->constant(count), loadLocal(context, 1, index)),
|
||||
storeLocal
|
||||
(context, 1,
|
||||
c->add(4, c->constant(count), loadLocal(context, 1, index)),
|
||||
index);
|
||||
} break;
|
||||
|
||||
@ -3810,7 +3798,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
||||
|
||||
unsigned offset
|
||||
= (localOffset
|
||||
(t, localSize(t, context->method) + c->index(c->top()),
|
||||
(t, localSize(t, context->method) + c->topOfStack(),
|
||||
context->method) / BytesPerWord)
|
||||
+ t->arch->frameReturnAddressSize();
|
||||
|
||||
@ -4117,8 +4105,9 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
uint16_t count = codeReadInt16(t, code, ip);
|
||||
|
||||
c->storeLocal
|
||||
(1, c->add(4, c->constant(count), loadLocal(context, 1, index)),
|
||||
storeLocal
|
||||
(context, 1,
|
||||
c->add(4, c->constant(count), loadLocal(context, 1, index)),
|
||||
index);
|
||||
} break;
|
||||
|
||||
@ -4611,10 +4600,10 @@ compile(MyThread* t, Allocator* allocator, Context* context)
|
||||
uint8_t stackMap[codeMaxStack(t, methodCode(t, context->method))];
|
||||
Frame frame(context, stackMap);
|
||||
|
||||
unsigned index = 0;
|
||||
unsigned index = methodParameterFootprint(t, context->method);
|
||||
if ((methodFlags(t, context->method) & ACC_STATIC) == 0) {
|
||||
initLocal(context, 1, index);
|
||||
frame.set(index++, Frame::Object);
|
||||
frame.set(--index, Frame::Object);
|
||||
c->initLocal(1, index);
|
||||
}
|
||||
|
||||
for (MethodSpecIterator it
|
||||
@ -4625,20 +4614,20 @@ compile(MyThread* t, Allocator* allocator, Context* context)
|
||||
switch (*it.next()) {
|
||||
case 'L':
|
||||
case '[':
|
||||
initLocal(context, 1, index);
|
||||
frame.set(index++, Frame::Object);
|
||||
frame.set(--index, Frame::Object);
|
||||
c->initLocal(1, index);
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
case 'D':
|
||||
initLocal(context, 2, index);
|
||||
frame.set(index++, Frame::Long);
|
||||
frame.set(index++, Frame::Long);
|
||||
frame.set(--index, Frame::Long);
|
||||
frame.set(--index, Frame::Long);
|
||||
c->initLocal(2, index);
|
||||
break;
|
||||
|
||||
default:
|
||||
initLocal(context, 1, index);
|
||||
frame.set(index++, Frame::Integer);
|
||||
frame.set(--index, Frame::Integer);
|
||||
c->initLocal(1, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -5151,11 +5140,10 @@ visitStackAndLocals(MyThread* t, Heap::Visitor* v, void* frame, object method,
|
||||
}
|
||||
|
||||
void
|
||||
visitArgument(MyThread* t, Heap::Visitor* v, void* stack, object method,
|
||||
unsigned index)
|
||||
visitArgument(MyThread* t, Heap::Visitor* v, void* stack, unsigned index)
|
||||
{
|
||||
v->visit(static_cast<object*>(stack)
|
||||
+ (methodParameterFootprint(t, method) - index - 1)
|
||||
+ index
|
||||
+ t->arch->frameReturnAddressSize()
|
||||
+ t->arch->frameFooterSize());
|
||||
}
|
||||
@ -5166,7 +5154,7 @@ visitArguments(MyThread* t, Heap::Visitor* v, void* stack, object method)
|
||||
unsigned index = 0;
|
||||
|
||||
if ((methodFlags(t, method) & ACC_STATIC) == 0) {
|
||||
visitArgument(t, v, stack, method, index++);
|
||||
visitArgument(t, v, stack, index++);
|
||||
}
|
||||
|
||||
for (MethodSpecIterator it
|
||||
@ -5177,7 +5165,7 @@ visitArguments(MyThread* t, Heap::Visitor* v, void* stack, object method)
|
||||
switch (*it.next()) {
|
||||
case 'L':
|
||||
case '[':
|
||||
visitArgument(t, v, stack, method, index++);
|
||||
visitArgument(t, v, stack, index++);
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
@ -5435,13 +5423,14 @@ invoke(Thread* thread, object method, ArgumentList* arguments)
|
||||
trace.nativeMethod = method;
|
||||
}
|
||||
|
||||
unsigned count = arguments->size - arguments->position;
|
||||
assert(t, arguments->position == arguments->size);
|
||||
|
||||
result = vmInvoke
|
||||
(t, reinterpret_cast<void*>(methodAddress(t, method)),
|
||||
arguments->array + arguments->position,
|
||||
count * BytesPerWord,
|
||||
t->arch->alignFrameSize(count + t->arch->frameFootprint(0))
|
||||
arguments->array,
|
||||
arguments->position * BytesPerWord,
|
||||
t->arch->alignFrameSize
|
||||
(arguments->position + t->arch->frameFootprint(0))
|
||||
* BytesPerWord,
|
||||
returnType);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ class SitePair {
|
||||
Site* high;
|
||||
};
|
||||
|
||||
class Stack: public Compiler::StackElement {
|
||||
class Stack {
|
||||
public:
|
||||
Stack(unsigned index, Value* value, Stack* next):
|
||||
index(index), value(value), next(next)
|
||||
@ -5140,35 +5140,19 @@ class MyCompiler: public Compiler {
|
||||
}
|
||||
|
||||
virtual void popped(unsigned footprint) {
|
||||
assert(&c, c.stack->value->home >= 0);
|
||||
for (; footprint; -- footprint) {
|
||||
assert(&c, c.stack->value == 0 or c.stack->value->home >= 0);
|
||||
|
||||
if (footprint > 1) {
|
||||
assert(&c, footprint == 2);
|
||||
assert(&c, c.stack->value->high == c.stack->next->value
|
||||
and ((BytesPerWord == 8) xor (c.stack->value->high != 0)));
|
||||
|
||||
popped(1);
|
||||
if (DebugFrame) {
|
||||
fprintf(stderr, "popped %p\n", c.stack->value);
|
||||
}
|
||||
|
||||
c.stack = c.stack->next;
|
||||
}
|
||||
|
||||
if (DebugFrame) {
|
||||
fprintf(stderr, "popped %p\n", c.stack->value);
|
||||
}
|
||||
|
||||
c.stack = c.stack->next;
|
||||
}
|
||||
|
||||
virtual StackElement* top() {
|
||||
return c.stack;
|
||||
}
|
||||
|
||||
virtual unsigned footprint(StackElement* e) {
|
||||
return (static_cast<Stack*>(e)->next
|
||||
and (static_cast<Stack*>(e)->next->value
|
||||
== static_cast<Stack*>(e)->value->high)) ? 2 : 1;
|
||||
}
|
||||
|
||||
virtual unsigned index(StackElement* e) {
|
||||
return static_cast<Stack*>(e)->index;
|
||||
virtual unsigned topOfStack() {
|
||||
return c.stack->index;
|
||||
}
|
||||
|
||||
virtual Operand* peek(unsigned footprint, unsigned index) {
|
||||
|
@ -35,7 +35,6 @@ class Compiler {
|
||||
static const unsigned TailJump = 1 << 2;
|
||||
|
||||
class Operand { };
|
||||
class StackElement { };
|
||||
class State { };
|
||||
class Subroutine { };
|
||||
|
||||
@ -73,9 +72,7 @@ class Compiler {
|
||||
virtual Operand* pop(unsigned footprint) = 0;
|
||||
virtual void pushed() = 0;
|
||||
virtual void popped(unsigned footprint) = 0;
|
||||
virtual StackElement* top() = 0;
|
||||
virtual unsigned footprint(StackElement*) = 0;
|
||||
virtual unsigned index(StackElement*) = 0;
|
||||
virtual unsigned topOfStack() = 0;
|
||||
virtual Operand* peek(unsigned footprint, unsigned index) = 0;
|
||||
|
||||
virtual Operand* call(Operand* address,
|
||||
|
Loading…
Reference in New Issue
Block a user