more JIT bugfixes and new instructions

This commit is contained in:
Joel Dice 2007-12-12 17:18:31 -07:00
parent b2147c2c99
commit c4347bd7d3
2 changed files with 43 additions and 13 deletions

View File

@ -1498,7 +1498,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip)
c->release(tmp); c->release(tmp);
c->cmp(0, result); c->cmp(c->constant(0), result);
c->jne(next); c->jne(next);
compileThrowNew(t, frame, Machine::ClassCastExceptionType); compileThrowNew(t, frame, Machine::ClassCastExceptionType);
@ -2594,7 +2594,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip)
Operand* nonnegative = c->label(); Operand* nonnegative = c->label();
Operand* size = frame->popInt(); Operand* size = frame->popInt();
c->cmp(0, size); c->cmp(c->constant(0), size);
c->release(size); c->release(size);
c->jge(nonnegative); c->jge(nonnegative);
@ -2958,6 +2958,18 @@ finish(MyThread* t, Compiler* c, object method, Vector* objectPool,
start, start,
start + c->codeSize()); start + c->codeSize());
} }
// for debugging:
if (false and
strcmp(reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, methodClass(t, method)), 0)),
"java/lang/String") == 0 and
strcmp(reinterpret_cast<const char*>
(&byteArrayBody(t, methodName(t, method), 0)),
"getBytes") == 0)
{
asm("int3");
}
} }
return result; return result;

View File

@ -362,6 +362,10 @@ class StackOperand: public MyOperand {
base->apply(c, operation); base->apply(c, operation);
} }
virtual void apply(Context* c, Operation operation, MyOperand* operand) {
base->apply(c, operation, operand);
}
virtual void accept(Context* c, Operation operation, virtual void accept(Context* c, Operation operation,
RegisterOperand* operand) RegisterOperand* operand)
{ {
@ -514,12 +518,13 @@ pushed(Context* c)
void void
push(Context* c, int count) push(Context* c, int count)
{ {
immediate(c, count * BytesPerWord)->apply
(c, MyOperand::sub, register_(c, rsp));
while (count) { while (count) {
-- count; -- count;
pushed(c); pushed(c);
} }
immediate(c, count * BytesPerWord)->apply
(c, MyOperand::sub, register_(c, rsp));
} }
StackOperand* StackOperand*
@ -532,13 +537,14 @@ push(Context* c, MyOperand* v)
void void
pop(Context* c, int count) pop(Context* c, int count)
{ {
immediate(c, count * BytesPerWord)->apply
(c, MyOperand::add, register_(c, rsp));
while (count) { while (count) {
count -= (c->stack->footprint() / BytesPerWord); count -= (c->stack->footprint() / BytesPerWord);
assert(c, count >= 0); assert(c, count >= 0);
c->stack = c->stack->next; c->stack = c->stack->next;
} }
immediate(c, count * BytesPerWord)->apply
(c, MyOperand::add, register_(c, rsp));
} }
void void
@ -759,14 +765,12 @@ RegisterOperand::accept(Context* c, Operation operation,
case cmp: { case cmp: {
intptr_t v = operand->value->value(c); intptr_t v = operand->value->value(c);
if (v) { assert(c, isInt8(v)); // todo
assert(c, isInt8(v)); // todo
rex(c); rex(c);
c->code.append(0x83); c->code.append(0x83);
c->code.append(0xf8 | value); c->code.append(0xf8 | value);
c->code.append(v); c->code.append(v);
}
} break; } break;
case mov: { case mov: {
@ -797,6 +801,12 @@ RegisterOperand::accept(Context* c, Operation operation,
MemoryOperand* operand) MemoryOperand* operand)
{ {
switch (operation) { switch (operation) {
case cmp:
rex(c);
encode(c, 0x3b, 0, 0x40, 0x80, value, operand->base->asRegister(c),
operand->displacement);
break;
case mov: case mov:
rex(c); rex(c);
encode(c, 0x8b, 0, 0x40, 0x80, value, operand->base->asRegister(c), encode(c, 0x8b, 0, 0x40, 0x80, value, operand->base->asRegister(c),
@ -838,6 +848,14 @@ RegisterOperand::accept(Context* c, Operation operation,
AbsoluteOperand* operand) AbsoluteOperand* operand)
{ {
switch (operation) { switch (operation) {
case cmp: {
RegisterOperand* tmp = temporary(c);
addAbsoluteMovTask(c, operand->value);
tmp->accept(c, mov, immediate(c, 0));
accept(c, cmp, memory(c, tmp, 0, 0, 1));
tmp->release(c);
} break;
case mov: { case mov: {
addAbsoluteMovTask(c, operand->value); addAbsoluteMovTask(c, operand->value);