From e3f50e6d67e5e4010384ab6b63fad530e6c368a8 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 29 Dec 2014 11:04:27 -0700 Subject: [PATCH] fix ARM64 OffsetPromise::value I must have done a search-and-replace from 4 to TargetBytesPerWord earlier, but in this case it should have been the instruction size (4), not the word size. --- src/codegen/target/arm/assembler.cpp | 2 ++ src/codegen/target/arm/fixup.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/codegen/target/arm/assembler.cpp b/src/codegen/target/arm/assembler.cpp index 1ff070bcea..d34f9992f1 100644 --- a/src/codegen/target/arm/assembler.cpp +++ b/src/codegen/target/arm/assembler.cpp @@ -981,6 +981,8 @@ class MyAssembler : public Assembler { bool jump = needJump(b); if (jump) { + expect(&con, TargetBytesPerWord == 4); + write4(dst + dstOffset, isa::b((poolSize + TargetBytesPerWord - 8) >> 2)); } diff --git a/src/codegen/target/arm/fixup.cpp b/src/codegen/target/arm/fixup.cpp index 7f5c0ff277..2e32813cbb 100644 --- a/src/codegen/target/arm/fixup.cpp +++ b/src/codegen/target/arm/fixup.cpp @@ -12,6 +12,12 @@ #include "fixup.h" #include "block.h" +namespace { + +const unsigned InstructionSize = 4; + +} // namespace + namespace avian { namespace codegen { namespace arm { @@ -39,7 +45,7 @@ int64_t OffsetPromise::value() unsigned o = offset - block->offset; return block->start - + padding(block, forTrace ? o - vm::TargetBytesPerWord : o) + o; + + padding(block, forTrace ? o - InstructionSize : o) + o; } Promise* offsetPromise(Context* con, bool forTrace) @@ -115,7 +121,7 @@ void* updateOffset(vm::System* s, uint8_t* instruction, int64_t value) *p = (v & mask) | ((~mask) & *p); - return instruction + 4; + return instruction + InstructionSize; } ConstantPoolEntry::ConstantPoolEntry(Context* con,