Ignore:
Timestamp:
Nov 28, 2012, 3:37:24 PM (12 years ago)
Author:
[email protected]
Message:

Disassembly methods should be able to disassemble to any PrintStream& rather than always using WTF::dataFile()
https://bugs.webkit.org/show_bug.cgi?id=103492

Reviewed by Mark Hahnenberg.

Switched disassembly code to use PrintStream&, and to use print() rather than printf().

  • dfg/DFGDisassembler.cpp:

(JSC::DFG::Disassembler::dump):
(DFG):
(JSC::DFG::Disassembler::dumpDisassembly):

  • dfg/DFGDisassembler.h:

(Disassembler):

  • dfg/DFGGraph.cpp:

(JSC::DFG::printWhiteSpace):
(JSC::DFG::Graph::dumpCodeOrigin):
(JSC::DFG::Graph::printNodeWhiteSpace):
(JSC::DFG::Graph::dump):
(DFG):
(JSC::DFG::Graph::dumpBlockHeader):

  • dfg/DFGGraph.h:

(Graph):

  • jit/JITDisassembler.cpp:

(JSC::JITDisassembler::dump):
(JSC::JITDisassembler::dumpForInstructions):
(JSC::JITDisassembler::dumpDisassembly):

  • jit/JITDisassembler.h:

(JITDisassembler):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JITDisassembler.cpp

    r135469 r136069  
    4545}
    4646
    47 void JITDisassembler::dump(LinkBuffer& linkBuffer)
     47void JITDisassembler::dump(PrintStream& out, LinkBuffer& linkBuffer)
    4848{
    49     dataLogF("Baseline JIT code for CodeBlock %p, instruction count = %u:\n", m_codeBlock, m_codeBlock->instructionCount());
    50     dataLogF("    Code at [%p, %p):\n", linkBuffer.debugAddress(), static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize());
    51     dumpDisassembly(linkBuffer, m_startOfCode, m_labelForBytecodeIndexInMainPath[0]);
     49    out.print("Baseline JIT code for CodeBlock ", RawPointer(m_codeBlock), ", instruction count = ", m_codeBlock->instructionCount(), "\n");
     50    out.print("   Code at [", RawPointer(linkBuffer.debugAddress()), ", ", RawPointer(static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize()), "):\n");
     51    dumpDisassembly(out, linkBuffer, m_startOfCode, m_labelForBytecodeIndexInMainPath[0]);
    5252   
    5353    MacroAssembler::Label firstSlowLabel;
     
    5858        }
    5959    }
    60     dumpForInstructions(linkBuffer, "    ", m_labelForBytecodeIndexInMainPath, firstSlowLabel.isSet() ? firstSlowLabel : m_endOfSlowPath);
    61     dataLogF("    (End Of Main Path)\n");
    62     dumpForInstructions(linkBuffer, "    (S) ", m_labelForBytecodeIndexInSlowPath, m_endOfSlowPath);
    63     dataLogF("    (End Of Slow Path)\n");
     60    dumpForInstructions(out, linkBuffer, "    ", m_labelForBytecodeIndexInMainPath, firstSlowLabel.isSet() ? firstSlowLabel : m_endOfSlowPath);
     61    out.print("    (End Of Main Path)\n");
     62    dumpForInstructions(out, linkBuffer, "    (S) ", m_labelForBytecodeIndexInSlowPath, m_endOfSlowPath);
     63    out.print("    (End Of Slow Path)\n");
    6464
    65     dumpDisassembly(linkBuffer, m_endOfSlowPath, m_endOfCode);
     65    dumpDisassembly(out, linkBuffer, m_endOfSlowPath, m_endOfCode);
    6666}
    6767
    68 void JITDisassembler::dumpForInstructions(LinkBuffer& linkBuffer, const char* prefix, Vector<MacroAssembler::Label>& labels, MacroAssembler::Label endLabel)
     68void JITDisassembler::dump(LinkBuffer& linkBuffer)
     69{
     70    dump(WTF::dataFile(), linkBuffer);
     71}
     72
     73void JITDisassembler::dumpForInstructions(PrintStream& out, LinkBuffer& linkBuffer, const char* prefix, Vector<MacroAssembler::Label>& labels, MacroAssembler::Label endLabel)
    6974{
    7075    for (unsigned i = 0 ; i < labels.size();) {
     
    7378            continue;
    7479        }
    75         dataLogF("%s", prefix);
     80        out.print(prefix);
    7681        m_codeBlock->dump(i);
    7782        for (unsigned nextIndex = i + 1; ; nextIndex++) {
    7883            if (nextIndex >= labels.size()) {
    79                 dumpDisassembly(linkBuffer, labels[i], endLabel);
     84                dumpDisassembly(out, linkBuffer, labels[i], endLabel);
    8085                return;
    8186            }
    8287            if (labels[nextIndex].isSet()) {
    83                 dumpDisassembly(linkBuffer, labels[i], labels[nextIndex]);
     88                dumpDisassembly(out, linkBuffer, labels[i], labels[nextIndex]);
    8489                i = nextIndex;
    8590                break;
     
    8994}
    9095
    91 void JITDisassembler::dumpDisassembly(LinkBuffer& linkBuffer, MacroAssembler::Label from, MacroAssembler::Label to)
     96void JITDisassembler::dumpDisassembly(PrintStream& out, LinkBuffer& linkBuffer, MacroAssembler::Label from, MacroAssembler::Label to)
    9297{
    9398    CodeLocationLabel fromLocation = linkBuffer.locationOf(from);
    9499    CodeLocationLabel toLocation = linkBuffer.locationOf(to);
    95     disassemble(fromLocation, bitwise_cast<uintptr_t>(toLocation.executableAddress()) - bitwise_cast<uintptr_t>(fromLocation.executableAddress()), "        ", WTF::dataFile());
     100    disassemble(fromLocation, bitwise_cast<uintptr_t>(toLocation.executableAddress()) - bitwise_cast<uintptr_t>(fromLocation.executableAddress()), "        ", out);
    96101}
    97102
Note: See TracChangeset for help on using the changeset viewer.