| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 const char* V8NameConverter::NameInCode(byte* addr) const { | 93 const char* V8NameConverter::NameInCode(byte* addr) const { |
| 94 // The V8NameConverter is used for well known code, so we can "safely" | 94 // The V8NameConverter is used for well known code, so we can "safely" |
| 95 // dereference pointers in generated code. | 95 // dereference pointers in generated code. |
| 96 return (code_ != NULL) ? reinterpret_cast<const char*>(addr) : ""; | 96 return (code_ != NULL) ? reinterpret_cast<const char*>(addr) : ""; |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 static void DumpBuffer(FILE* f, char* buff) { | 100 static void DumpBuffer(FILE* f, StringBuilder* out) { |
| 101 if (f == NULL) { | 101 if (f == NULL) { |
| 102 PrintF("%s", buff); | 102 PrintF("%s\n", out->Finalize()); |
| 103 } else { | 103 } else { |
| 104 fprintf(f, "%s", buff); | 104 fprintf(f, "%s\n", out->Finalize()); |
| 105 } | 105 } |
| 106 out->Reset(); |
| 106 } | 107 } |
| 107 | 108 |
| 109 |
| 110 |
| 108 static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength; | 111 static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength; |
| 109 static const int kRelocInfoPosition = 57; | 112 static const int kRelocInfoPosition = 57; |
| 110 | 113 |
| 111 static int DecodeIt(FILE* f, | 114 static int DecodeIt(FILE* f, |
| 112 const V8NameConverter& converter, | 115 const V8NameConverter& converter, |
| 113 byte* begin, | 116 byte* begin, |
| 114 byte* end) { | 117 byte* end) { |
| 115 NoHandleAllocation ha; | 118 NoHandleAllocation ha; |
| 116 AssertNoAllocation no_alloc; | 119 AssertNoAllocation no_alloc; |
| 117 ExternalReferenceEncoder ref_encoder; | 120 ExternalReferenceEncoder ref_encoder; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 datas.Add(it->rinfo()->data()); | 181 datas.Add(it->rinfo()->data()); |
| 179 } | 182 } |
| 180 it->next(); | 183 it->next(); |
| 181 } | 184 } |
| 182 } | 185 } |
| 183 | 186 |
| 184 StringBuilder out(out_buffer.start(), out_buffer.length()); | 187 StringBuilder out(out_buffer.start(), out_buffer.length()); |
| 185 | 188 |
| 186 // Comments. | 189 // Comments. |
| 187 for (int i = 0; i < comments.length(); i++) { | 190 for (int i = 0; i < comments.length(); i++) { |
| 188 out.AddFormatted(" %s\n", comments[i]); | 191 out.AddFormatted(" %s", comments[i]); |
| 192 DumpBuffer(f, &out); |
| 189 } | 193 } |
| 190 | 194 |
| 191 // Write out comments, resets outp so that we can format the next line. | |
| 192 DumpBuffer(f, out.Finalize()); | |
| 193 out.Reset(); | |
| 194 | |
| 195 // Instruction address and instruction offset. | 195 // Instruction address and instruction offset. |
| 196 out.AddFormatted("%p %4d ", prev_pc, prev_pc - begin); | 196 out.AddFormatted("%p %4d ", prev_pc, prev_pc - begin); |
| 197 | 197 |
| 198 // Instruction. | 198 // Instruction. |
| 199 out.AddFormatted("%s", decode_buffer.start()); | 199 out.AddFormatted("%s", decode_buffer.start()); |
| 200 | 200 |
| 201 // Print all the reloc info for this instruction which are not comments. | 201 // Print all the reloc info for this instruction which are not comments. |
| 202 for (int i = 0; i < pcs.length(); i++) { | 202 for (int i = 0; i < pcs.length(); i++) { |
| 203 // Put together the reloc info | 203 // Put together the reloc info |
| 204 RelocInfo relocinfo(pcs[i], rmodes[i], datas[i]); | 204 RelocInfo relocinfo(pcs[i], rmodes[i], datas[i]); |
| 205 | 205 |
| 206 // Indent the printing of the reloc info. | 206 // Indent the printing of the reloc info. |
| 207 if (i == 0) { | 207 if (i == 0) { |
| 208 // The first reloc info is printed after the disassembled instruction. | 208 // The first reloc info is printed after the disassembled instruction. |
| 209 out.AddPadding(' ', kRelocInfoPosition - out.position()); | 209 out.AddPadding(' ', kRelocInfoPosition - out.position()); |
| 210 } else { | 210 } else { |
| 211 // Additional reloc infos are printed on separate lines. | 211 // Additional reloc infos are printed on separate lines. |
| 212 out.AddFormatted("\n"); | 212 DumpBuffer(f, &out); |
| 213 out.AddPadding(' ', kRelocInfoPosition); | 213 out.AddPadding(' ', kRelocInfoPosition); |
| 214 } | 214 } |
| 215 | 215 |
| 216 RelocInfo::Mode rmode = relocinfo.rmode(); | 216 RelocInfo::Mode rmode = relocinfo.rmode(); |
| 217 if (RelocInfo::IsPosition(rmode)) { | 217 if (RelocInfo::IsPosition(rmode)) { |
| 218 if (RelocInfo::IsStatementPosition(rmode)) { | 218 if (RelocInfo::IsStatementPosition(rmode)) { |
| 219 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); | 219 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); |
| 220 } else { | 220 } else { |
| 221 out.AddFormatted(" ;; debug: position %d", relocinfo.data()); | 221 out.AddFormatted(" ;; debug: position %d", relocinfo.data()); |
| 222 } | 222 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 int id = Deoptimizer::GetDeoptimizationId(addr, Deoptimizer::EAGER); | 292 int id = Deoptimizer::GetDeoptimizationId(addr, Deoptimizer::EAGER); |
| 293 if (id == Deoptimizer::kNotDeoptimizationEntry) { | 293 if (id == Deoptimizer::kNotDeoptimizationEntry) { |
| 294 out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); | 294 out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); |
| 295 } else { | 295 } else { |
| 296 out.AddFormatted(" ;; deoptimization bailout %d", id); | 296 out.AddFormatted(" ;; deoptimization bailout %d", id); |
| 297 } | 297 } |
| 298 } else { | 298 } else { |
| 299 out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); | 299 out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 out.AddString("\n"); | 302 DumpBuffer(f, &out); |
| 303 DumpBuffer(f, out.Finalize()); | |
| 304 out.Reset(); | |
| 305 } | 303 } |
| 306 | 304 |
| 307 delete it; | 305 delete it; |
| 308 return static_cast<int>(pc - begin); | 306 return static_cast<int>(pc - begin); |
| 309 } | 307 } |
| 310 | 308 |
| 311 | 309 |
| 312 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { | 310 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { |
| 313 V8NameConverter defaultConverter(NULL); | 311 V8NameConverter defaultConverter(NULL); |
| 314 return DecodeIt(f, defaultConverter, begin, end); | 312 return DecodeIt(f, defaultConverter, begin, end); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 334 | 332 |
| 335 #else // ENABLE_DISASSEMBLER | 333 #else // ENABLE_DISASSEMBLER |
| 336 | 334 |
| 337 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} | 335 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} |
| 338 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } | 336 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } |
| 339 void Disassembler::Decode(FILE* f, Code* code) {} | 337 void Disassembler::Decode(FILE* f, Code* code) {} |
| 340 | 338 |
| 341 #endif // ENABLE_DISASSEMBLER | 339 #endif // ENABLE_DISASSEMBLER |
| 342 | 340 |
| 343 } } // namespace v8::internal | 341 } } // namespace v8::internal |
| OLD | NEW |