fix Compiler.compileCaller() to work on both i386 and amd64

This commit is contained in:
Joel Dice 2007-10-17 11:22:09 -06:00
parent 5fb1495f4d
commit e393f49fd6

View File

@ -692,6 +692,7 @@ class MyThread: public Thread {
ArgumentList* argumentList; ArgumentList* argumentList;
void* frame; void* frame;
void* frameData[2];
Reference* reference; Reference* reference;
}; };
@ -705,7 +706,7 @@ frameBase(void* frame)
inline bool inline bool
frameValid(void* frame) frameValid(void* frame)
{ {
return frame != 0; return frame and frameBase(frame);
} }
inline void* inline void*
@ -1648,6 +1649,12 @@ class Assembler {
mov4(src, dst, dstOffset); mov4(src, dst, dstOffset);
} }
void mov(int32_t v, Register dst, int32_t dstOffset) {
rex();
offsetInstruction(0xc7, 0, 0x40, 0x80, rax, dst, dstOffset);
code.append4(v);
}
void mov(uintptr_t v, Register dst) { void mov(uintptr_t v, Register dst) {
rex(); rex();
code.append(0xb8 | dst); code.append(0xb8 | dst);
@ -2078,6 +2085,11 @@ class Compiler: public Assembler {
- reinterpret_cast<uintptr_t>(t); - reinterpret_cast<uintptr_t>(t);
} }
unsigned threadFrameDataOffset() {
return reinterpret_cast<uintptr_t>(&(t->frameData))
- reinterpret_cast<uintptr_t>(t);
}
Compiled* compileStub() { Compiled* compileStub() {
push(rbp); push(rbp);
mov(rsp, rbp); mov(rsp, rbp);
@ -2137,16 +2149,13 @@ class Compiler: public Assembler {
Compiled* compileCaller() { Compiled* compileCaller() {
mov(rbp, FrameThread, rdi); mov(rbp, FrameThread, rdi);
lea(rsp, FrameFootprint + BytesPerWord, rcx); mov(rsp, 0, rcx);
mov(rcx, rdi, threadFrameOffset()); // set thread frame to current mov(threadFrameDataOffset() + FrameFootprint + (BytesPerWord * 2),
rdi, threadFrameOffset());
mov(rcx, rdi, threadFrameDataOffset());
mov(rbp, rdi, threadFrameDataOffset() + BytesPerWord);
push(rbp); jmp(rbx);
call(rbx);
add(BytesPerWord, rsp);
ret();
return finish(); return finish();
} }