From 5fc9ad058bf9f4b7d05e2deefdf9d5337d84ea1b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 10 Nov 2008 17:07:44 -0700 Subject: [PATCH] more bugfixes; all tests pass on amd64 --- src/compile.cpp | 22 ++++++++++++++++------ src/compiler.cpp | 40 ++++++++++++++++++++++------------------ src/compiler.h | 3 +-- src/x86.cpp | 13 ++++++++----- 4 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index d62d1db71c..37d31f8ec9 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -1531,14 +1531,14 @@ releaseMonitorForObject(MyThread* t, object o) } object -makeMultidimensionalArray2(MyThread* t, object class_, uintptr_t* stack, +makeMultidimensionalArray2(MyThread* t, object class_, uintptr_t* countStack, int32_t dimensions) { PROTECT(t, class_); int32_t counts[dimensions]; for (int i = dimensions - 1; i >= 0; --i) { - counts[i] = stack[dimensions - i - 1]; + counts[i] = countStack[dimensions - i - 1]; if (UNLIKELY(counts[i] < 0)) { object message = makeString(t, "%d", counts[i]); t->exception = makeNegativeArraySizeException(t, message); @@ -1557,9 +1557,11 @@ makeMultidimensionalArray2(MyThread* t, object class_, uintptr_t* stack, object makeMultidimensionalArray(MyThread* t, object class_, int32_t dimensions, - uintptr_t* stack) + int32_t offset) { - object r = makeMultidimensionalArray2(t, class_, stack, dimensions); + object r = makeMultidimensionalArray2 + (t, class_, static_cast(t->stack) + offset, dimensions); + if (UNLIKELY(t->exception)) { unwind(t); } else { @@ -3118,13 +3120,21 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, if (UNLIKELY(t->exception)) return; PROTECT(t, class_); + unsigned offset = alignedFrameSize(t, context->method) + - t->arch->frameHeaderSize() + - (localSize(t, context->method) + - methodParameterFootprint(t, context->method) + - 1) + + t->arch->frameReturnAddressSize() + - c->index(c->top()); + Compiler::Operand* result = c->call (c->constant(getThunk(t, makeMultidimensionalArrayThunk)), 0, frame->trace(0, false), BytesPerWord, 4, c->thread(), frame->append(class_), c->constant(dimensions), - c->stackTop()); + c->constant(offset)); frame->pop(dimensions); frame->pushObject(result); @@ -3867,7 +3877,7 @@ finish(MyThread* t, Context* context) strcmp (reinterpret_cast (&byteArrayBody(t, className(t, methodClass(t, context->method)), 0)), - "NullPointer") == 0 and + "Longs") == 0 and strcmp (reinterpret_cast (&byteArrayBody(t, methodName(t, context->method), 0)), diff --git a/src/compiler.cpp b/src/compiler.cpp index f5755c640f..1f3641d56a 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -1780,9 +1780,6 @@ trySteal(Context* c, Site* site, Value* v, unsigned size, Stack* stack, if (index == NoFrameIndex) { for (Stack* s = stack; s; s = s->next) { - fprintf(stderr, "%p belongs at %d\n", s->value, frameIndex - (c, s->index + c->localFootprint, s->footprint)); - if (find(v, s->value)) { uint8_t typeMask; uint64_t registerMask; @@ -2667,7 +2664,6 @@ class CombineEvent: public Event { if (c->arch->condensedAddressing()) { maybePreserve(c, stackBefore, localsBefore, secondSize, second, second->source); - removeSite(c, second, second->source); target = second->source; } else { target = resultRead->allocateSite(c); @@ -2681,8 +2677,11 @@ class CombineEvent: public Event { nextRead(c, this, first); nextRead(c, this, second); - if (c->arch->condensedAddressing() and live(result)) { - addSite(c, 0, 0, resultSize, result, target); + if (c->arch->condensedAddressing()) { + removeSite(c, second, second->source); + if (live(result)) { + addSite(c, 0, 0, resultSize, result, target); + } } } @@ -2904,7 +2903,6 @@ class TranslateEvent: public Event { Site* target; if (c->arch->condensedAddressing()) { maybePreserve(c, stackBefore, localsBefore, size, value, value->source); - removeSite(c, value, value->source); target = value->source; } else { target = resultRead->allocateSite(c); @@ -2915,8 +2913,11 @@ class TranslateEvent: public Event { nextRead(c, this, value); - if (c->arch->condensedAddressing() and live(result)) { - addSite(c, 0, 0, size, result, target); + if (c->arch->condensedAddressing()) { + removeSite(c, value, value->source); + if (live(result)) { + addSite(c, 0, 0, size, result, target); + } } } @@ -3445,8 +3446,8 @@ resolveJunctionSite(Context* c, Event* e, Value* v, if (DebugControl) { char buffer[256]; target->toString(c, buffer, 256); - fprintf(stderr, "resolved junction site %d %s %p\n", - frameIndex, buffer, v); + fprintf(stderr, "resolved junction site local %d frame %d %s %p\n", + siteIndex, frameIndex, buffer, v); } } @@ -4136,13 +4137,6 @@ class MyCompiler: public Compiler { return value(&c, s, s); } - virtual Operand* stackTop() { - Site* s = frameSite - (&c, frameIndex - (&c, c.stack->index + c.localFootprint, c.stack->footprint)); - return value(&c, s, s); - } - Promise* machineIp() { return codePromise(&c, c.logicalCode[c.logicalIp]->lastEvent); } @@ -4186,6 +4180,10 @@ class MyCompiler: public Compiler { return static_cast(e)->footprint; } + virtual unsigned index(StackElement* e) { + return static_cast(e)->index; + } + virtual Operand* peek(unsigned footprint UNUSED, unsigned index) { Stack* s = c.stack; for (unsigned i = index; i > 0;) { @@ -4312,6 +4310,12 @@ class MyCompiler: public Compiler { local->value = maybeBuddy (&c, static_cast(src), footprintSizeInBytes(footprint)); + if (footprint == 2) { + Local* clobber = local + 1; + clobber->value = 0; + clobber->footprint = 0; + } + if (DebugFrame) { fprintf(stderr, "store local %p of footprint %d at %d\n", local->value, footprint, index); diff --git a/src/compiler.h b/src/compiler.h index b72ba4bff6..038fcc63fd 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -61,8 +61,6 @@ class Compiler { virtual Operand* stack() = 0; virtual Operand* thread() = 0; - virtual Operand* stackTop() = 0; - virtual void push(unsigned footprint) = 0; virtual void push(unsigned footprint, Operand* value) = 0; virtual void save(unsigned footprint, Operand* value) = 0; @@ -71,6 +69,7 @@ class Compiler { virtual void popped() = 0; virtual StackElement* top() = 0; virtual unsigned footprint(StackElement*) = 0; + virtual unsigned index(StackElement*) = 0; virtual Operand* peek(unsigned footprint, unsigned index) = 0; virtual Operand* call(Operand* address, diff --git a/src/x86.cpp b/src/x86.cpp index 97abda39a9..df06d34e61 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -844,12 +844,10 @@ moveAR(Context* c, unsigned aSize, Assembler::Address* a, // } void -moveCR(Context* c, unsigned aSize, Assembler::Constant* a, - unsigned bSize UNUSED, Assembler::Register* b) +moveCR(Context* c, unsigned, Assembler::Constant* a, + unsigned bSize, Assembler::Register* b) { - assert(c, aSize == bSize); - - if (BytesPerWord == 4 and aSize == 8) { + if (BytesPerWord == 4 and bSize == 8) { int64_t v = a->value->value(); ResolvedPromise high((v >> 32) & 0xFFFFFFFF); @@ -2059,6 +2057,11 @@ class MyArchitecture: public Assembler::Architecture { *bTypeMask = (1 << RegisterOperand); break; + case Negate: + *aTypeMask = (1 << RegisterOperand); + *bTypeMask = (1 << RegisterOperand); + break; + case Move: if (BytesPerWord == 4) { if (aSize == 4 and bSize == 8) {