Bug 1438827 - Fix tracing of ARM macro assembler r=nbp
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 23 Feb 2018 17:41:28 +0000
changeset 759124 f9ec9a7399faf4dd1e18bb43ba04d456a2ed23d0
parent 759098 f701ae6821301b585d5759e006eed13d877d5f10
child 759126 10b3853d4c069bd8908b056af9949e487f5b5ddb
push id100272
push userrwood@mozilla.com
push dateFri, 23 Feb 2018 18:27:33 +0000
reviewersnbp
bugs1438827
milestone60.0a1
Bug 1438827 - Fix tracing of ARM macro assembler r=nbp
js/src/jit/arm/Assembler-arm.cpp
js/src/jit/arm/Assembler-arm.h
js/src/jit/arm/MacroAssembler-arm.cpp
js/src/jit/arm/MacroAssembler-arm.h
--- a/js/src/jit/arm/Assembler-arm.cpp
+++ b/js/src/jit/arm/Assembler-arm.cpp
@@ -3076,16 +3076,17 @@ BufferInstructionIterator::maybeSkipAuto
 {
     const PoolHeader* ph;
     // If this is a guard, and the next instruction is a header, always work
     // around the pool. If it isn't a guard, then start looking ahead.
     if (InstIsGuard(*this, &ph)) {
         // Don't skip a natural guard.
         if (ph->isNatural())
             return cur();
+        advance(sizeof(Instruction) * ph->size());
         return next();
     }
     if (InstIsBNop<BufferInstructionIterator>(*this))
         return next();
     return cur();
 }
 
 // Cases to be handled:
--- a/js/src/jit/arm/Assembler-arm.h
+++ b/js/src/jit/arm/Assembler-arm.h
@@ -1348,24 +1348,21 @@ class Assembler : public AssemblerShared
     static DoubleCondition InvertCondition(DoubleCondition cond);
 
     // MacroAssemblers hold onto gcthings, so they are traced by the GC.
     void trace(JSTracer* trc);
     void writeRelocation(BufferOffset src) {
         jumpRelocations_.writeUnsigned(src.getOffset());
     }
 
-    // As opposed to x86/x64 version, the data relocation has to be executed
-    // before to recover the pointer, and not after.
-    void writeDataRelocation(ImmGCPtr ptr) {
+    void writeDataRelocation(BufferOffset offset, ImmGCPtr ptr) {
         if (ptr.value) {
             if (gc::IsInsideNursery(ptr.value))
                 embedsNurseryPointers_ = true;
-            if (ptr.value)
-                dataRelocations_.writeUnsigned(nextOffset().getOffset());
+            dataRelocations_.writeUnsigned(offset.getOffset());
         }
     }
 
     enum RelocBranchStyle {
         B_MOVWT,
         B_LDR_BX,
         B_LDR,
         B_MOVW_ADD
--- a/js/src/jit/arm/MacroAssembler-arm.cpp
+++ b/js/src/jit/arm/MacroAssembler-arm.cpp
@@ -302,32 +302,33 @@ MacroAssemblerARM::ma_alu(Register src1,
 }
 
 void
 MacroAssemblerARM::ma_nop()
 {
     as_nop();
 }
 
-void
+BufferOffset
 MacroAssemblerARM::ma_movPatchable(Imm32 imm_, Register dest, Assembler::Condition c)
 {
     int32_t imm = imm_.value;
     if (HasMOVWT()) {
-        as_movw(dest, Imm16(imm & 0xffff), c);
+        BufferOffset offset = as_movw(dest, Imm16(imm & 0xffff), c);
         as_movt(dest, Imm16(imm >> 16 & 0xffff), c);
+        return offset;
     } else {
-        as_Imm32Pool(dest, imm, c);
+        return as_Imm32Pool(dest, imm, c);
     }
 }
 
-void
+BufferOffset
 MacroAssemblerARM::ma_movPatchable(ImmPtr imm, Register dest, Assembler::Condition c)
 {
-    ma_movPatchable(Imm32(int32_t(imm.value)), dest, c);
+    return ma_movPatchable(Imm32(int32_t(imm.value)), dest, c);
 }
 
 /* static */
 template<class Iter>
 void
 MacroAssemblerARM::ma_mov_patch(Imm32 imm32, Register dest, Assembler::Condition c,
                                 RelocStyle rs, Iter iter)
 {
@@ -398,20 +399,18 @@ void
 MacroAssemblerARM::ma_mov(ImmWord imm, Register dest, Assembler::Condition c)
 {
     ma_mov(Imm32(imm.value), dest, c);
 }
 
 void
 MacroAssemblerARM::ma_mov(ImmGCPtr ptr, Register dest)
 {
-    // As opposed to x86/x64 version, the data relocation has to be executed
-    // before to recover the pointer, and not after.
-    writeDataRelocation(ptr);
-    ma_movPatchable(Imm32(uintptr_t(ptr.value)), dest, Always);
+    BufferOffset offset = ma_movPatchable(Imm32(uintptr_t(ptr.value)), dest, Always);
+    writeDataRelocation(offset, ptr);
 }
 
 // Shifts (just a move with a shifting op2)
 void
 MacroAssemblerARM::ma_lsl(Imm32 shift, Register src, Register dst)
 {
     as_mov(dst, lsl(src, shift.value));
 }
--- a/js/src/jit/arm/MacroAssembler-arm.h
+++ b/js/src/jit/arm/MacroAssembler-arm.h
@@ -114,18 +114,18 @@ class MacroAssemblerARM : public Assembl
     void ma_alu(Register src1, Imm32 imm, Register dest, AutoRegisterScope& scratch,
                 ALUOp op, SBit s = LeaveCC, Condition c = Always);
     void ma_alu(Register src1, Operand2 op2, Register dest, ALUOp op,
                 SBit s = LeaveCC, Condition c = Always);
     void ma_alu(Register src1, Operand op2, Register dest, ALUOp op,
                 SBit s = LeaveCC, Condition c = Always);
     void ma_nop();
 
-    void ma_movPatchable(Imm32 imm, Register dest, Assembler::Condition c);
-    void ma_movPatchable(ImmPtr imm, Register dest, Assembler::Condition c);
+    BufferOffset ma_movPatchable(Imm32 imm, Register dest, Assembler::Condition c);
+    BufferOffset ma_movPatchable(ImmPtr imm, Register dest, Assembler::Condition c);
 
     // To be used with Iter := InstructionIterator or BufferInstructionIterator.
     template<class Iter>
     static void ma_mov_patch(Imm32 imm, Register dest, Assembler::Condition c,
                              RelocStyle rs, Iter iter);
 
     // ALU based ops
     // mov