don't call prologue and epilogue from compileDefault, since we want the original rbp and rsp values

This commit is contained in:
Joel Dice 2007-12-11 18:19:03 -07:00
parent 33b2a4a1e8
commit fab77e4d96
3 changed files with 64 additions and 31 deletions

View File

@ -3158,13 +3158,9 @@ visitStack(MyThread* t, Heap::Visitor* v)
object
compileDefault(MyThread* t, Compiler* c)
{
c->prologue();
c->mov(c->base(), c->memory(c->thread(), difference(&(t->base), t)));
c->mov(c->stack(), c->memory(c->thread(), difference(&(t->stack), t)));
c->epilogue();
c->jmp
(c->directCall
(c->constant(reinterpret_cast<intptr_t>(compileMethod)),
@ -3693,6 +3689,10 @@ compile(MyThread* t, object method)
object
findTraceNode(MyThread* t, void* address)
{
if (Verbose) {
fprintf(stderr, "find trace node %p\n", address);
}
MyProcessor* p = processor(t);
ACQUIRE(t, t->m->classLock);
@ -3739,6 +3739,11 @@ resizeTable(MyThread* t, object oldTable, unsigned newLength)
void
insertTraceNode(MyThread* t, object node)
{
if (Verbose) {
fprintf(stderr, "insert trace node %p\n",
reinterpret_cast<void*>(traceNodeAddress(t, node)));
}
MyProcessor* p = processor(t);
PROTECT(t, node);
ACQUIRE(t, t->m->classLock);

View File

@ -285,7 +285,10 @@ class MemoryOperand: public MyOperand {
displacement(displacement),
index(index),
scale(scale)
{ }
{
assert(static_cast<System*>(0), index == 0); // todo
assert(static_cast<System*>(0), scale == 1); // todo
}
virtual StackOperand* logicalPush(Context* c);
@ -347,6 +350,10 @@ class StackOperand: public MyOperand {
return base->logicalPush(c);
}
virtual Register asRegister(Context* c) {
return base->asRegister(c);
}
virtual void accept(Context* c, Operation operation,
RegisterOperand* operand)
{
@ -677,12 +684,9 @@ void
RegisterOperand::apply(Context* c, Operation operation)
{
switch (operation) {
case push:
c->code.append(0x50 | value);
break;
case pop:
c->code.append(0x58 | value);
case call:
c->code.append(0xff);
c->code.append(0xd0 | value);
break;
case jmp:
@ -690,9 +694,12 @@ RegisterOperand::apply(Context* c, Operation operation)
c->code.append(0xe0 | value);
break;
case call:
c->code.append(0xff);
c->code.append(0xd0 | value);
case pop:
c->code.append(0x58 | value);
break;
case push:
c->code.append(0x50 | value);
break;
default: abort(c);
@ -704,6 +711,12 @@ RegisterOperand::accept(Context* c, Operation operation,
RegisterOperand* operand)
{
switch (operation) {
case add:
rex(c);
c->code.append(0x01);
c->code.append(0xc0 | (operand->value << 3) | value);
break;
case mov:
if (value != operand->value) {
rex(c);
@ -712,12 +725,6 @@ RegisterOperand::accept(Context* c, Operation operation,
}
break;
case add:
rex(c);
c->code.append(0x01);
c->code.append(0xc0 | (operand->value << 3) | value);
break;
default: abort(c);
}
}
@ -727,6 +734,23 @@ RegisterOperand::accept(Context* c, Operation operation,
ImmediateOperand* operand)
{
switch (operation) {
case and_:
if (operand->value) {
rex(c);
if (isInt8(operand->value)) {
c->code.append(0x83);
c->code.append(0xe0 | value);
c->code.append(operand->value);
} else {
assert(c, isInt32(operand->value));
c->code.append(0x81);
c->code.append(0xe0 | value);
c->code.append(operand->value);
}
}
break;
case mov:
rex(c);
c->code.append(0xb8 | value);
@ -811,7 +835,7 @@ class DirectCallTask: public IpTask {
uint8_t* instruction = code + offset + (this->start - start);
assert(c, *instruction == 0xe8);
intptr_t v = address - instruction;
intptr_t v = address - instruction - 5;
assert(c, isInt32(v));
int32_t v32 = v;
@ -833,6 +857,13 @@ void
ImmediateOperand::apply(Context* c, Operation operation)
{
switch (operation) {
case alignedCall: {
while ((c->code.length() + 1) % 4) {
c->code.append(0x90);
}
apply(c, call);
} break;
case call: {
IpMapping* mapping = currentMapping(c);
mapping->task = new (c->zone.allocate(sizeof(DirectCallTask)))
@ -842,13 +873,6 @@ ImmediateOperand::apply(Context* c, Operation operation)
c->code.append(0xE8);
c->code.append4(0);
} break;
case alignedCall: {
while ((c->code.length() + 1) % 4) {
c->code.append(0x90);
}
apply(c, call);
} break;
default: abort(c);
}
@ -884,6 +908,10 @@ void
MemoryOperand::apply(Context* c, Operation operation)
{
switch (operation) {
case call:
encode(c, 0xff, 0x10, 0x50, 0x90, rax, base->asRegister(c), displacement);
break;
case pop:
encode(c, 0x8f, 0, 0x40, 0x80, rax, base->asRegister(c), displacement);
break;

View File

@ -25,9 +25,9 @@ public class Misc {
Misc m = new Misc();
String s = "hello";
// m.foo(s);
// m.bar(s);
// baz(s);
m.foo(s);
m.bar(s);
baz(s);
// int d = alpha;
// beta = 42;