mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
various bugfixes
This commit is contained in:
parent
adb63778f0
commit
f6c4496166
@ -3873,15 +3873,15 @@ finish(MyThread* t, Context* context)
|
||||
}
|
||||
|
||||
// for debugging:
|
||||
if (false and
|
||||
if (//false and
|
||||
strcmp
|
||||
(reinterpret_cast<const char*>
|
||||
(&byteArrayBody(t, className(t, methodClass(t, context->method)), 0)),
|
||||
"java/lang/System") == 0 and
|
||||
"java/lang/Class") == 0 and
|
||||
strcmp
|
||||
(reinterpret_cast<const char*>
|
||||
(&byteArrayBody(t, methodName(t, context->method), 0)),
|
||||
"<clinit>") == 0)
|
||||
"getName") == 0)
|
||||
{
|
||||
asm("int3");
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ using namespace vm;
|
||||
|
||||
namespace {
|
||||
|
||||
const bool DebugAppend = false;
|
||||
const bool DebugCompile = false;
|
||||
const bool DebugAppend = true;
|
||||
const bool DebugCompile = true;
|
||||
const bool DebugStack = false;
|
||||
const bool DebugRegisters = false;
|
||||
const bool DebugRegisters = true;
|
||||
const bool DebugFrameIndexes = false;
|
||||
|
||||
const int AnyFrameIndex = -2;
|
||||
@ -181,7 +181,6 @@ class FrameResource {
|
||||
Value* value;
|
||||
MemorySite* site;
|
||||
unsigned size;
|
||||
unsigned freezeCount;
|
||||
};
|
||||
|
||||
class ConstantPoolNode {
|
||||
@ -486,9 +485,6 @@ class Event {
|
||||
|
||||
Event* p = c->predecessor;
|
||||
if (p) {
|
||||
p->stackAfter = stackBefore;
|
||||
p->localsAfter = localsBefore;
|
||||
|
||||
predecessors = cons(c, p, 0);
|
||||
p->successors = cons(c, this, p->successors);
|
||||
}
|
||||
@ -1809,10 +1805,14 @@ addRead(Context* c, Event* e, Value* v, Read* r)
|
||||
}
|
||||
|
||||
void
|
||||
clean(Context* c, Value* v)
|
||||
clean(Context* c, Value* v, unsigned popIndex)
|
||||
{
|
||||
for (Site** s = &(v->sites); *s;) {
|
||||
if ((*s)->match(c, 1 << MemoryOperand, 0, AnyFrameIndex)) {
|
||||
if ((*s)->match(c, 1 << MemoryOperand, 0, AnyFrameIndex)
|
||||
and localOffsetToFrameIndex
|
||||
(c, static_cast<MemorySite*>(*s)->value.offset)
|
||||
< static_cast<int>(popIndex))
|
||||
{
|
||||
s = &((*s)->next);
|
||||
} else {
|
||||
(*s)->release(c);
|
||||
@ -1822,14 +1822,15 @@ clean(Context* c, Value* v)
|
||||
}
|
||||
|
||||
void
|
||||
clean(Context* c, Event* e, Stack* stack, Local* locals, Read* reads)
|
||||
clean(Context* c, Event* e, Stack* stack, Local* locals, Read* reads,
|
||||
unsigned popIndex)
|
||||
{
|
||||
for (unsigned i = 0; i < c->localFootprint; ++i) {
|
||||
if (locals[i].value) clean(c, locals[i].value);
|
||||
if (locals[i].value) clean(c, locals[i].value, c->localFootprint);
|
||||
}
|
||||
|
||||
for (Stack* s = stack; s; s = s->next) {
|
||||
clean(c, s->value);
|
||||
clean(c, s->value, popIndex);
|
||||
}
|
||||
|
||||
for (Read* r = reads; r; r = r->eventNext) {
|
||||
@ -1860,6 +1861,7 @@ class CallEvent: public Event {
|
||||
address(address),
|
||||
traceHandler(traceHandler),
|
||||
result(result),
|
||||
popIndex(c->localFootprint),
|
||||
flags(flags),
|
||||
resultSize(resultSize)
|
||||
{
|
||||
@ -1894,11 +1896,12 @@ class CallEvent: public Event {
|
||||
addRead(c, this, s->value, read
|
||||
(c, s->size * BytesPerWord,
|
||||
1 << MemoryOperand, 0, frameIndex));
|
||||
} else {
|
||||
} else {
|
||||
unsigned index = s->index + c->localFootprint;
|
||||
if (footprint == 0) {
|
||||
assert(c, index <= frameIndex);
|
||||
s->padding = frameIndex - index;
|
||||
popIndex = index + s->size;
|
||||
}
|
||||
addRead(c, this, s->value, read
|
||||
(c, s->size * BytesPerWord, 1 << MemoryOperand, 0, index));
|
||||
@ -1927,7 +1930,7 @@ class CallEvent: public Event {
|
||||
traceHandler->handleTrace(codePromise(c, c->assembler->offset()));
|
||||
}
|
||||
|
||||
clean(c, this, stackBefore, localsBefore, reads);
|
||||
clean(c, this, stackBefore, localsBefore, reads, popIndex);
|
||||
|
||||
if (resultSize and live(result)) {
|
||||
addSite(c, 0, 0, resultSize, result, registerSite
|
||||
@ -1940,6 +1943,7 @@ class CallEvent: public Event {
|
||||
Value* address;
|
||||
TraceHandler* traceHandler;
|
||||
Value* result;
|
||||
unsigned popIndex;
|
||||
unsigned flags;
|
||||
unsigned resultSize;
|
||||
};
|
||||
@ -2178,7 +2182,8 @@ move(Context* c, Stack* stack, Local* locals, unsigned size, Value* value,
|
||||
Site* src, Site* dst)
|
||||
{
|
||||
if (dst->type(c) == MemoryOperand
|
||||
and src->type(c) == MemoryOperand)
|
||||
and (src->type(c) == MemoryOperand
|
||||
or src->type(c) == AddressOperand))
|
||||
{
|
||||
Site* tmp = freeRegisterSite(c);
|
||||
addSite(c, stack, locals, size, value, tmp);
|
||||
@ -2732,17 +2737,18 @@ Site*
|
||||
pickJunctionSite(Context* c, Value* v, Read* r, unsigned index)
|
||||
{
|
||||
if (c->availableRegisterCount > 1) {
|
||||
Site* s = r->pickSite(c, v);
|
||||
if (s
|
||||
and ((1 << s->type(c))
|
||||
& ((1 << MemoryOperand)
|
||||
| (1 << RegisterOperand))))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
if (not v->visited) {
|
||||
Site* s = r->pickSite(c, v);
|
||||
if (s and s->match
|
||||
(c, (1 << MemoryOperand) | (1 << RegisterOperand),
|
||||
~0, AnyFrameIndex))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
s = r->allocateSite(c);
|
||||
if (s) return s;
|
||||
s = r->allocateSite(c);
|
||||
if (s) return s;
|
||||
}
|
||||
|
||||
return freeRegisterSite(c);
|
||||
} else {
|
||||
@ -2769,7 +2775,7 @@ resolveJunctionSite(Context* c, Event* e, Value* v, unsigned index,
|
||||
Site* target = e->junctionSites[index];
|
||||
unsigned copyCost;
|
||||
Site* site = pick(c, v->sites, target, ©Cost);
|
||||
if (copyCost) {
|
||||
if (v->visited or copyCost) {
|
||||
move(c, e->stackAfter, e->localsAfter, r->size, v, site, target);
|
||||
} else {
|
||||
target = site;
|
||||
@ -2778,7 +2784,7 @@ resolveJunctionSite(Context* c, Event* e, Value* v, unsigned index,
|
||||
target->makeSpecific(c);
|
||||
|
||||
char buffer[256]; target->toString(c, buffer, 256);
|
||||
// fprintf(stderr, "resolve junction site %d %s %p\n", index, buffer, target);
|
||||
fprintf(stderr, "resolve junction site %d %s %p\n", index, buffer, v);
|
||||
|
||||
if (original == 0) {
|
||||
frozenSites[frozenSiteIndex++] = target;
|
||||
@ -2786,6 +2792,8 @@ resolveJunctionSite(Context* c, Event* e, Value* v, unsigned index,
|
||||
}
|
||||
}
|
||||
|
||||
v->visited = true;
|
||||
|
||||
return frozenSiteIndex;
|
||||
}
|
||||
|
||||
@ -2865,6 +2873,18 @@ populateSiteTables(Context* c, Event* e)
|
||||
(c, e, e->localsAfter[i].value, i, frozenSites, frozenSiteIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (e->stackAfter) {
|
||||
for (Stack* stack = e->stackAfter; stack; stack = stack->next) {
|
||||
stack->value->visited = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = c->localFootprint - 1; i >= 0; --i) {
|
||||
if (e->localsAfter[i].value) {
|
||||
e->localsAfter[i].value->visited = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (frozenSiteIndex) {
|
||||
@ -3064,11 +3084,14 @@ compile(Context* c)
|
||||
|
||||
if (DebugCompile) {
|
||||
fprintf(stderr,
|
||||
"compile %s at %d with %d preds, %d succs, %d stack\n",
|
||||
"compile %s at %d with %d preds %d succs %d stack before "
|
||||
"%d after\n",
|
||||
e->name(), e->logicalInstruction->index,
|
||||
count(e->predecessors), count(e->successors),
|
||||
e->stackBefore ?
|
||||
e->stackBefore->index + e->stackBefore->size : 0);
|
||||
e->stackBefore->index + e->stackBefore->size : 0,
|
||||
e->stackAfter ?
|
||||
e->stackAfter->index + e->stackAfter->size : 0);
|
||||
}
|
||||
|
||||
if (e->logicalInstruction->machineOffset == 0) {
|
||||
@ -3325,6 +3348,12 @@ class MyCompiler: public Compiler {
|
||||
appendDummy(&c);
|
||||
}
|
||||
|
||||
Event* p = c.predecessor;
|
||||
if (p) {
|
||||
p->stackAfter = c.stack;
|
||||
p->localsAfter = c.locals;
|
||||
}
|
||||
|
||||
c.logicalCode[logicalIp] = new
|
||||
(c.zone->allocate(sizeof(LogicalInstruction)))
|
||||
LogicalInstruction(logicalIp, c.stack, c.locals);
|
||||
|
22
src/x86.cpp
22
src/x86.cpp
@ -785,17 +785,17 @@ moveAR(Context* c, unsigned aSize, Assembler::Address* a,
|
||||
moveMR(c, bSize, &memory, bSize, b);
|
||||
}
|
||||
|
||||
void
|
||||
moveAM(Context* c, unsigned aSize, Assembler::Address* a,
|
||||
unsigned bSize, Assembler::Memory* b)
|
||||
{
|
||||
assert(c, BytesPerWord == 8 or (aSize == 4 and bSize == 4));
|
||||
// void
|
||||
// moveAM(Context* c, unsigned aSize, Assembler::Address* a,
|
||||
// unsigned bSize, Assembler::Memory* b)
|
||||
// {
|
||||
// assert(c, BytesPerWord == 8 or (aSize == 4 and bSize == 4));
|
||||
|
||||
Assembler::Register tmp(c->client->acquireTemporary());
|
||||
moveAR(c, aSize, a, aSize, &tmp);
|
||||
moveRM(c, aSize, &tmp, bSize, b);
|
||||
c->client->releaseTemporary(tmp.low);
|
||||
}
|
||||
// Assembler::Register tmp(c->client->acquireTemporary());
|
||||
// moveAR(c, aSize, a, aSize, &tmp);
|
||||
// moveRM(c, aSize, &tmp, bSize, b);
|
||||
// c->client->releaseTemporary(tmp.low);
|
||||
// }
|
||||
|
||||
void
|
||||
moveCR(Context* c, unsigned aSize, Assembler::Constant* a,
|
||||
@ -1282,7 +1282,7 @@ populateTables(ArchitectureContext* c)
|
||||
bo[index(Move, M, R)] = CAST2(moveMR);
|
||||
bo[index(Move, R, M)] = CAST2(moveRM);
|
||||
bo[index(Move, C, M)] = CAST2(moveCM);
|
||||
bo[index(Move, A, M)] = CAST2(moveAM);
|
||||
// bo[index(Move, A, M)] = CAST2(moveAM);
|
||||
bo[index(Move, A, R)] = CAST2(moveAR);
|
||||
// bo[index(Move, M, M)] = CAST2(moveMM);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user