diff --git a/makefile b/makefile index 7ce70e22e2..676ecfdf6e 100644 --- a/makefile +++ b/makefile @@ -449,7 +449,7 @@ $(bootimage-bin): $(bootimage-generator) $(bootimage-object): $(bootimage-bin) $(binaryToMacho) @echo "creating $(@)" ifeq ($(platform),darwin) - $(binaryToMacho) $(<) __BOOT __boot \ + $(binaryToMacho) $(asm) $(<) __BOOT __boot \ __binary_bootimage_bin_start __binary_bootimage_bin_end > $(@) else (wd=$$(pwd); \ diff --git a/src/assembler.h b/src/assembler.h index 6aa6242072..8fda163ca3 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -277,6 +277,9 @@ class Assembler { virtual void updateCall(UnaryOperation op, bool assertAlignment, void* returnAddress, void* newTarget) = 0; + virtual uintptr_t getConstant(const void* src) = 0; + virtual void setConstant(void* dst, uintptr_t constant) = 0; + virtual unsigned alignFrameSize(unsigned sizeInWords) = 0; virtual void* frameIp(void* stack) = 0; diff --git a/src/compile.cpp b/src/compile.cpp index bd1b3367b5..df17107cbd 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -27,7 +27,7 @@ vmCall(); namespace { -const bool DebugCompile = true; +const bool DebugCompile = false; const bool DebugNatives = false; const bool DebugCallTable = false; const bool DebugMethodTree = false; @@ -5627,28 +5627,33 @@ fixupHeap(MyThread* t UNUSED, uintptr_t* map, unsigned size, uintptr_t* heap) } void -fixupCode(Thread*, uintptr_t* map, unsigned size, uint8_t* code, +fixupCode(Thread* t, uintptr_t* map, unsigned size, uint8_t* code, uintptr_t* heap) { + Assembler::Architecture* arch = makeArchitecture(t->m->system); + arch->acquire(); + for (unsigned word = 0; word < size; ++word) { uintptr_t w = map[word]; if (w) { for (unsigned bit = 0; bit < BitsPerWord; ++bit) { if (w & (static_cast(1) << bit)) { unsigned index = indexOf(word, bit); - uintptr_t v; memcpy(&v, code + index, BytesPerWord); + uintptr_t v = arch->getConstant(code + index); uintptr_t mark = v >> BootShift; if (mark) { - v = reinterpret_cast(code + (v & BootMask)); - memcpy(code + index, &v, BytesPerWord); + arch->setConstant(code + index, reinterpret_cast + (code + (v & BootMask))); } else { - v = reinterpret_cast(heap + v - 1); - memcpy(code + index, &v, BytesPerWord); + arch->setConstant(code + index, reinterpret_cast + (heap + v - 1)); } } } } } + + arch->release(); } void diff --git a/src/powerpc.cpp b/src/powerpc.cpp index 9ad08e11b1..99e06601cb 100644 --- a/src/powerpc.cpp +++ b/src/powerpc.cpp @@ -1690,10 +1690,25 @@ class MyArchitecture: public Assembler::Architecture { reinterpret_cast(newTarget)); } break; + case LongCall: + case LongJump: { + updateImmediate(c.s, static_cast(returnAddress) - 12, + reinterpret_cast(newTarget), BytesPerWord); + } break; + default: abort(&c); } } + virtual uintptr_t getConstant(const void* src) { + const int32_t* p = static_cast(src); + return (p[0] << 16) | (p[1] & 0xFFFF); + } + + virtual void setConstant(void* dst, uintptr_t constant) { + updateImmediate(c.s, dst, constant, BytesPerWord); + } + virtual unsigned alignFrameSize(unsigned sizeInWords) { const unsigned alignment = 16 / BytesPerWord; return (ceiling(sizeInWords + FrameFooterSize, alignment) * alignment); diff --git a/src/x86.cpp b/src/x86.cpp index c63ba57365..a5c01de2e3 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -2085,6 +2085,16 @@ class MyArchitecture: public Assembler::Architecture { } } + virtual uintptr_t getConstant(const void* src) { + uintptr_t v; + memcpy(&v, src, BytesPerWord); + return v; + } + + virtual void setConstant(void* dst, uintptr_t constant) { + memcpy(dst, &constant, BytesPerWord); + } + virtual unsigned alignFrameSize(unsigned sizeInWords) { const unsigned alignment = 16 / BytesPerWord; return (ceiling(sizeInWords + FrameHeaderSize, alignment) * alignment)