This commit is contained in:
Joel Dice 2008-10-18 18:15:57 -06:00
parent 26614e2182
commit 7d6ca28b2f
4 changed files with 53 additions and 28 deletions

View File

@ -3873,15 +3873,15 @@ finish(MyThread* t, Context* context)
} }
// for debugging: // for debugging:
if (false and if (//false and
strcmp strcmp
(reinterpret_cast<const char*> (reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, methodClass(t, context->method)), 0)), (&byteArrayBody(t, className(t, methodClass(t, context->method)), 0)),
"java/lang/Class") == 0 and "java/lang/Long") == 0 and
strcmp strcmp
(reinterpret_cast<const char*> (reinterpret_cast<const char*>
(&byteArrayBody(t, methodName(t, context->method), 0)), (&byteArrayBody(t, methodName(t, context->method), 0)),
"replace") == 0) "valueOf") == 0)
{ {
asm("int3"); asm("int3");
} }

View File

@ -566,7 +566,7 @@ class Event {
}; };
int int
localOffset(Context* c, int frameIndex) frameIndexToLocalOffset(Context* c, int frameIndex)
{ {
int parameterFootprint = c->parameterFootprint; int parameterFootprint = c->parameterFootprint;
int frameSize = c->alignedFrameSize; int frameSize = c->alignedFrameSize;
@ -607,7 +607,7 @@ localOffsetToFrameIndex(Context* c, int offset)
- normalizedOffset - 1)); - normalizedOffset - 1));
assert(c, frameIndex >= 0); assert(c, frameIndex >= 0);
assert(c, localOffset(c, frameIndex) == offset); assert(c, frameIndexToLocalOffset(c, frameIndex) == offset);
return frameIndex; return frameIndex;
} }
@ -1080,9 +1080,9 @@ class MemorySite: public Site {
assert(c, value.index == NoRegister); assert(c, value.index == NoRegister);
return frameIndex == AnyFrameIndex return frameIndex == AnyFrameIndex
|| (frameIndex != NoFrameIndex || (frameIndex != NoFrameIndex
&& localOffset(c, frameIndex) == value.offset); && frameIndexToLocalOffset(c, frameIndex) == value.offset);
} else { } else {
return false; return true;
} }
} else { } else {
return false; return false;
@ -1151,7 +1151,8 @@ MemorySite*
frameSite(Context* c, int frameIndex) frameSite(Context* c, int frameIndex)
{ {
assert(c, frameIndex >= 0); assert(c, frameIndex >= 0);
return memorySite(c, c->arch->stack(), localOffset(c, frameIndex)); return memorySite
(c, c->arch->stack(), frameIndexToLocalOffset(c, frameIndex));
} }
Site* Site*
@ -1505,9 +1506,9 @@ move(Context* c, Stack* stack, Local* locals, unsigned size, Value* value,
Site* tmp = freeRegisterSite(c); Site* tmp = freeRegisterSite(c);
addSite(c, stack, locals, size, value, tmp); addSite(c, stack, locals, size, value, tmp);
// char srcb[256]; src->toString(c, srcb, 256); char srcb[256]; src->toString(c, srcb, 256);
// char tmpb[256]; tmp->toString(c, tmpb, 256); char tmpb[256]; tmp->toString(c, tmpb, 256);
// fprintf(stderr, "move %s to %s for %p\n", srcb, tmpb, value); fprintf(stderr, "move %s to %s for %p\n", srcb, tmpb, value);
apply(c, Move, size, src, size, tmp); apply(c, Move, size, src, size, tmp);
src = tmp; src = tmp;
@ -1515,9 +1516,9 @@ move(Context* c, Stack* stack, Local* locals, unsigned size, Value* value,
addSite(c, stack, locals, size, value, dst); addSite(c, stack, locals, size, value, dst);
// char srcb[256]; src->toString(c, srcb, 256); char srcb[256]; src->toString(c, srcb, 256);
// char dstb[256]; dst->toString(c, dstb, 256); char dstb[256]; dst->toString(c, dstb, 256);
// fprintf(stderr, "move %s to %s for %p\n", srcb, dstb, value); fprintf(stderr, "move %s to %s for %p\n", srcb, dstb, value);
apply(c, Move, size, src, size, dst); apply(c, Move, size, src, size, dst);
} }
@ -1836,7 +1837,7 @@ trySteal(Context* c, FrameResource* r, Stack* stack, Local* locals)
int index = r - c->frameResources; int index = r - c->frameResources;
fprintf(stderr, fprintf(stderr,
"try steal frame index %d offset 0x%x from value %p site %p\n", "try steal frame index %d offset 0x%x from value %p site %p\n",
index, localOffset(c, index), r->value, r->site); index, frameIndexToLocalOffset(c, index), r->value, r->site);
} }
return trySteal(c, r->site, r->value, r->size, stack, locals); return trySteal(c, r->site, r->value, r->size, stack, locals);
@ -1854,7 +1855,7 @@ acquireFrameIndex(Context* c, int index, Stack* stack, Local* locals,
if (DebugFrameIndexes) { if (DebugFrameIndexes) {
fprintf(stderr, fprintf(stderr,
"acquire frame index %d offset 0x%x value %p site %p\n", "acquire frame index %d offset 0x%x value %p site %p\n",
index, localOffset(c, index), newValue, newSite); index, frameIndexToLocalOffset(c, index), newValue, newSite);
} }
FrameResource* r = c->frameResources + index; FrameResource* r = c->frameResources + index;
@ -1888,7 +1889,7 @@ releaseFrameIndex(Context* c, int index, bool recurse)
if (DebugFrameIndexes) { if (DebugFrameIndexes) {
fprintf(stderr, "release frame index %d offset 0x%x\n", fprintf(stderr, "release frame index %d offset 0x%x\n",
index, localOffset(c, index)); index, frameIndexToLocalOffset(c, index));
} }
FrameResource* r = c->frameResources + index; FrameResource* r = c->frameResources + index;
@ -2061,6 +2062,7 @@ class CallEvent: public Event {
for (Stack* s = stackBefore; s; s = s->next) { for (Stack* s = stackBefore; s; s = s->next) {
frameIndex -= s->size; frameIndex -= s->size;
if (footprint > 0) { if (footprint > 0) {
fprintf(stderr, "stack arg of size %d at %d of %d\n", s->size, frameIndex, c->alignedFrameSize + c->parameterFootprint);
addRead(c, this, s->value, read addRead(c, this, s->value, read
(c, s->size * BytesPerWord, (c, s->size * BytesPerWord,
1 << MemoryOperand, 0, frameIndex)); 1 << MemoryOperand, 0, frameIndex));
@ -2179,17 +2181,14 @@ class MoveEvent: public Event {
} }
virtual void compile(Context* c) { virtual void compile(Context* c) {
bool isLoad = not valid(src->reads->next(c));
bool isStore = not valid(dst->reads); bool isStore = not valid(dst->reads);
Site* target = targetOrRegister(c, dst); Site* target = targetOrRegister(c, dst);
unsigned cost = src->source->copyCost(c, target); unsigned cost = src->source->copyCost(c, target);
if (cost == 0 and (isLoad or isStore)) { if (cost == 0) {
target = src->source; target = src->source;
} }
assert(c, isLoad or isStore or target != src->source);
if (target == src->source) { if (target == src->source) {
removeSite(c, src, target); removeSite(c, src, target);
} }
@ -2210,6 +2209,10 @@ class MoveEvent: public Event {
if (target->match(c, typeMask, registerMask, frameIndex) if (target->match(c, typeMask, registerMask, frameIndex)
and not memoryToMemory) and not memoryToMemory)
{ {
char srcb[256]; src->source->toString(c, srcb, 256);
char dstb[256]; target->toString(c, dstb, 256);
fprintf(stderr, "move %s to %s for %p to %p\n", srcb, dstb, src, dst);
apply(c, type, srcSize, src->source, dstSize, target); apply(c, type, srcSize, src->source, dstSize, target);
} else { } else {
assert(c, typeMask & (1 << RegisterOperand)); assert(c, typeMask & (1 << RegisterOperand));
@ -2218,6 +2221,10 @@ class MoveEvent: public Event {
addSite(c, stackBefore, localsBefore, dstSize, dst, tmpTarget); addSite(c, stackBefore, localsBefore, dstSize, dst, tmpTarget);
char srcb[256]; src->source->toString(c, srcb, 256);
char dstb[256]; tmpTarget->toString(c, dstb, 256);
fprintf(stderr, "move %s to %s for %p to %p\n", srcb, dstb, src, dst);
apply(c, type, srcSize, src->source, dstSize, tmpTarget); apply(c, type, srcSize, src->source, dstSize, tmpTarget);
if (isStore) { if (isStore) {
@ -2225,6 +2232,10 @@ class MoveEvent: public Event {
} }
if (memoryToMemory or isStore) { if (memoryToMemory or isStore) {
char srcb[256]; tmpTarget->toString(c, srcb, 256);
char dstb[256]; target->toString(c, dstb, 256);
fprintf(stderr, "move %s to %s for %p to %p\n", srcb, dstb, src, dst);
apply(c, Move, dstSize, tmpTarget, dstSize, target); apply(c, Move, dstSize, tmpTarget, dstSize, target);
} else { } else {
removeSite(c, dst, target); removeSite(c, dst, target);

View File

@ -545,6 +545,14 @@ callC(Context* c, unsigned size UNUSED, Assembler::Constant* a)
unconditional(c, 0xe8, a); unconditional(c, 0xe8, a);
} }
void
callM(Context* c, unsigned size UNUSED, Assembler::Memory* a)
{
assert(c, size == BytesPerWord);
encode(c, 0xff, 2, a, false);
}
void void
alignedCallC(Context* c, unsigned size, Assembler::Constant* a) alignedCallC(Context* c, unsigned size, Assembler::Constant* a)
{ {
@ -921,6 +929,16 @@ moveZRR(Context* c, unsigned aSize, Assembler::Register* a,
} }
} }
void
moveZMR(Context* c, unsigned aSize UNUSED, Assembler::Memory* a,
unsigned bSize UNUSED, Assembler::Register* b)
{
assert(c, aSize == bSize);
assert(c, aSize == 2);
encode2(c, 0x0fb7, b->low, a, true);
}
void void
swapRR(Context* c, unsigned aSize UNUSED, Assembler::Register* a, swapRR(Context* c, unsigned aSize UNUSED, Assembler::Register* a,
unsigned bSize UNUSED, Assembler::Register* b) unsigned bSize UNUSED, Assembler::Register* b)
@ -1483,6 +1501,7 @@ populateTables(ArchitectureContext* c)
uo[index(Call, C)] = CAST1(callC); uo[index(Call, C)] = CAST1(callC);
uo[index(Call, R)] = CAST1(callR); uo[index(Call, R)] = CAST1(callR);
uo[index(Call, M)] = CAST1(callM);
uo[index(AlignedCall, C)] = CAST1(alignedCallC); uo[index(AlignedCall, C)] = CAST1(alignedCallC);
@ -1513,6 +1532,7 @@ populateTables(ArchitectureContext* c)
// bo[index(Move, M, M)] = CAST2(moveMM); // bo[index(Move, M, M)] = CAST2(moveMM);
bo[index(MoveZ, R, R)] = CAST2(moveZRR); bo[index(MoveZ, R, R)] = CAST2(moveZRR);
bo[index(MoveZ, M, R)] = CAST2(moveZMR);
bo[index(Swap, R, R)] = CAST2(swapRR); bo[index(Swap, R, R)] = CAST2(swapRR);

View File

@ -1,11 +1,5 @@
public class Simple { public class Simple {
private static int pow(int a, int b) {
int c = 1;
for (int i = 0; i < b; ++i) c *= a;
return c;
}
public static void main(String[] args) { public static void main(String[] args) {
pow(2, 3); System.out.println("'" + String.class.getName() + "'");
} }
} }