more JIT bugfixes; implement mul instruction

This commit is contained in:
Joel Dice 2007-12-16 16:52:38 -07:00
parent e4fbadd051
commit 56a8ce8fb1
3 changed files with 36 additions and 17 deletions

View File

@ -28,7 +28,7 @@ src = src
classpath = classpath classpath = classpath
test = test test = test
input = $(test-build)/GC.class input = $(test-build)/List.class
build-cxx = g++ build-cxx = g++
build-cc = gcc build-cc = gcc

View File

@ -872,10 +872,12 @@ unwind(MyThread* t)
} }
} }
object void*
findInterfaceMethodFromInstance(Thread* t, object method, object instance) findInterfaceMethodFromInstance(Thread* t, object method, object instance)
{ {
return findInterfaceMethod(t, method, objectClass(t, instance)); return &singletonValue
(t, methodCompiled
(t, findInterfaceMethod(t, method, objectClass(t, instance))), 0);
} }
intptr_t intptr_t
@ -2157,15 +2159,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip)
unsigned instance = parameterFootprint - 1; unsigned instance = parameterFootprint - 1;
Operand* found = c->directCall Operand* result = c->call
(c->constant (c->directCall
(reinterpret_cast<intptr_t>(findInterfaceMethodFromInstance)), (c->constant
3, c->thread(), frame->append(target), (reinterpret_cast<intptr_t>(findInterfaceMethodFromInstance)),
c->stack(frame->stack, instance)); 3, c->thread(), frame->append(target),
c->stack(frame->stack, instance)));
c->mov(c->memory(found, MethodCompiled), found);
Operand* result = c->call(c->memory(found, SingletonBody));
frame->trace(target, true); frame->trace(target, true);
@ -3009,13 +3008,13 @@ finish(MyThread* t, Compiler* c, object method, Vector* objectPool,
} }
// for debugging: // for debugging:
if (false and if (//false and
strcmp(reinterpret_cast<const char*> strcmp(reinterpret_cast<const char*>
(&byteArrayBody(t, className(t, methodClass(t, method)), 0)), (&byteArrayBody(t, className(t, methodClass(t, method)), 0)),
"java/lang/Long") == 0 and "java/util/Collections$ArrayListIterator") == 0 and
strcmp(reinterpret_cast<const char*> strcmp(reinterpret_cast<const char*>
(&byteArrayBody(t, methodName(t, method), 0)), (&byteArrayBody(t, methodName(t, method), 0)),
"toString") == 0) "<init>") == 0)
{ {
asm("int3"); asm("int3");
} }

View File

@ -1165,6 +1165,13 @@ RegisterOperand::accept(Context* c, Operation operation,
} }
break; break;
case mul:
rex(c);
c->code.append(0x0f);
c->code.append(0xaf);
c->code.append(0xc0 | (value << 3) | operand->value);
break;
default: abort(c); default: abort(c);
} }
} }
@ -1578,7 +1585,10 @@ MemoryOperand::accept(Context* c, Operation operation,
} else { } else {
switch (selection) { switch (selection) {
case S1Selection: case S1Selection:
encode(c, 0x88, operand->value, this, true); if (operand->value > rbx) {
c->code.append(0x40);
}
encode(c, 0x88, operand->value, this, false);
break; break;
case S2Selection: case S2Selection:
@ -1596,6 +1606,16 @@ MemoryOperand::accept(Context* c, Operation operation,
} }
} break; } break;
case mul: {
RegisterOperand* tmp = temporary(c);
tmp->accept(c, mov, this);
tmp->accept(c, mul, operand);
accept(c, mov, tmp);
tmp->release(c);
} break;
case rem: { case rem: {
RegisterOperand* ax = temporary(c, rax); RegisterOperand* ax = temporary(c, rax);
RegisterOperand* dx = temporary(c, rdx); RegisterOperand* dx = temporary(c, rdx);