Bug 858940 - Fix an additional case where we inspect the instruction stream without going through an iterator. r=jbramley, a=lsblakk
authorMarty Rosenberg <mrosenberg@mozilla.com>
Mon, 15 Jul 2013 14:21:46 -0400
changeset 143162 cd1947651841b580e993ee065432404c2d6c0212
parent 143161 fd3ee1bc6ca2e326f8c914fc4820789d9ea68c17
child 143163 1db960f50d2ea99a701b85310507cff6ca86f338
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersjbramley, lsblakk
bugs858940
milestone23.0
Bug 858940 - Fix an additional case where we inspect the instruction stream without going through an iterator. r=jbramley, a=lsblakk
js/src/ion/arm/MacroAssembler-arm.cpp
--- a/js/src/ion/arm/MacroAssembler-arm.cpp
+++ b/js/src/ion/arm/MacroAssembler-arm.cpp
@@ -332,16 +332,24 @@ NextInst(Instruction *i)
     return i->next();
 }
 
 void
 MacroAssemblerARM::ma_movPatchable(Imm32 imm_, Register dest,
                                    Assembler::Condition c, RelocStyle rs, Instruction *i)
 {
     int32_t imm = imm_.value;
+    if (i) {
+        // Make sure the current instruction is not an artificial guard
+        // inserted by the assembler buffer.
+        // The InstructionIterator already does this and handles edge cases,
+        // so, just asking an iterator for its current instruction should be
+        // enough to make sure we don't accidentally inspect an artificial guard.
+        i = InstructionIterator(i).cur();
+    }
     switch(rs) {
       case L_MOVWT:
         as_movw(dest, Imm16(imm & 0xffff), c, i);
         // i can be NULL here.  that just means "insert in the next in sequence."
         // NextInst is special cased to not do anything when it is passed NULL, so two
         // consecutive instructions will be inserted.
         i = NextInst(i);
         as_movt(dest, Imm16(imm >> 16 & 0xffff), c, i);