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->cmp(0, result);
c->cmp(c->constant(0), result);
c->jne(next);
compileThrowNew(t, frame, Machine::ClassCastExceptionType);
@ -2594,7 +2594,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip)
Operand* nonnegative = c->label();
Operand* size = frame->popInt();
c->cmp(0, size);
c->cmp(c->constant(0), size);
c->release(size);
c->jge(nonnegative);
@ -2958,6 +2958,18 @@ finish(MyThread* t, Compiler* c, object method, Vector* objectPool,
start,
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;

View File

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