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( | 112 SNPrintF(decode_buffer, |
113 decode_buffer, "%08" V8PRIxPTR " jump table entry %4" PRIuS, | 113 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, |
114 reinterpret_cast<intptr_t>(ptr), static_cast<size_t>(ptr - begin)); | 114 reinterpret_cast<intptr_t>(ptr), |
| 115 ptr - begin); |
115 pc += sizeof(ptr); | 116 pc += sizeof(ptr); |
116 } else { | 117 } else { |
117 decode_buffer[0] = '\0'; | 118 decode_buffer[0] = '\0'; |
118 pc += d.InstructionDecode(decode_buffer, pc); | 119 pc += d.InstructionDecode(decode_buffer, pc); |
119 } | 120 } |
120 } | 121 } |
121 | 122 |
122 // Collect RelocInfo for this instruction (prev_pc .. pc-1) | 123 // Collect RelocInfo for this instruction (prev_pc .. pc-1) |
123 List<const char*> comments(4); | 124 List<const char*> comments(4); |
124 List<byte*> pcs(1); | 125 List<byte*> pcs(1); |
(...skipping 14 matching lines...) Expand all Loading... |
139 } | 140 } |
140 } | 141 } |
141 | 142 |
142 // Comments. | 143 // Comments. |
143 for (int i = 0; i < comments.length(); i++) { | 144 for (int i = 0; i < comments.length(); i++) { |
144 out.AddFormatted(" %s", comments[i]); | 145 out.AddFormatted(" %s", comments[i]); |
145 DumpBuffer(os, &out); | 146 DumpBuffer(os, &out); |
146 } | 147 } |
147 | 148 |
148 // Instruction address and instruction offset. | 149 // Instruction address and instruction offset. |
149 out.AddFormatted("%p %4" V8PRIdPTRDIFF " ", prev_pc, prev_pc - begin); | 150 out.AddFormatted("%p %4d ", prev_pc, prev_pc - begin); |
150 | 151 |
151 // Instruction. | 152 // Instruction. |
152 out.AddFormatted("%s", decode_buffer.start()); | 153 out.AddFormatted("%s", decode_buffer.start()); |
153 | 154 |
154 // Print all the reloc info for this instruction which are not comments. | 155 // Print all the reloc info for this instruction which are not comments. |
155 for (int i = 0; i < pcs.length(); i++) { | 156 for (int i = 0; i < pcs.length(); i++) { |
156 // Put together the reloc info | 157 // Put together the reloc info |
157 RelocInfo relocinfo(isolate, pcs[i], rmodes[i], datas[i], | 158 RelocInfo relocinfo(isolate, pcs[i], rmodes[i], datas[i], |
158 converter.code()); | 159 converter.code()); |
159 | 160 |
160 // Indent the printing of the reloc info. | 161 // Indent the printing of the reloc info. |
161 if (i == 0) { | 162 if (i == 0) { |
162 // The first reloc info is printed after the disassembled instruction. | 163 // The first reloc info is printed after the disassembled instruction. |
163 out.AddPadding(' ', kRelocInfoPosition - out.position()); | 164 out.AddPadding(' ', kRelocInfoPosition - out.position()); |
164 } else { | 165 } else { |
165 // Additional reloc infos are printed on separate lines. | 166 // Additional reloc infos are printed on separate lines. |
166 DumpBuffer(os, &out); | 167 DumpBuffer(os, &out); |
167 out.AddPadding(' ', kRelocInfoPosition); | 168 out.AddPadding(' ', kRelocInfoPosition); |
168 } | 169 } |
169 | 170 |
170 RelocInfo::Mode rmode = relocinfo.rmode(); | 171 RelocInfo::Mode rmode = relocinfo.rmode(); |
171 if (RelocInfo::IsPosition(rmode)) { | 172 if (RelocInfo::IsPosition(rmode)) { |
172 if (RelocInfo::IsStatementPosition(rmode)) { | 173 if (RelocInfo::IsStatementPosition(rmode)) { |
173 out.AddFormatted(" ;; debug: statement %" V8PRIdPTR, | 174 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); |
174 relocinfo.data()); | |
175 } else { | 175 } else { |
176 out.AddFormatted(" ;; debug: position %" V8PRIdPTR, | 176 out.AddFormatted(" ;; debug: position %d", relocinfo.data()); |
177 relocinfo.data()); | |
178 } | 177 } |
179 } else if (rmode == RelocInfo::DEOPT_REASON) { | 178 } else if (rmode == RelocInfo::DEOPT_REASON) { |
180 Deoptimizer::DeoptReason reason = | 179 Deoptimizer::DeoptReason reason = |
181 static_cast<Deoptimizer::DeoptReason>(relocinfo.data()); | 180 static_cast<Deoptimizer::DeoptReason>(relocinfo.data()); |
182 out.AddFormatted(" ;; debug: deopt reason '%s'", | 181 out.AddFormatted(" ;; debug: deopt reason '%s'", |
183 Deoptimizer::GetDeoptReason(reason)); | 182 Deoptimizer::GetDeoptReason(reason)); |
184 } else if (rmode == RelocInfo::EMBEDDED_OBJECT) { | 183 } else if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
185 HeapStringAllocator allocator; | 184 HeapStringAllocator allocator; |
186 StringStream accumulator(&allocator); | 185 StringStream accumulator(&allocator); |
187 relocinfo.target_object()->ShortPrint(&accumulator); | 186 relocinfo.target_object()->ShortPrint(&accumulator); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 277 |
279 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, | 278 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, |
280 byte* end, Code* code) { | 279 byte* end, Code* code) { |
281 return 0; | 280 return 0; |
282 } | 281 } |
283 | 282 |
284 #endif // ENABLE_DISASSEMBLER | 283 #endif // ENABLE_DISASSEMBLER |
285 | 284 |
286 } // namespace internal | 285 } // namespace internal |
287 } // namespace v8 | 286 } // namespace v8 |
OLD | NEW |