diff --git a/js/src/jit/arm/Assembler-arm.cpp b/js/src/jit/arm/Assembler-arm.cpp index 74c0d59bc05..da15f9552cc 100644 --- a/js/src/jit/arm/Assembler-arm.cpp +++ b/js/src/jit/arm/Assembler-arm.cpp @@ -1427,7 +1427,7 @@ Assembler::bytesNeeded() const void Assembler::spew(Instruction* i) { - if (spewDisabled()) + if (spewDisabled() || !i) return; disasm::NameConverter converter; disasm::Disassembler dasm(converter); @@ -1453,7 +1453,7 @@ Assembler::spewTarget(Label* target) void Assembler::spewBranch(Instruction* i, Label* target /* may be nullptr */) { - if (spewDisabled()) + if (spewDisabled() || !i) return; disasm::NameConverter converter; disasm::Disassembler dasm(converter); @@ -1515,7 +1515,10 @@ Assembler::spewData(BufferOffset addr, size_t numInstr, bool loadToPC) { if (spewDisabled()) return; - uint32_t *instr = reinterpret_cast(m_buffer.getInst(addr)); + Instruction* inst = m_buffer.getInstOrNull(addr); + if (!inst) + return; + uint32_t *instr = reinterpret_cast(inst); for ( size_t k=0 ; k < numInstr ; k++ ) { spew(" %08x %08x (patchable constant load%s)", reinterpret_cast(instr+k), *(instr+k), loadToPC ? " to PC" : ""); @@ -1636,7 +1639,7 @@ Assembler::writeInst(uint32_t x) { BufferOffset offs = m_buffer.putInt(x); #ifdef JS_DISASM_ARM - spew(m_buffer.getInst(offs)); + spew(m_buffer.getInstOrNull(offs)); #endif return offs; } @@ -1646,7 +1649,7 @@ Assembler::writeBranchInst(uint32_t x, Label* documentation) { BufferOffset offs = m_buffer.putInt(x, /* markAsBranch = */ true); #ifdef JS_DISASM_ARM - spewBranch(m_buffer.getInst(offs), documentation); + spewBranch(m_buffer.getInstOrNull(offs), documentation); #endif return offs; } @@ -2375,7 +2378,7 @@ Assembler::as_b(Label* l, Condition c) BufferOffset ret = allocBranchInst(); as_b(BufferOffset(l).diffB(ret), c, ret); #ifdef JS_DISASM_ARM - spewBranch(m_buffer.getInst(ret), l); + spewBranch(m_buffer.getInstOrNull(ret), l); #endif return ret; } @@ -2442,7 +2445,7 @@ Assembler::as_bl(Label* l, Condition c) BufferOffset ret = allocBranchInst(); as_bl(BufferOffset(l).diffB(ret), c, ret); #ifdef JS_DISASM_ARM - spewBranch(m_buffer.getInst(ret), l); + spewBranch(m_buffer.getInstOrNull(ret), l); #endif return ret; } diff --git a/js/src/jit/shared/IonAssemblerBuffer.h b/js/src/jit/shared/IonAssemblerBuffer.h index bb852ffe656..be1251e45e2 100644 --- a/js/src/jit/shared/IonAssemblerBuffer.h +++ b/js/src/jit/shared/IonAssemblerBuffer.h @@ -279,6 +279,12 @@ class AssemblerBuffer } public: + Inst* getInstOrNull(BufferOffset off) { + if (!off.assigned()) + return nullptr; + return getInst(off); + } + Inst* getInst(BufferOffset off) { const int offset = off.getOffset();