From c4347bd7d388b96ce7bcc789c7ceedfacbf19921 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 12 Dec 2007 17:18:31 -0700 Subject: [PATCH] more JIT bugfixes and new instructions --- src/compile.cpp | 16 ++++++++++++++-- src/compiler.cpp | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 80979732d6..f110ec5d02 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -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 + (&byteArrayBody(t, className(t, methodClass(t, method)), 0)), + "java/lang/String") == 0 and + strcmp(reinterpret_cast + (&byteArrayBody(t, methodName(t, method), 0)), + "getBytes") == 0) + { + asm("int3"); + } } return result; diff --git a/src/compiler.cpp b/src/compiler.cpp index fd1a2f5de5..a3ae78180d 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -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);