From b2cb8e0a695c47efed8bd7bc9d8c2f1efa163688 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 17 Dec 2007 17:22:37 -0700 Subject: [PATCH] JIT bugfixes; implement or and xor --- src/compile.cpp | 18 ++++++++++++------ src/compiler.cpp | 38 ++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index a8f4089a88..468517691a 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -2165,6 +2165,9 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip) object class_ = methodClass(t, target); if (isSpecialMethod(t, target, class_)) { + initClass(t, classSuper(t, class_)); + if (UNLIKELY(t->exception)) return; + target = findMethod(t, target, classSuper(t, class_)); } @@ -2996,10 +2999,10 @@ finish(MyThread* t, Compiler* c, object method, Vector* objectPool, if (false and strcmp(reinterpret_cast (&byteArrayBody(t, className(t, methodClass(t, method)), 0)), - "java/lang/String") == 0 and + "org/eclipse/swt/widgets/Display") == 0 and strcmp(reinterpret_cast (&byteArrayBody(t, methodName(t, method), 0)), - "getChars") == 0) + "init") == 0) { asm("int3"); } @@ -3066,9 +3069,13 @@ compileMethod2(MyThread* t) object node = findTraceNode(t, *static_cast(t->stack)); PROTECT(t, node); - object target = resolveTarget(t, t->stack, traceNodeTarget(t, node)); + object target = traceNodeTarget(t, node); PROTECT(t, target); + if (traceNodeVirtualCall(t, node)) { + target = resolveTarget(t, t->stack, traceNodeTarget(t, node)); + } + if (LIKELY(t->exception == 0)) { compile(t, target); } @@ -3167,15 +3174,14 @@ invokeNative2(MyThread* t, object method) memcpy(args + argOffset, sp, 8); if (BytesPerWord == 8) { ++argOffset; - --sp; } else { argOffset += 2; - sp -= 2; } + sp -= 2; } break; case POINTER_TYPE: { - args[argOffset++] = reinterpret_cast(sp--); + args[argOffset++] = *sp ? reinterpret_cast(sp--) : 0; } break; default: abort(t); diff --git a/src/compiler.cpp b/src/compiler.cpp index 1241817752..93da8d616f 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -963,10 +963,10 @@ rex(Context* c) } void -encode(Context* c, uint8_t instruction, int a, Register b, +encode(Context* c, uint8_t* instruction, unsigned length, int a, Register b, int32_t displacement, int index, unsigned scale) { - c->code.append(instruction); + c->code.append(instruction, length); uint8_t width; if (displacement == 0 and b != rbp) { @@ -1005,7 +1005,19 @@ encode(Context* c, uint8_t instruction, int a, MemoryOperand* b, bool rex) if (rex) { ::rex(c); } - encode(c, instruction, a, r, b->displacement, index, b->scale); + encode(c, &instruction, 1, a, r, b->displacement, index, b->scale); +} + +void +encode2(Context* c, uint16_t instruction, int a, MemoryOperand* b, bool rex) +{ + Register r = b->base->asRegister(c); + int index = b->index ? b->index->asRegister(c) : -1; + if (rex) { + ::rex(c); + } + uint8_t i[2] = { instruction >> 8, instruction & 0xff }; + encode(c, i, 2, a, r, b->displacement, index, b->scale); } void @@ -1221,21 +1233,15 @@ RegisterOperand::accept(Context* c, Operation operation, } else { switch (operand->selection) { case S1Selection: - rex(c); - c->code.append(0x0f); - encode(c, 0xbe, value, operand, false); + encode2(c, 0x0fbe, value, operand, true); break; case S2Selection: - rex(c); - c->code.append(0x0f); - encode(c, 0xbf, value, operand, false); + encode2(c, 0x0fbf, value, operand, true); break; case Z2Selection: - rex(c); - c->code.append(0x0f); - encode(c, 0xb7, value, operand, false); + encode2(c, 0x0fb7, value, operand, true); break; case S4Selection: @@ -1582,6 +1588,10 @@ MemoryOperand::accept(Context* c, Operation operation, tmp->release(c); } break; + case or_: { + encode(c, 0x09, operand->value, this, true); + } break; + case rem: { RegisterOperand* ax = temporary(c, rax); RegisterOperand* dx = temporary(c, rdx); @@ -1610,6 +1620,10 @@ MemoryOperand::accept(Context* c, Operation operation, encode(c, 0x29, operand->value, this, true); } break; + case xor_: { + encode(c, 0x31, operand->value, this, true); + } break; + default: abort(c); } }