Changeset 136601 in webkit for trunk/Source/JavaScriptCore/jit/JITDisassembler.cpp
- Timestamp:
- Dec 4, 2012, 5:26:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jit/JITDisassembler.cpp
r136318 r136601 32 32 #include "CodeBlockWithJITType.h" 33 33 #include "JIT.h" 34 #include <wtf/StringPrintStream.h> 34 35 35 36 namespace JSC { … … 48 49 void JITDisassembler::dump(PrintStream& out, LinkBuffer& linkBuffer) 49 50 { 50 out.print("Generated Baseline JIT code for ", CodeBlockWithJITType(m_codeBlock, JITCode::BaselineJIT), ", instruction count = ", m_codeBlock->instructionCount(), "\n"); 51 out.print(" Code at [", RawPointer(linkBuffer.debugAddress()), ", ", RawPointer(static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize()), "):\n"); 51 dumpHeader(out, linkBuffer); 52 52 dumpDisassembly(out, linkBuffer, m_startOfCode, m_labelForBytecodeIndexInMainPath[0]); 53 53 54 MacroAssembler::Label firstSlowLabel; 55 for (unsigned i = 0; i < m_labelForBytecodeIndexInSlowPath.size(); ++i) { 56 if (m_labelForBytecodeIndexInSlowPath[i].isSet()) { 57 firstSlowLabel = m_labelForBytecodeIndexInSlowPath[i]; 58 break; 59 } 60 } 61 dumpForInstructions(out, linkBuffer, " ", m_labelForBytecodeIndexInMainPath, firstSlowLabel.isSet() ? firstSlowLabel : m_endOfSlowPath); 54 dumpForInstructions(out, linkBuffer, " ", m_labelForBytecodeIndexInMainPath, firstSlowLabel()); 62 55 out.print(" (End Of Main Path)\n"); 63 56 dumpForInstructions(out, linkBuffer, " (S) ", m_labelForBytecodeIndexInSlowPath, m_endOfSlowPath); … … 72 65 } 73 66 74 void JITDisassembler:: dumpForInstructions(PrintStream& out, LinkBuffer& linkBuffer, const char* prefix, Vector<MacroAssembler::Label>& labels, MacroAssembler::Label endLabel)67 void JITDisassembler::reportToProfiler(Profiler::Compilation* compilation, LinkBuffer& linkBuffer) 75 68 { 76 for (unsigned i = 0 ; i < labels.size();) { 69 StringPrintStream out; 70 71 dumpHeader(out, linkBuffer); 72 compilation->addDescription(Profiler::CompiledBytecode(Profiler::OriginStack(), out.toCString())); 73 out.reset(); 74 dumpDisassembly(out, linkBuffer, m_startOfCode, m_labelForBytecodeIndexInMainPath[0]); 75 compilation->addDescription(Profiler::CompiledBytecode(Profiler::OriginStack(), out.toCString())); 76 77 reportInstructions(compilation, linkBuffer, " ", m_labelForBytecodeIndexInMainPath, firstSlowLabel()); 78 compilation->addDescription(Profiler::CompiledBytecode(Profiler::OriginStack(), " (End Of Main Path)\n")); 79 reportInstructions(compilation, linkBuffer, " (S) ", m_labelForBytecodeIndexInSlowPath, m_endOfSlowPath); 80 compilation->addDescription(Profiler::CompiledBytecode(Profiler::OriginStack(), " (End Of Slow Path)\n")); 81 out.reset(); 82 dumpDisassembly(out, linkBuffer, m_endOfSlowPath, m_endOfCode); 83 compilation->addDescription(Profiler::CompiledBytecode(Profiler::OriginStack(), out.toCString())); 84 } 85 86 void JITDisassembler::dumpHeader(PrintStream& out, LinkBuffer& linkBuffer) 87 { 88 out.print("Generated Baseline JIT code for ", CodeBlockWithJITType(m_codeBlock, JITCode::BaselineJIT), ", instruction count = ", m_codeBlock->instructionCount(), "\n"); 89 out.print(" Code at [", RawPointer(linkBuffer.debugAddress()), ", ", RawPointer(static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize()), "):\n"); 90 } 91 92 MacroAssembler::Label JITDisassembler::firstSlowLabel() 93 { 94 MacroAssembler::Label firstSlowLabel; 95 for (unsigned i = 0; i < m_labelForBytecodeIndexInSlowPath.size(); ++i) { 96 if (m_labelForBytecodeIndexInSlowPath[i].isSet()) { 97 firstSlowLabel = m_labelForBytecodeIndexInSlowPath[i]; 98 break; 99 } 100 } 101 return firstSlowLabel.isSet() ? firstSlowLabel : m_endOfSlowPath; 102 } 103 104 Vector<JITDisassembler::DumpedOp> JITDisassembler::dumpVectorForInstructions(LinkBuffer& linkBuffer, const char* prefix, Vector<MacroAssembler::Label>& labels, MacroAssembler::Label endLabel) 105 { 106 StringPrintStream out; 107 Vector<DumpedOp> result; 108 109 for (unsigned i = 0; i < labels.size();) { 77 110 if (!labels[i].isSet()) { 78 111 i++; 79 112 continue; 80 113 } 114 out.reset(); 115 result.append(DumpedOp()); 116 result.last().index = i; 81 117 out.print(prefix); 82 118 m_codeBlock->dumpBytecode(out, i); … … 84 120 if (nextIndex >= labels.size()) { 85 121 dumpDisassembly(out, linkBuffer, labels[i], endLabel); 86 return; 122 result.last().disassembly = out.toCString(); 123 return result; 87 124 } 88 125 if (labels[nextIndex].isSet()) { 89 126 dumpDisassembly(out, linkBuffer, labels[i], labels[nextIndex]); 127 result.last().disassembly = out.toCString(); 90 128 i = nextIndex; 91 129 break; 92 130 } 93 131 } 132 } 133 134 return result; 135 } 136 137 void JITDisassembler::dumpForInstructions(PrintStream& out, LinkBuffer& linkBuffer, const char* prefix, Vector<MacroAssembler::Label>& labels, MacroAssembler::Label endLabel) 138 { 139 Vector<DumpedOp> dumpedOps = dumpVectorForInstructions(linkBuffer, prefix, labels, endLabel); 140 141 for (unsigned i = 0; i < dumpedOps.size(); ++i) 142 out.print(dumpedOps[i].disassembly); 143 } 144 145 void JITDisassembler::reportInstructions(Profiler::Compilation* compilation, LinkBuffer& linkBuffer, const char* prefix, Vector<MacroAssembler::Label>& labels, MacroAssembler::Label endLabel) 146 { 147 Vector<DumpedOp> dumpedOps = dumpVectorForInstructions(linkBuffer, prefix, labels, endLabel); 148 149 for (unsigned i = 0; i < dumpedOps.size(); ++i) { 150 compilation->addDescription( 151 Profiler::CompiledBytecode( 152 Profiler::OriginStack(Profiler::Origin(compilation->bytecodes(), dumpedOps[i].index)), 153 dumpedOps[i].disassembly)); 94 154 } 95 155 }
Note:
See TracChangeset
for help on using the changeset viewer.