From 22c639fb8d8fcbbcdf95d29b1c6a3baa3c226937 Mon Sep 17 00:00:00 2001 From: Jacob Bramley Date: Tue, 23 Nov 2010 14:00:05 -0800 Subject: [PATCH] ARM assembler tweaks. (b=588021, r=cdleary) --- js/src/assembler/assembler/ARMAssembler.cpp | 5 +++++ js/src/assembler/assembler/ARMAssembler.h | 19 +++++++++++-------- .../assembler/assembler/MacroAssemblerARM.h | 14 +++++++++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/js/src/assembler/assembler/ARMAssembler.cpp b/js/src/assembler/assembler/ARMAssembler.cpp index 85fbaf16b44..ba7cec282bb 100644 --- a/js/src/assembler/assembler/ARMAssembler.cpp +++ b/js/src/assembler/assembler/ARMAssembler.cpp @@ -201,6 +201,11 @@ int ARMAssembler::genInt(int reg, ARMWord imm, bool positive) return 1; } +#ifdef __GNUC__ +// If the result of this function isn't used, the caller should probably be +// using movImm. +__attribute__((warn_unused_result)) +#endif ARMWord ARMAssembler::getImm(ARMWord imm, int tmpReg, bool invert) { ARMWord tmp; diff --git a/js/src/assembler/assembler/ARMAssembler.h b/js/src/assembler/assembler/ARMAssembler.h index 16b7d58f559..0f8d943cee7 100644 --- a/js/src/assembler/assembler/ARMAssembler.h +++ b/js/src/assembler/assembler/ARMAssembler.h @@ -929,7 +929,9 @@ namespace JSC { JmpDst label() { - return JmpDst(m_buffer.size()); + JmpDst label(m_buffer.size()); + js::JaegerSpew(js::JSpew_Insns, IPFX "#label ((%d))\n", MAYBE_PAD, label.m_offset); + return label; } JmpDst align(int alignment) @@ -1050,10 +1052,11 @@ namespace JSC { // Like repatchLoadPtrToLEA, this is specialized for our purpose. ARMWord* insn = reinterpret_cast(from); if ((*insn & 0x0ff00f00) == 0x05900000) - return; - ASSERT((*insn & 0xf00ff0ff) == 0x02800000); + return; // Valid ldr instruction + ASSERT((*insn & 0x0ff00000) == 0x02800000); // Valid add instruction + ASSERT((*insn & 0x00000f00) == 0x00000000); // Simple-to-handle immediates (no rotate) - *insn = (*insn & 0x0ff00f00) | 0x05900000; + *insn = (*insn & 0xf00ff0ff) | 0x05900000; ExecutableAllocator::cacheFlush(insn, sizeof(ARMWord)); } @@ -1087,7 +1090,7 @@ namespace JSC { ISPFX "##relinkJump ((%p)) jumps to ((%p))\n", from, to); - patchPointerInternal(reinterpret_cast(from) - sizeof(ARMWord), to); + patchPointerInternal(reinterpret_cast(from), to); } static bool canRelinkJump(void* from, void* to) @@ -1110,14 +1113,14 @@ namespace JSC { ISPFX "##relinkCall ((%p)) jumps to ((%p))\n", from, to); - patchPointerInternal(reinterpret_cast(from) - sizeof(ARMWord), to); + patchPointerInternal(reinterpret_cast(from), to); } // Address operations static void* getRelocatedAddress(void* code, JmpSrc jump) { - return reinterpret_cast(reinterpret_cast(code) + jump.m_offset / sizeof(ARMWord) + 1); + return reinterpret_cast(reinterpret_cast(code) + jump.m_offset / sizeof(ARMWord)); } static void* getRelocatedAddress(void* code, JmpDst label) @@ -1129,7 +1132,7 @@ namespace JSC { static int getDifferenceBetweenLabels(JmpDst from, JmpSrc to) { - return (to.m_offset + sizeof(ARMWord)) - from.m_offset; + return to.m_offset - from.m_offset; } static int getDifferenceBetweenLabels(JmpDst from, JmpDst to) diff --git a/js/src/assembler/assembler/MacroAssemblerARM.h b/js/src/assembler/assembler/MacroAssemblerARM.h index 15aca15c81b..742b85c1135 100644 --- a/js/src/assembler/assembler/MacroAssemblerARM.h +++ b/js/src/assembler/assembler/MacroAssemblerARM.h @@ -277,6 +277,7 @@ public: DataLabel32 load32WithAddressOffsetPatch(Address address, RegisterID dest) { + ASSERT(address.base != ARMRegisters::S0); DataLabel32 dataLabel(this); m_assembler.ldr_un_imm(ARMRegisters::S0, 0); m_assembler.dtr_ur(true, dest, address.base, ARMRegisters::S0); @@ -285,6 +286,8 @@ public: DataLabel32 load64WithAddressOffsetPatch(Address address, RegisterID hi, RegisterID lo) { + ASSERT(address.base != ARMRegisters::S0); + ASSERT(lo != ARMRegisters::S0); DataLabel32 dataLabel(this); m_assembler.ldr_un_imm(ARMRegisters::S0, 0); m_assembler.add_r(ARMRegisters::S0, ARMRegisters::S0, address.base); @@ -316,6 +319,7 @@ public: DataLabel32 store32WithAddressOffsetPatch(RegisterID src, Address address) { + ASSERT(address.base != ARMRegisters::S0); DataLabel32 dataLabel(this); m_assembler.ldr_un_imm(ARMRegisters::S0, 0); m_assembler.dtr_ur(false, src, address.base, ARMRegisters::S0); @@ -324,6 +328,9 @@ public: DataLabel32 store64WithAddressOffsetPatch(RegisterID hi, RegisterID lo, Address address) { + ASSERT(hi != ARMRegisters::S0); + ASSERT(lo != ARMRegisters::S0); + ASSERT(address.base != ARMRegisters::S0); DataLabel32 dataLabel(this); m_assembler.ldr_un_imm(ARMRegisters::S0, 0); m_assembler.add_r(ARMRegisters::S0, ARMRegisters::S0, address.base); @@ -334,9 +341,14 @@ public: DataLabel32 store64WithAddressOffsetPatch(Imm32 hi, RegisterID lo, Address address) { + ASSERT(lo != ARMRegisters::S0); + ASSERT(lo != ARMRegisters::S1); + ASSERT(lo != address.base); + ASSERT(address.base != ARMRegisters::S0); + ASSERT(address.base != ARMRegisters::S1); DataLabel32 dataLabel(this); m_assembler.ldr_un_imm(ARMRegisters::S0, 0); - m_assembler.getImm(hi.m_value, ARMRegisters::S1); + m_assembler.moveImm(hi.m_value, ARMRegisters::S1); m_assembler.add_r(ARMRegisters::S0, ARMRegisters::S0, address.base); m_assembler.dtr_u(false, lo, ARMRegisters::S0, 0); m_assembler.dtr_u(false, ARMRegisters::S1, ARMRegisters::S0, 4);