fix x86->powerpc boot image cross build

This fixes the remaining cross-endian translation issues needed to
build powerpc boot images on x86.
This commit is contained in:
Joel Dice 2011-09-23 22:21:54 -06:00
parent e6c780e4e8
commit 3fa4a7001d
7 changed files with 35 additions and 18 deletions

View File

@ -1783,6 +1783,10 @@ class MyArchitecture: public Assembler::Architecture {
return 0;
}
virtual int scratch() {
return 5;
}
virtual int stack() {
return StackRegister;
}

View File

@ -329,6 +329,7 @@ class Assembler {
virtual uint32_t generalRegisterMask() = 0;
virtual uint32_t floatRegisterMask() = 0;
virtual int scratch() = 0;
virtual int stack() = 0;
virtual int thread() = 0;
virtual int returnLow() = 0;

View File

@ -672,7 +672,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
expect(t, value >= code);
addresses->listener->resolve
(targetVW(static_cast<target_intptr_t>(value - code)), 0);
(static_cast<target_intptr_t>(value - code), 0);
}
for (; methods; methods = pairSecond(t, methods)) {
@ -987,7 +987,7 @@ copy(Thread* t, object typeMaps, object p, uint8_t* dst)
if (field->type == Type_object) {
unsigned offset = field->targetOffset / TargetBytesPerWord;
reinterpret_cast<uint32_t*>(mask)[offset / 32]
|= static_cast<uint32_t>(1) << (offset % 32);
|= targetV4(static_cast<uint32_t>(1) << (offset % 32));
}
}
@ -1027,14 +1027,15 @@ copy(Thread* t, object typeMaps, object p, uint8_t* dst)
switch (field->type) {
case Type_object:
reinterpret_cast<uint32_t*>(objectMask)[i / 32]
|= static_cast<uint32_t>(1) << (i % 32);
|= targetV4(static_cast<uint32_t>(1) << (i % 32));
break;
case Type_float:
case Type_double:
reinterpret_cast<target_uintptr_t*>(poolMask)
[i / TargetBitsPerWord]
|= static_cast<target_uintptr_t>(1) << (i % TargetBitsPerWord);
|= targetVW
(static_cast<target_uintptr_t>(1) << (i % TargetBitsPerWord));
break;
default:
@ -1083,7 +1084,7 @@ copy(Thread* t, object typeMaps, object referer, unsigned refererOffset,
if (field->type == Type_object) {
unsigned offset = field->targetOffset / TargetBytesPerWord;
reinterpret_cast<uint32_t*>(dst + (TargetBytesPerWord * 2))
[offset / 32] |= static_cast<uint32_t>(1) << (offset % 32);
[offset / 32] |= targetV4(static_cast<uint32_t>(1) << (offset % 32));
}
}
@ -1092,7 +1093,7 @@ copy(Thread* t, object typeMaps, object referer, unsigned refererOffset,
{
unsigned offset = map->targetFixedSizeInWords;
reinterpret_cast<uint32_t*>(dst + (TargetBytesPerWord * 2))
[offset / 32] |= static_cast<uint32_t>(1) << (offset % 32);
[offset / 32] |= targetV4(static_cast<uint32_t>(1) << (offset % 32));
}
} else {
copy(t, typeMaps, p, dst);

View File

@ -8347,8 +8347,14 @@ class MyProcessor: public Processor {
#define THUNK(s) thunkTable[s##Index] = voidPointer(s);
#include "thunks.cpp"
#undef THUNK
// Set the dummyIndex entry to a constant which should require the
// maximum number of bytes to represent in assembly code
// (i.e. can't be represented by a smaller number of bytes and
// implicitly sign- or zero-extended). We'll use this property
// later to determine the maximum size of a thunk in the thunk
// table.
thunkTable[dummyIndex] = reinterpret_cast<void*>
(~static_cast<uintptr_t>(0));
(static_cast<uintptr_t>(UINT64_C(0x5555555555555555)));
}
virtual Thread*
@ -9396,10 +9402,7 @@ compileCall(MyThread* t, Context* c, ThunkIndex index, bool call = true)
if (processor(t)->bootImage) {
Assembler::Memory table(t->arch->thread(), TargetThreadThunkTable);
// use Architecture::virtualCallTarget register here as a scratch
// register; any register that isn't used to pass arguments would
// be acceptable:
Assembler::Register scratch(t->arch->virtualCallTarget());
Assembler::Register scratch(t->arch->scratch());
a->apply(Move, TargetBytesPerWord, MemoryOperand, &table,
TargetBytesPerWord, RegisterOperand, &scratch);
Assembler::Memory proc(scratch.low, index * TargetBytesPerWord);

View File

@ -6953,14 +6953,14 @@ class MyCompiler: public Compiler {
(c.machineCode + pad(c.machineCodeSize, TargetBytesPerWord) + i);
if (n->promise->resolved()) {
*target = n->promise->value();
*target = targetVW(n->promise->value());
} else {
class Listener: public Promise::Listener {
public:
Listener(target_intptr_t* target): target(target){ }
virtual bool resolve(int64_t value, void** location) {
*target = value;
*target = targetVW(value);
if (location) *location = target;
return true;
}

View File

@ -789,14 +789,14 @@ updateImmediate(System* s, void* dst, int32_t src, unsigned size, bool address)
switch (size) {
case 4: {
int32_t* p = static_cast<int32_t*>(dst);
int r = (p[1] >> 21) & 31;
int r = (targetV4(p[1]) >> 21) & 31;
if (address) {
p[0] = lis(r, ha16(src));
p[1] |= (src & 0xFFFF);
p[0] = targetV4(lis(r, ha16(src)));
p[1] |= targetV4(src & 0xFFFF);
} else {
p[0] = lis(r, src >> 16);
p[1] = ori(r, r, src);
p[0] = targetV4(lis(r, src >> 16));
p[1] = targetV4(ori(r, r, src));
}
} break;
@ -2076,6 +2076,10 @@ class MyArchitecture: public Assembler::Architecture {
return 0;
}
virtual int scratch() {
return 31;
}
virtual int stack() {
return StackRegister;
}

View File

@ -2763,6 +2763,10 @@ class MyArchitecture: public Assembler::Architecture {
return useSSE(&c) ? FloatRegisterMask : 0;
}
virtual int scratch() {
return rax;
}
virtual int stack() {
return rsp;
}