diff --git a/src/arm.cpp b/src/arm.cpp index 16241d180c..2c7549238c 100644 --- a/src/arm.cpp +++ b/src/arm.cpp @@ -1783,6 +1783,10 @@ class MyArchitecture: public Assembler::Architecture { return 0; } + virtual int scratch() { + return 5; + } + virtual int stack() { return StackRegister; } diff --git a/src/assembler.h b/src/assembler.h index 04c0693a36..1566df6cd7 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -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; diff --git a/src/bootimage.cpp b/src/bootimage.cpp index efbd240ef0..bb9f75926d 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -672,7 +672,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, expect(t, value >= code); addresses->listener->resolve - (targetVW(static_cast(value - code)), 0); + (static_cast(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(mask)[offset / 32] - |= static_cast(1) << (offset % 32); + |= targetV4(static_cast(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(objectMask)[i / 32] - |= static_cast(1) << (i % 32); + |= targetV4(static_cast(1) << (i % 32)); break; case Type_float: case Type_double: reinterpret_cast(poolMask) [i / TargetBitsPerWord] - |= static_cast(1) << (i % TargetBitsPerWord); + |= targetVW + (static_cast(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(dst + (TargetBytesPerWord * 2)) - [offset / 32] |= static_cast(1) << (offset % 32); + [offset / 32] |= targetV4(static_cast(1) << (offset % 32)); } } @@ -1092,7 +1093,7 @@ copy(Thread* t, object typeMaps, object referer, unsigned refererOffset, { unsigned offset = map->targetFixedSizeInWords; reinterpret_cast(dst + (TargetBytesPerWord * 2)) - [offset / 32] |= static_cast(1) << (offset % 32); + [offset / 32] |= targetV4(static_cast(1) << (offset % 32)); } } else { copy(t, typeMaps, p, dst); diff --git a/src/compile.cpp b/src/compile.cpp index 95fef9ee4c..c6f33a0806 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -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 - (~static_cast(0)); + (static_cast(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); diff --git a/src/compiler.cpp b/src/compiler.cpp index 5221485cac..737f723da4 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -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; } diff --git a/src/powerpc.cpp b/src/powerpc.cpp index 50359e8e78..59e0c77146 100644 --- a/src/powerpc.cpp +++ b/src/powerpc.cpp @@ -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(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; } diff --git a/src/x86.cpp b/src/x86.cpp index 2101d04911..28c6dc2bc7 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -2763,6 +2763,10 @@ class MyArchitecture: public Assembler::Architecture { return useSSE(&c) ? FloatRegisterMask : 0; } + virtual int scratch() { + return rax; + } + virtual int stack() { return rsp; }