| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/disassembler.h" | 5 #include "src/disassembler.h" |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (num_const >= 0) { | 102 if (num_const >= 0) { |
| 103 SNPrintF(decode_buffer, | 103 SNPrintF(decode_buffer, |
| 104 "%08x constant pool begin (num_const = %d)", | 104 "%08x constant pool begin (num_const = %d)", |
| 105 *reinterpret_cast<int32_t*>(pc), num_const); | 105 *reinterpret_cast<int32_t*>(pc), num_const); |
| 106 constants = num_const; | 106 constants = num_const; |
| 107 pc += 4; | 107 pc += 4; |
| 108 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && | 108 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && |
| 109 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { | 109 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { |
| 110 // raw pointer embedded in code stream, e.g., jump table | 110 // raw pointer embedded in code stream, e.g., jump table |
| 111 byte* ptr = *reinterpret_cast<byte**>(pc); | 111 byte* ptr = *reinterpret_cast<byte**>(pc); |
| 112 SNPrintF(decode_buffer, | 112 SNPrintF( |
| 113 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, | 113 decode_buffer, "%08" V8PRIxPTR " jump table entry %4" PRIuS, |
| 114 reinterpret_cast<intptr_t>(ptr), | 114 reinterpret_cast<intptr_t>(ptr), static_cast<size_t>(ptr - begin)); |
| 115 ptr - begin); | |
| 116 pc += sizeof(ptr); | 115 pc += sizeof(ptr); |
| 117 } else { | 116 } else { |
| 118 decode_buffer[0] = '\0'; | 117 decode_buffer[0] = '\0'; |
| 119 pc += d.InstructionDecode(decode_buffer, pc); | 118 pc += d.InstructionDecode(decode_buffer, pc); |
| 120 } | 119 } |
| 121 } | 120 } |
| 122 | 121 |
| 123 // Collect RelocInfo for this instruction (prev_pc .. pc-1) | 122 // Collect RelocInfo for this instruction (prev_pc .. pc-1) |
| 124 List<const char*> comments(4); | 123 List<const char*> comments(4); |
| 125 List<byte*> pcs(1); | 124 List<byte*> pcs(1); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 140 } | 139 } |
| 141 } | 140 } |
| 142 | 141 |
| 143 // Comments. | 142 // Comments. |
| 144 for (int i = 0; i < comments.length(); i++) { | 143 for (int i = 0; i < comments.length(); i++) { |
| 145 out.AddFormatted(" %s", comments[i]); | 144 out.AddFormatted(" %s", comments[i]); |
| 146 DumpBuffer(os, &out); | 145 DumpBuffer(os, &out); |
| 147 } | 146 } |
| 148 | 147 |
| 149 // Instruction address and instruction offset. | 148 // Instruction address and instruction offset. |
| 150 out.AddFormatted("%p %4d ", prev_pc, prev_pc - begin); | 149 out.AddFormatted("%p %4" V8PRIdPTRDIFF " ", prev_pc, prev_pc - begin); |
| 151 | 150 |
| 152 // Instruction. | 151 // Instruction. |
| 153 out.AddFormatted("%s", decode_buffer.start()); | 152 out.AddFormatted("%s", decode_buffer.start()); |
| 154 | 153 |
| 155 // Print all the reloc info for this instruction which are not comments. | 154 // Print all the reloc info for this instruction which are not comments. |
| 156 for (int i = 0; i < pcs.length(); i++) { | 155 for (int i = 0; i < pcs.length(); i++) { |
| 157 // Put together the reloc info | 156 // Put together the reloc info |
| 158 RelocInfo relocinfo(isolate, pcs[i], rmodes[i], datas[i], | 157 RelocInfo relocinfo(isolate, pcs[i], rmodes[i], datas[i], |
| 159 converter.code()); | 158 converter.code()); |
| 160 | 159 |
| 161 // Indent the printing of the reloc info. | 160 // Indent the printing of the reloc info. |
| 162 if (i == 0) { | 161 if (i == 0) { |
| 163 // The first reloc info is printed after the disassembled instruction. | 162 // The first reloc info is printed after the disassembled instruction. |
| 164 out.AddPadding(' ', kRelocInfoPosition - out.position()); | 163 out.AddPadding(' ', kRelocInfoPosition - out.position()); |
| 165 } else { | 164 } else { |
| 166 // Additional reloc infos are printed on separate lines. | 165 // Additional reloc infos are printed on separate lines. |
| 167 DumpBuffer(os, &out); | 166 DumpBuffer(os, &out); |
| 168 out.AddPadding(' ', kRelocInfoPosition); | 167 out.AddPadding(' ', kRelocInfoPosition); |
| 169 } | 168 } |
| 170 | 169 |
| 171 RelocInfo::Mode rmode = relocinfo.rmode(); | 170 RelocInfo::Mode rmode = relocinfo.rmode(); |
| 172 if (RelocInfo::IsPosition(rmode)) { | 171 if (RelocInfo::IsPosition(rmode)) { |
| 173 if (RelocInfo::IsStatementPosition(rmode)) { | 172 if (RelocInfo::IsStatementPosition(rmode)) { |
| 174 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); | 173 out.AddFormatted(" ;; debug: statement %" V8PRIdPTR, |
| 174 relocinfo.data()); |
| 175 } else { | 175 } else { |
| 176 out.AddFormatted(" ;; debug: position %d", relocinfo.data()); | 176 out.AddFormatted(" ;; debug: position %" V8PRIdPTR, |
| 177 relocinfo.data()); |
| 177 } | 178 } |
| 178 } else if (rmode == RelocInfo::DEOPT_REASON) { | 179 } else if (rmode == RelocInfo::DEOPT_REASON) { |
| 179 Deoptimizer::DeoptReason reason = | 180 Deoptimizer::DeoptReason reason = |
| 180 static_cast<Deoptimizer::DeoptReason>(relocinfo.data()); | 181 static_cast<Deoptimizer::DeoptReason>(relocinfo.data()); |
| 181 out.AddFormatted(" ;; debug: deopt reason '%s'", | 182 out.AddFormatted(" ;; debug: deopt reason '%s'", |
| 182 Deoptimizer::GetDeoptReason(reason)); | 183 Deoptimizer::GetDeoptReason(reason)); |
| 183 } else if (rmode == RelocInfo::EMBEDDED_OBJECT) { | 184 } else if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
| 184 HeapStringAllocator allocator; | 185 HeapStringAllocator allocator; |
| 185 StringStream accumulator(&allocator); | 186 StringStream accumulator(&allocator); |
| 186 relocinfo.target_object()->ShortPrint(&accumulator); | 187 relocinfo.target_object()->ShortPrint(&accumulator); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 278 |
| 278 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, | 279 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, |
| 279 byte* end, Code* code) { | 280 byte* end, Code* code) { |
| 280 return 0; | 281 return 0; |
| 281 } | 282 } |
| 282 | 283 |
| 283 #endif // ENABLE_DISASSEMBLER | 284 #endif // ENABLE_DISASSEMBLER |
| 284 | 285 |
| 285 } // namespace internal | 286 } // namespace internal |
| 286 } // namespace v8 | 287 } // namespace v8 |
| OLD | NEW |