Ignore:
Timestamp:
Nov 28, 2012, 3:37:24 PM (13 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/dfg/DFGDisassembler.cpp

    r135923 r136069  
    4040}
    4141
    42 void Disassembler::dump(LinkBuffer& linkBuffer)
     42void Disassembler::dump(PrintStream& out, LinkBuffer& linkBuffer)
    4343{
    4444    m_graph.m_dominators.computeIfNecessary(m_graph);
    4545   
    46     dataLogF("Generated JIT code for DFG CodeBlock %p, instruction count = %u:\n", m_graph.m_codeBlock, m_graph.m_codeBlock->instructionCount());
    47     dataLogF("    Code at [%p, %p):\n", linkBuffer.debugAddress(), static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize());
     46    out.print("Generated JIT code for DFG CodeBlock ", RawPointer(m_graph.m_codeBlock), ", instruction count = ", m_graph.m_codeBlock->instructionCount(), ":\n");
     47    out.print("    Code at [", RawPointer(linkBuffer.debugAddress()), ", ", RawPointer(static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize()), "):\n");
    4848   
    4949    const char* prefix = "    ";
     
    5656        if (!block)
    5757            continue;
    58         dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, m_labelForBlockIndex[blockIndex], lastNodeIndex);
    59         m_graph.dumpBlockHeader(prefix, blockIndex, Graph::DumpLivePhisOnly);
     58        dumpDisassembly(out, disassemblyPrefix, linkBuffer, previousLabel, m_labelForBlockIndex[blockIndex], lastNodeIndex);
     59        m_graph.dumpBlockHeader(out, prefix, blockIndex, Graph::DumpLivePhisOnly);
    6060        NodeIndex lastNodeIndexForDisassembly = block->at(0);
    6161        for (size_t i = 0; i < block->size(); ++i) {
     
    7575                    currentLabel = m_endOfMainPath;
    7676            }
    77             dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, currentLabel, lastNodeIndexForDisassembly);
    78             m_graph.dumpCodeOrigin(prefix, lastNodeIndex, block->at(i));
    79             m_graph.dump(prefix, block->at(i));
     77            dumpDisassembly(out, disassemblyPrefix, linkBuffer, previousLabel, currentLabel, lastNodeIndexForDisassembly);
     78            m_graph.dumpCodeOrigin(out, prefix, lastNodeIndex, block->at(i));
     79            m_graph.dump(out, prefix, block->at(i));
    8080            lastNodeIndex = block->at(i);
    8181            lastNodeIndexForDisassembly = block->at(i);
    8282        }
    8383    }
    84     dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, m_endOfMainPath, lastNodeIndex);
    85     dataLogF("%s(End Of Main Path)\n", prefix);
    86     dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, m_endOfCode, NoNode);
     84    dumpDisassembly(out, disassemblyPrefix, linkBuffer, previousLabel, m_endOfMainPath, lastNodeIndex);
     85    out.print(prefix, "(End Of Main Path)\n");
     86    dumpDisassembly(out, disassemblyPrefix, linkBuffer, previousLabel, m_endOfCode, NoNode);
    8787}
    8888
    89 void Disassembler::dumpDisassembly(const char* prefix, LinkBuffer& linkBuffer, MacroAssembler::Label& previousLabel, MacroAssembler::Label currentLabel, NodeIndex context)
     89void Disassembler::dump(LinkBuffer& linkBuffer)
     90{
     91    dump(WTF::dataFile(), linkBuffer);
     92}
     93
     94void Disassembler::dumpDisassembly(PrintStream& out, const char* prefix, LinkBuffer& linkBuffer, MacroAssembler::Label& previousLabel, MacroAssembler::Label currentLabel, NodeIndex context)
    9095{
    9196    size_t prefixLength = strlen(prefix);
     
    105110    previousLabel = currentLabel;
    106111    ASSERT(bitwise_cast<uintptr_t>(end.executableAddress()) >= bitwise_cast<uintptr_t>(start.executableAddress()));
    107     disassemble(start, bitwise_cast<uintptr_t>(end.executableAddress()) - bitwise_cast<uintptr_t>(start.executableAddress()), prefixBuffer.get(), WTF::dataFile());
     112    disassemble(start, bitwise_cast<uintptr_t>(end.executableAddress()) - bitwise_cast<uintptr_t>(start.executableAddress()), prefixBuffer.get(), out);
    108113}
    109114
Note: See TracChangeset for help on using the changeset viewer.