mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1393347 - MIPS: Output some more infomation when debug jit code. r=luke
This commit is contained in:
parent
31b4badfcf
commit
5289232843
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@
|
|||||||
#include "mozilla/ArrayUtils.h"
|
#include "mozilla/ArrayUtils.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
|
#include "mozilla/Sprintf.h"
|
||||||
|
|
||||||
#include "jit/CompactBuffer.h"
|
#include "jit/CompactBuffer.h"
|
||||||
#include "jit/IonCode.h"
|
#include "jit/IonCode.h"
|
||||||
@ -762,6 +763,9 @@ class MIPSBufferWithExecutableCopy : public MIPSBuffer
|
|||||||
|
|
||||||
class AssemblerMIPSShared : public AssemblerShared
|
class AssemblerMIPSShared : public AssemblerShared
|
||||||
{
|
{
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
Sprinter* printer;
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Condition {
|
enum Condition {
|
||||||
@ -883,7 +887,10 @@ class AssemblerMIPSShared : public AssemblerShared
|
|||||||
public:
|
public:
|
||||||
AssemblerMIPSShared()
|
AssemblerMIPSShared()
|
||||||
: m_buffer(),
|
: m_buffer(),
|
||||||
isFinished(false)
|
#ifdef JS_JITSPEW
|
||||||
|
printer(nullptr),
|
||||||
|
#endif
|
||||||
|
isFinished(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
static Condition InvertCondition(Condition cond);
|
static Condition InvertCondition(Condition cond);
|
||||||
@ -907,8 +914,42 @@ class AssemblerMIPSShared : public AssemblerShared
|
|||||||
bool oom() const;
|
bool oom() const;
|
||||||
|
|
||||||
void setPrinter(Sprinter* sp) {
|
void setPrinter(Sprinter* sp) {
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
printer = sp;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
inline void spew(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3) {
|
||||||
|
if (MOZ_UNLIKELY(printer || JitSpewEnabled(JitSpew_Codegen))) {
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
spew(fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void decodeBranchInstAndSpew(InstImm branch);
|
||||||
|
#else
|
||||||
|
MOZ_ALWAYS_INLINE void spew(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3) {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
MOZ_COLD void spew(const char* fmt, va_list va) MOZ_FORMAT_PRINTF(2, 0) {
|
||||||
|
// Buffer to hold the formatted string. Note that this may contain
|
||||||
|
// '%' characters, so do not pass it directly to printf functions.
|
||||||
|
char buf[200];
|
||||||
|
|
||||||
|
int i = VsprintfLiteral(buf, fmt, va);
|
||||||
|
if (i > -1) {
|
||||||
|
if (printer)
|
||||||
|
printer->printf("%s\n", buf);
|
||||||
|
js::jit::JitSpew(js::jit::JitSpew_Codegen, "%s", buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static const Register getStackPointer() {
|
static const Register getStackPointer() {
|
||||||
return StackPointer;
|
return StackPointer;
|
||||||
}
|
}
|
||||||
@ -1257,8 +1298,7 @@ class AssemblerMIPSShared : public AssemblerShared
|
|||||||
}
|
}
|
||||||
|
|
||||||
void comment(const char* msg) {
|
void comment(const char* msg) {
|
||||||
// This is not implemented because setPrinter() is not implemented.
|
spew("; %s", msg);
|
||||||
// TODO spew("; %s", msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t NopSize() { return 4; }
|
static uint32_t NopSize() { return 4; }
|
||||||
|
@ -1579,6 +1579,7 @@ MacroAssembler::callWithPatch()
|
|||||||
as_bal(BOffImm16(3 * sizeof(uint32_t)));
|
as_bal(BOffImm16(3 * sizeof(uint32_t)));
|
||||||
addPtr(Imm32(5 * sizeof(uint32_t)), ra);
|
addPtr(Imm32(5 * sizeof(uint32_t)), ra);
|
||||||
// Allocate space which will be patched by patchCall().
|
// Allocate space which will be patched by patchCall().
|
||||||
|
spew(".space 32bit initValue 0xffff ffff");
|
||||||
writeInst(UINT32_MAX);
|
writeInst(UINT32_MAX);
|
||||||
as_lw(ScratchRegister, ra, -(int32_t)(5 * sizeof(uint32_t)));
|
as_lw(ScratchRegister, ra, -(int32_t)(5 * sizeof(uint32_t)));
|
||||||
addPtr(ra, ScratchRegister);
|
addPtr(ra, ScratchRegister);
|
||||||
@ -1611,6 +1612,7 @@ MacroAssembler::farJumpWithPatch()
|
|||||||
as_lw(ScratchRegister, ra, 0);
|
as_lw(ScratchRegister, ra, 0);
|
||||||
// Allocate space which will be patched by patchFarJump().
|
// Allocate space which will be patched by patchFarJump().
|
||||||
CodeOffset farJump(currentOffset());
|
CodeOffset farJump(currentOffset());
|
||||||
|
spew(".space 32bit initValue 0xffff ffff");
|
||||||
writeInst(UINT32_MAX);
|
writeInst(UINT32_MAX);
|
||||||
addPtr(ra, ScratchRegister);
|
addPtr(ra, ScratchRegister);
|
||||||
as_jr(ScratchRegister);
|
as_jr(ScratchRegister);
|
||||||
|
@ -506,6 +506,7 @@ MacroAssemblerMIPS::ma_b(Address addr, ImmGCPtr imm, Label* label, Condition c,
|
|||||||
void
|
void
|
||||||
MacroAssemblerMIPS::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
MacroAssemblerMIPS::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
||||||
{
|
{
|
||||||
|
spew("branch .Llabel %p\n", label);
|
||||||
if (label->bound()) {
|
if (label->bound()) {
|
||||||
// Generate the long jump for calls because return address has to be
|
// Generate the long jump for calls because return address has to be
|
||||||
// the address after the reserved block.
|
// the address after the reserved block.
|
||||||
@ -523,6 +524,7 @@ MacroAssemblerMIPS::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
|||||||
// Make the whole branch continous in the buffer.
|
// Make the whole branch continous in the buffer.
|
||||||
m_buffer.ensureSpace(4 * sizeof(uint32_t));
|
m_buffer.ensureSpace(4 * sizeof(uint32_t));
|
||||||
|
|
||||||
|
spew("bal .Llabel %p\n", label);
|
||||||
BufferOffset bo = writeInst(getBranchCode(BranchIsCall).encode());
|
BufferOffset bo = writeInst(getBranchCode(BranchIsCall).encode());
|
||||||
writeInst(nextInChain);
|
writeInst(nextInChain);
|
||||||
if (!oom())
|
if (!oom())
|
||||||
@ -536,6 +538,7 @@ MacroAssemblerMIPS::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
|||||||
void
|
void
|
||||||
MacroAssemblerMIPS::branchWithCode(InstImm code, Label* label, JumpKind jumpKind)
|
MacroAssemblerMIPS::branchWithCode(InstImm code, Label* label, JumpKind jumpKind)
|
||||||
{
|
{
|
||||||
|
spew("branch .Llabel %p", label);
|
||||||
MOZ_ASSERT(code.encode() != InstImm(op_regimm, zero, rt_bgezal, BOffImm16(0)).encode());
|
MOZ_ASSERT(code.encode() != InstImm(op_regimm, zero, rt_bgezal, BOffImm16(0)).encode());
|
||||||
InstImm inst_beq = InstImm(op_beq, zero, zero, BOffImm16(0));
|
InstImm inst_beq = InstImm(op_beq, zero, zero, BOffImm16(0));
|
||||||
|
|
||||||
@ -548,6 +551,9 @@ MacroAssemblerMIPS::branchWithCode(InstImm code, Label* label, JumpKind jumpKind
|
|||||||
if (jumpKind == ShortJump) {
|
if (jumpKind == ShortJump) {
|
||||||
MOZ_ASSERT(BOffImm16::IsInRange(offset));
|
MOZ_ASSERT(BOffImm16::IsInRange(offset));
|
||||||
code.setBOffImm16(BOffImm16(offset));
|
code.setBOffImm16(BOffImm16(offset));
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code);
|
||||||
|
#endif
|
||||||
writeInst(code.encode());
|
writeInst(code.encode());
|
||||||
as_nop();
|
as_nop();
|
||||||
return;
|
return;
|
||||||
@ -563,7 +569,13 @@ MacroAssemblerMIPS::branchWithCode(InstImm code, Label* label, JumpKind jumpKind
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle long conditional branch
|
// Handle long conditional branch
|
||||||
writeInst(invertBranch(code, BOffImm16(5 * sizeof(uint32_t))).encode());
|
spew("invert branch .Llabel %p", label);
|
||||||
|
InstImm code_r = invertBranch(code, BOffImm16(5 * sizeof(uint32_t)));
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code_r);
|
||||||
|
#endif
|
||||||
|
writeInst(code_r.encode());
|
||||||
|
|
||||||
// No need for a "nop" here because we can clobber scratch.
|
// No need for a "nop" here because we can clobber scratch.
|
||||||
addLongJump(nextOffset());
|
addLongJump(nextOffset());
|
||||||
ma_liPatchable(ScratchRegister, Imm32(label->offset()));
|
ma_liPatchable(ScratchRegister, Imm32(label->offset()));
|
||||||
@ -583,6 +595,9 @@ MacroAssemblerMIPS::branchWithCode(InstImm code, Label* label, JumpKind jumpKind
|
|||||||
|
|
||||||
// Indicate that this is short jump with offset 4.
|
// Indicate that this is short jump with offset 4.
|
||||||
code.setBOffImm16(BOffImm16(4));
|
code.setBOffImm16(BOffImm16(4));
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code);
|
||||||
|
#endif
|
||||||
BufferOffset bo = writeInst(code.encode());
|
BufferOffset bo = writeInst(code.encode());
|
||||||
writeInst(nextInChain);
|
writeInst(nextInChain);
|
||||||
if (!oom())
|
if (!oom())
|
||||||
@ -595,6 +610,9 @@ MacroAssemblerMIPS::branchWithCode(InstImm code, Label* label, JumpKind jumpKind
|
|||||||
// Make the whole branch continous in the buffer.
|
// Make the whole branch continous in the buffer.
|
||||||
m_buffer.ensureSpace((conditional ? 5 : 4) * sizeof(uint32_t));
|
m_buffer.ensureSpace((conditional ? 5 : 4) * sizeof(uint32_t));
|
||||||
|
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code);
|
||||||
|
#endif
|
||||||
BufferOffset bo = writeInst(code.encode());
|
BufferOffset bo = writeInst(code.encode());
|
||||||
writeInst(nextInChain);
|
writeInst(nextInChain);
|
||||||
if (!oom())
|
if (!oom())
|
||||||
|
@ -759,6 +759,7 @@ MacroAssemblerMIPS64::ma_b(Address addr, ImmGCPtr imm, Label* label, Condition c
|
|||||||
void
|
void
|
||||||
MacroAssemblerMIPS64::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
MacroAssemblerMIPS64::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
||||||
{
|
{
|
||||||
|
spew("branch .Llabel %p\n", label);
|
||||||
if (label->bound()) {
|
if (label->bound()) {
|
||||||
// Generate the long jump for calls because return address has to be
|
// Generate the long jump for calls because return address has to be
|
||||||
// the address after the reserved block.
|
// the address after the reserved block.
|
||||||
@ -777,6 +778,7 @@ MacroAssemblerMIPS64::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
|||||||
// instructions are writing at below (contain delay slot).
|
// instructions are writing at below (contain delay slot).
|
||||||
m_buffer.ensureSpace(6 * sizeof(uint32_t));
|
m_buffer.ensureSpace(6 * sizeof(uint32_t));
|
||||||
|
|
||||||
|
spew("bal .Llabel %p\n", label);
|
||||||
BufferOffset bo = writeInst(getBranchCode(BranchIsCall).encode());
|
BufferOffset bo = writeInst(getBranchCode(BranchIsCall).encode());
|
||||||
writeInst(nextInChain);
|
writeInst(nextInChain);
|
||||||
if (!oom())
|
if (!oom())
|
||||||
@ -792,6 +794,9 @@ MacroAssemblerMIPS64::ma_bal(Label* label, DelaySlotFill delaySlotFill)
|
|||||||
void
|
void
|
||||||
MacroAssemblerMIPS64::branchWithCode(InstImm code, Label* label, JumpKind jumpKind)
|
MacroAssemblerMIPS64::branchWithCode(InstImm code, Label* label, JumpKind jumpKind)
|
||||||
{
|
{
|
||||||
|
// simply output the pointer of one label as its id,
|
||||||
|
// notice that after one label destructor, the pointer will be reused.
|
||||||
|
spew("branch .Llabel %p", label);
|
||||||
MOZ_ASSERT(code.encode() != InstImm(op_regimm, zero, rt_bgezal, BOffImm16(0)).encode());
|
MOZ_ASSERT(code.encode() != InstImm(op_regimm, zero, rt_bgezal, BOffImm16(0)).encode());
|
||||||
InstImm inst_beq = InstImm(op_beq, zero, zero, BOffImm16(0));
|
InstImm inst_beq = InstImm(op_beq, zero, zero, BOffImm16(0));
|
||||||
|
|
||||||
@ -804,6 +809,9 @@ MacroAssemblerMIPS64::branchWithCode(InstImm code, Label* label, JumpKind jumpKi
|
|||||||
if (jumpKind == ShortJump) {
|
if (jumpKind == ShortJump) {
|
||||||
MOZ_ASSERT(BOffImm16::IsInRange(offset));
|
MOZ_ASSERT(BOffImm16::IsInRange(offset));
|
||||||
code.setBOffImm16(BOffImm16(offset));
|
code.setBOffImm16(BOffImm16(offset));
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code);
|
||||||
|
#endif
|
||||||
writeInst(code.encode());
|
writeInst(code.encode());
|
||||||
as_nop();
|
as_nop();
|
||||||
return;
|
return;
|
||||||
@ -820,7 +828,12 @@ MacroAssemblerMIPS64::branchWithCode(InstImm code, Label* label, JumpKind jumpKi
|
|||||||
|
|
||||||
// Handle long conditional branch, the target offset is based on self,
|
// Handle long conditional branch, the target offset is based on self,
|
||||||
// point to next instruction of nop at below.
|
// point to next instruction of nop at below.
|
||||||
writeInst(invertBranch(code, BOffImm16(7 * sizeof(uint32_t))).encode());
|
spew("invert branch .Llabel %p", label);
|
||||||
|
InstImm code_r = invertBranch(code, BOffImm16(7 * sizeof(uint32_t)));
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code_r);
|
||||||
|
#endif
|
||||||
|
writeInst(code_r.encode());
|
||||||
// No need for a "nop" here because we can clobber scratch.
|
// No need for a "nop" here because we can clobber scratch.
|
||||||
addLongJump(nextOffset());
|
addLongJump(nextOffset());
|
||||||
ma_liPatchable(ScratchRegister, ImmWord(label->offset()));
|
ma_liPatchable(ScratchRegister, ImmWord(label->offset()));
|
||||||
@ -840,6 +853,9 @@ MacroAssemblerMIPS64::branchWithCode(InstImm code, Label* label, JumpKind jumpKi
|
|||||||
|
|
||||||
// Indicate that this is short jump with offset 4.
|
// Indicate that this is short jump with offset 4.
|
||||||
code.setBOffImm16(BOffImm16(4));
|
code.setBOffImm16(BOffImm16(4));
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code);
|
||||||
|
#endif
|
||||||
BufferOffset bo = writeInst(code.encode());
|
BufferOffset bo = writeInst(code.encode());
|
||||||
writeInst(nextInChain);
|
writeInst(nextInChain);
|
||||||
if (!oom())
|
if (!oom())
|
||||||
@ -853,6 +869,9 @@ MacroAssemblerMIPS64::branchWithCode(InstImm code, Label* label, JumpKind jumpKi
|
|||||||
// instructions are writing at below (contain conditional nop).
|
// instructions are writing at below (contain conditional nop).
|
||||||
m_buffer.ensureSpace(7 * sizeof(uint32_t));
|
m_buffer.ensureSpace(7 * sizeof(uint32_t));
|
||||||
|
|
||||||
|
#ifdef JS_JITSPEW
|
||||||
|
decodeBranchInstAndSpew(code);
|
||||||
|
#endif
|
||||||
BufferOffset bo = writeInst(code.encode());
|
BufferOffset bo = writeInst(code.encode());
|
||||||
writeInst(nextInChain);
|
writeInst(nextInChain);
|
||||||
if (!oom())
|
if (!oom())
|
||||||
|
Loading…
Reference in New Issue
Block a user