Bug 858083: fix a silly bug where we use armv7 instructions when in armv6-mode (and think we are on armv6 when we are not). (r=jbramley)
authorMarty Rosenberg <mrosenberg@mozilla.com>
Fri, 05 Apr 2013 10:32:12 -0400
changeset 127841 6f83b4eedf820113c03a7941cae43aee4efe6bf1
parent 127840 c13cc671185857f59cf9a3eb172292be4f2dbebe
child 127842 45835d0c9d58d23af167821879fafd2570764e5a
push id24512
push userryanvm@gmail.com
push dateFri, 05 Apr 2013 20:13:49 +0000
treeherdermozilla-central@139b6ba547fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjbramley
bugs858083
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 858083: fix a silly bug where we use armv7 instructions when in armv6-mode (and think we are on armv6 when we are not). (r=jbramley)
js/src/ion/arm/Architecture-arm.cpp
js/src/ion/arm/Assembler-arm.cpp
js/src/ion/arm/MacroAssembler-arm.cpp
js/src/ion/arm/MacroAssembler-arm.h
js/src/ion/shared/BaselineCompiler-shared.h
--- a/js/src/ion/arm/Architecture-arm.cpp
+++ b/js/src/ion/arm/Architecture-arm.cpp
@@ -43,17 +43,17 @@ uint32_t getFlags()
     int fd = open("/proc/self/auxv", O_RDONLY);
     if (fd > 0) {
         Elf32_auxv_t aux;
         while (read(fd, &aux, sizeof(Elf32_auxv_t))) {
             if (aux.a_type == AT_HWCAP) {
                 close(fd);
                 flags = aux.a_un.a_val;
                 isSet = true;
-#ifdef __ARM_ARCH_7__
+#if defined(__ARM_ARCH_7__) || defined (__ARM_ARCH_7A__)
                 // this should really be detected at runtime, but
                 // /proc/*/auxv doesn't seem to carry the ISA
                 // I could look in /proc/cpuinfo as well, but
                 // the chances that it will be different from this
                 // are low.
                 flags |= HWCAP_ARMv7;
 #endif
                 return flags;
--- a/js/src/ion/arm/Assembler-arm.cpp
+++ b/js/src/ion/arm/Assembler-arm.cpp
@@ -2527,20 +2527,25 @@ Assembler::ToggleToCmp(CodeLocationLabel
 
     AutoFlushCache::updateTop((uintptr_t)ptr, 4);
 }
 
 void
 Assembler::ToggleCall(CodeLocationLabel inst_, bool enabled)
 {
     Instruction *inst = (Instruction *)inst_.raw();
-    JS_ASSERT(inst->is<InstMovW>());
+    JS_ASSERT(inst->is<InstMovW>() || inst->is<InstLDR>());
 
-    inst = inst->next();
-    JS_ASSERT(inst->is<InstMovT>());
+    if (inst->is<InstMovW>()) {
+        // If it looks like the start of a movw/movt sequence,
+        // then make sure we have all of it (and advance the iterator
+        // past the full sequence)
+        inst = inst->next();
+        JS_ASSERT(inst->is<InstMovT>());
+    }
 
     inst = inst->next();
     JS_ASSERT(inst->is<InstNOP>() || inst->is<InstBLXReg>());
 
     if (enabled == inst->is<InstBLXReg>()) {
         // Nothing to do.
         return;
     }
--- a/js/src/ion/arm/MacroAssembler-arm.cpp
+++ b/js/src/ion/arm/MacroAssembler-arm.cpp
@@ -3258,25 +3258,25 @@ MacroAssemblerARMCompat::toggledJump(Lab
     CodeOffsetLabel ret(nextOffset().getOffset());
     ma_b(label, Always, true);
     return ret;
 }
 
 CodeOffsetLabel
 MacroAssemblerARMCompat::toggledCall(IonCode *target, bool enabled)
 {
-    CodeOffsetLabel offset(size());
-    BufferOffset bo = m_buffer.nextOffset();
+    BufferOffset bo = nextOffset();
+    CodeOffsetLabel offset(bo.getOffset());
     addPendingJump(bo, target->raw(), Relocation::IONCODE);
-    ma_movPatchable(Imm32(uint32_t(target->raw())), ScratchRegister, Always, L_MOVWT);
+    ma_movPatchable(Imm32(uint32_t(target->raw())), ScratchRegister, Always, hasMOVWT() ? L_MOVWT : L_LDR);
     if (enabled)
         ma_blx(ScratchRegister);
     else
         ma_nop();
-    JS_ASSERT(size() - offset.offset() == ToggledCallSize());
+    JS_ASSERT(nextOffset().getOffset() - offset.offset() == ToggledCallSize());
     return offset;
 }
 
 void
 MacroAssemblerARMCompat::round(FloatRegister input, Register output, Label *bail, FloatRegister tmp)
 {
     Label handleZero;
     Label handleNeg;
--- a/js/src/ion/arm/MacroAssembler-arm.h
+++ b/js/src/ion/arm/MacroAssembler-arm.h
@@ -559,30 +559,33 @@ class MacroAssemblerARMCompat : public M
 
     CodeOffsetLabel toggledJump(Label *label);
 
     // Emit a BLX or NOP instruction. ToggleCall can be used to patch
     // this instruction.
     CodeOffsetLabel toggledCall(IonCode *target, bool enabled);
 
     static size_t ToggledCallSize() {
-        // Size of a movw, movt, nop/blx instruction.
-        return 12;
+        if (hasMOVWT())
+            // Size of a movw, movt, nop/blx instruction.
+            return 12;
+        // Size of a ldr, nop/blx instruction
+        return 8;
     }
 
     CodeOffsetLabel pushWithPatch(ImmWord imm) {
         CodeOffsetLabel label = currentOffset();
         ma_movPatchable(Imm32(imm.value), ScratchRegister, Always, hasMOVWT() ? L_MOVWT : L_LDR);
         ma_push(ScratchRegister);
         return label;
     }
 
     CodeOffsetLabel movWithPatch(ImmWord imm, Register dest) {
         CodeOffsetLabel label = currentOffset();
-        ma_movPatchable(Imm32(imm.value), dest, Always, L_MOVWT);
+        ma_movPatchable(Imm32(imm.value), dest, Always, hasMOVWT() ? L_MOVWT : L_LDR);
         return label;
     }
 
     void jump(Label *label) {
         as_b(label);
     }
     void jump(Register reg) {
         ma_bx(reg);
--- a/js/src/ion/shared/BaselineCompiler-shared.h
+++ b/js/src/ion/shared/BaselineCompiler-shared.h
@@ -115,18 +115,16 @@ class BaselineCompilerShared
 
     bool addPCMappingEntry(uint32_t nativeOffset, PCMappingSlotInfo slotInfo, bool addIndexEntry) {
 
         // Don't add multiple entries for a single pc.
         size_t nentries = pcMappingEntries_.length();
         if (nentries > 0 && pcMappingEntries_[nentries - 1].pcOffset == unsigned(pc - script->code))
             return true;
 
-        masm.flushBuffer();
-
         PCMappingEntry entry;
         entry.pcOffset = pc - script->code;
         entry.nativeOffset = nativeOffset;
         entry.slotInfo = slotInfo;
         entry.addIndexEntry = addIndexEntry;
 
         IonSpew(IonSpew_BaselineOp, "PCMapping (%s:%u): %u => %u (%u:%u:%u)!",
                         script->filename(), script->lineno,