various fixes to get JIT working on x86_64

This commit is contained in:
Joel Dice 2007-09-26 18:01:38 -06:00
parent 554dd76495
commit f1bdc4c745
3 changed files with 46 additions and 26 deletions

View File

@ -96,6 +96,7 @@ interpreter-depends = \
$(src)/heap.h \ $(src)/heap.h \
$(src)/finder.h \ $(src)/finder.h \
$(src)/processor.h \ $(src)/processor.h \
$(src)/process.h \
$(src)/stream.h \ $(src)/stream.h \
$(src)/constants.h \ $(src)/constants.h \
$(src)/jnienv.h \ $(src)/jnienv.h \

View File

@ -62,13 +62,20 @@ class Rope {
rear->data[position++] = v; rear->data[position++] = v;
} }
void appendAddress(uintptr_t v) { void append4(uint32_t v) {
append((v >> 0) & 0xFF); append((v >> 0) & 0xFF);
append((v >> 8) & 0xFF); append((v >> 8) & 0xFF);
append((v >> 16) & 0xFF); append((v >> 16) & 0xFF);
append((v >> 24) & 0xFF); append((v >> 24) & 0xFF);
} }
void appendAddress(uintptr_t v) {
append4(v);
if (BytesPerWord == 8) {
append4(v >> 32);
}
}
unsigned length() { unsigned length() {
return (count * Node::Size) + position; return (count * Node::Size) + position;
} }
@ -110,6 +117,12 @@ class MyThread: public Thread {
void* frame; void* frame;
}; };
inline bool
isByte(int32_t v)
{
return v == static_cast<int8_t>(v);
}
class Assembler { class Assembler {
public: public:
class Label { class Label {
@ -181,27 +194,33 @@ class Assembler {
code.append(0xc0 | (src << 3) | dst); code.append(0xc0 | (src << 3) | dst);
} }
void mov(Register src, int srcOffset, Register dst) { void mov(Register src, int32_t srcOffset, Register dst) {
rex(); rex();
code.append(0x8b); code.append(0x8b);
if (srcOffset) { if (srcOffset) {
assert(code.s, (srcOffset & 0xFFFFFF00) == 0); // todo if (isByte(srcOffset)) {
code.append(0x40 | (dst << 3) | src);
code.append(0x40 | (dst << 3) | src); code.append(srcOffset);
code.append(srcOffset); } else {
code.append(0x80 | (dst << 3) | src);
code.append4(srcOffset);
}
} else { } else {
code.append((dst << 3) | src); code.append((dst << 3) | src);
} }
} }
void mov(Register src, Register dst, int dstOffset) { void mov(Register src, Register dst, int32_t dstOffset) {
rex(); rex();
code.append(0x89); code.append(0x89);
if (dstOffset) { if (dstOffset) {
assert(code.s, (dstOffset & 0xFFFFFF00) == 0); // todo if (isByte(dstOffset)) {
code.append(0x40 | (src << 3) | dst);
code.append(0x40 | (src << 3) | dst); code.append(dstOffset);
code.append(dstOffset); } else {
code.append(0x80 | (src << 3) | dst);
code.append4(dstOffset);
}
} else { } else {
code.append((src << 3) | dst); code.append((src << 3) | dst);
} }
@ -230,16 +249,16 @@ class Assembler {
code.append(0x50 | reg); code.append(0x50 | reg);
} }
void push(Register reg, int offset) { void push(Register reg, int32_t offset) {
assert(code.s, (offset & 0xFFFFFF00) == 0); // todo assert(code.s, isByte(offset)); // todo
code.append(0xff); code.append(0xff);
code.append(0x70 | reg); code.append(0x70 | reg);
code.append(offset); code.append(offset);
} }
void push(int v) { void push(int32_t v) {
assert(code.s, (v & 0xFFFFFF00) == 0); // todo assert(code.s, isByte(v)); // todo
code.append(0x6a); code.append(0x6a);
code.append(v); code.append(v);
@ -249,8 +268,8 @@ class Assembler {
code.append(0x58 | dst); code.append(0x58 | dst);
} }
void pop(Register dst, int offset) { void pop(Register dst, int32_t offset) {
assert(code.s, (offset & 0xFFFFFF00) == 0); // todo assert(code.s, isByte(offset)); // todo
code.append(0x8f); code.append(0x8f);
code.append(0x40 | dst); code.append(0x40 | dst);
@ -263,8 +282,8 @@ class Assembler {
code.append(0xc0 | (src << 3) | dst); code.append(0xc0 | (src << 3) | dst);
} }
void add(int v, Register dst) { void add(int32_t v, Register dst) {
assert(code.s, (v & 0xFFFFFF00) == 0); // todo assert(code.s, isByte(v)); // todo
rex(); rex();
code.append(0x83); code.append(0x83);
@ -278,8 +297,8 @@ class Assembler {
code.append(0xc0 | (src << 3) | dst); code.append(0xc0 | (src << 3) | dst);
} }
void sub(int v, Register dst) { void sub(int32_t v, Register dst) {
assert(code.s, (v & 0xFFFFFF00) == 0); // todo assert(code.s, isByte(v)); // todo
rex(); rex();
code.append(0x83); code.append(0x83);
@ -293,8 +312,8 @@ class Assembler {
code.append(0xc0 | (src << 3) | dst); code.append(0xc0 | (src << 3) | dst);
} }
void or_(int v, Register dst) { void or_(int32_t v, Register dst) {
assert(code.s, (v & 0xFFFFFF00) == 0); // todo assert(code.s, isByte(v)); // todo
rex(); rex();
code.append(0x83); code.append(0x83);
@ -308,8 +327,8 @@ class Assembler {
code.append(0xc0 | (src << 3) | dst); code.append(0xc0 | (src << 3) | dst);
} }
void and_(int v, Register dst) { void and_(int32_t v, Register dst) {
assert(code.s, (v & 0xFFFFFF00) == 0); // todo assert(code.s, isByte(v)); // todo
rex(); rex();
code.append(0x83); code.append(0x83);

View File

@ -129,7 +129,7 @@ inline bool
methodVirtual(Thread* t, object method) methodVirtual(Thread* t, object method)
{ {
return (methodFlags(t, method) & (ACC_STATIC | ACC_FINAL | ACC_PRIVATE)) return (methodFlags(t, method) & (ACC_STATIC | ACC_FINAL | ACC_PRIVATE))
!= 0; == 0;
} }
} // namespace vm } // namespace vm