OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // Indent the printing of the reloc info. | 190 // Indent the printing of the reloc info. |
191 if (i == 0) { | 191 if (i == 0) { |
192 // The first reloc info is printed after the disassembled instruction. | 192 // The first reloc info is printed after the disassembled instruction. |
193 out.AddPadding(' ', kRelocInfoPosition - out.position()); | 193 out.AddPadding(' ', kRelocInfoPosition - out.position()); |
194 } else { | 194 } else { |
195 // Additional reloc infos are printed on separate lines. | 195 // Additional reloc infos are printed on separate lines. |
196 out.AddFormatted("\n"); | 196 out.AddFormatted("\n"); |
197 out.AddPadding(' ', kRelocInfoPosition); | 197 out.AddPadding(' ', kRelocInfoPosition); |
198 } | 198 } |
199 | 199 |
200 if (is_position(relocinfo.rmode())) { | 200 RelocMode rmode = relocinfo.rmode(); |
201 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); | 201 if (is_position(rmode)) { |
202 } else if (relocinfo.rmode() == embedded_object) { | 202 if (is_statement_position(rmode)) { |
| 203 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); |
| 204 } else { |
| 205 out.AddFormatted(" ;; debug: position %d", relocinfo.data()); |
| 206 } |
| 207 } else if (rmode == embedded_object) { |
203 HeapStringAllocator allocator; | 208 HeapStringAllocator allocator; |
204 StringStream accumulator(&allocator); | 209 StringStream accumulator(&allocator); |
205 relocinfo.target_object()->ShortPrint(&accumulator); | 210 relocinfo.target_object()->ShortPrint(&accumulator); |
206 SmartPointer<char> obj_name = accumulator.ToCString(); | 211 SmartPointer<char> obj_name = accumulator.ToCString(); |
207 out.AddFormatted(" ;; object: %s", *obj_name); | 212 out.AddFormatted(" ;; object: %s", *obj_name); |
208 } else if (relocinfo.rmode() == external_reference) { | 213 } else if (rmode == external_reference) { |
209 const char* reference_name = | 214 const char* reference_name = |
210 ref_encoder.NameOfAddress(*relocinfo.target_reference_address()); | 215 ref_encoder.NameOfAddress(*relocinfo.target_reference_address()); |
211 out.AddFormatted(" ;; external reference (%s)", reference_name); | 216 out.AddFormatted(" ;; external reference (%s)", reference_name); |
| 217 } else if (is_code_target(rmode)) { |
| 218 out.AddFormatted(" ;; code:"); |
| 219 if (rmode == js_construct_call) { |
| 220 out.AddFormatted(" constructor,"); |
| 221 } |
| 222 Code* code = Debug::GetCodeTarget(relocinfo.target_address()); |
| 223 Code::Kind kind = code->kind(); |
| 224 if (code->is_inline_cache_stub()) { |
| 225 if (rmode == code_target_context) { |
| 226 out.AddFormatted(" contextual,"); |
| 227 } |
| 228 InlineCacheState ic_state = code->ic_state(); |
| 229 out.AddFormatted(" %s, %s", Code::Kind2String(kind), |
| 230 Code::ICState2String(ic_state)); |
| 231 if (kind == Code::CALL_IC) { |
| 232 out.AddFormatted(", argc = %d", code->arguments_count()); |
| 233 } |
| 234 } else if (kind == Code::STUB) { |
| 235 // Reverse lookup required as the minor key cannot be retrieved |
| 236 // from the code object. |
| 237 Object* obj = Heap::code_stubs()->SlowReverseLookup(code); |
| 238 if (obj != Heap::undefined_value()) { |
| 239 ASSERT(obj->IsSmi()); |
| 240 // Get the STUB key and extract major and minor key. |
| 241 uint32_t key = Smi::cast(obj)->value(); |
| 242 uint32_t minor_key = CodeStub::MinorKeyFromKey(key); |
| 243 ASSERT(code->major_key() == CodeStub::MajorKeyFromKey(key)); |
| 244 out.AddFormatted(" %s, %s, ", |
| 245 Code::Kind2String(kind), |
| 246 CodeStub::MajorName(code->major_key())); |
| 247 switch (code->major_key()) { |
| 248 case CodeStub::CallFunction: |
| 249 out.AddFormatted("argc = %d", minor_key); |
| 250 break; |
| 251 case CodeStub::Runtime: { |
| 252 const char* name = |
| 253 RuntimeStub::GetNameFromMinorKey(minor_key); |
| 254 out.AddFormatted("%s", name); |
| 255 break; |
| 256 } |
| 257 default: |
| 258 out.AddFormatted("minor: %d", minor_key); |
| 259 } |
| 260 } |
| 261 } else { |
| 262 out.AddFormatted(" %s", Code::Kind2String(kind)); |
| 263 } |
212 } else { | 264 } else { |
213 out.AddFormatted(" ;; %s", | 265 out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); |
214 RelocInfo::RelocModeName(relocinfo.rmode())); | |
215 if (is_code_target(relocinfo.rmode())) { | |
216 Code* code = Debug::GetCodeTarget(relocinfo.target_address()); | |
217 Code::Kind kind = code->kind(); | |
218 if (kind == Code::STUB) { | |
219 // Reverse lookup required as the minor key cannot be retrieved | |
220 // from the code object. | |
221 Object* obj = Heap::code_stubs()->SlowReverseLookup(code); | |
222 if (obj != Heap::undefined_value()) { | |
223 ASSERT(obj->IsSmi()); | |
224 // Get the STUB key and extract major and minor key. | |
225 uint32_t key = Smi::cast(obj)->value(); | |
226 uint32_t minor_key = CodeStub::MinorKeyFromKey(key); | |
227 ASSERT(code->major_key() == CodeStub::MajorKeyFromKey(key)); | |
228 out.AddFormatted(" (%s, %s, ", | |
229 Code::Kind2String(kind), | |
230 CodeStub::MajorName(code->major_key())); | |
231 switch (code->major_key()) { | |
232 case CodeStub::CallFunction: | |
233 out.AddFormatted("argc = %d)", minor_key); | |
234 break; | |
235 case CodeStub::Runtime: { | |
236 const char* name = | |
237 RuntimeStub::GetNameFromMinorKey(minor_key); | |
238 out.AddFormatted("%s)", name); | |
239 break; | |
240 } | |
241 default: | |
242 out.AddFormatted("minor: %d)", minor_key); | |
243 } | |
244 } | |
245 } else { | |
246 out.AddFormatted(" (%s)", Code::Kind2String(kind)); | |
247 } | |
248 } | |
249 } | 266 } |
250 } | 267 } |
251 out.AddString("\n"); | 268 out.AddString("\n"); |
252 DumpBuffer(f, out.Finalize()); | 269 DumpBuffer(f, out.Finalize()); |
253 out.Reset(); | 270 out.Reset(); |
254 } | 271 } |
255 | 272 |
256 delete it; | 273 delete it; |
257 return pc - begin; | 274 return pc - begin; |
258 } | 275 } |
(...skipping 15 matching lines...) Expand all Loading... |
274 | 291 |
275 #else // ENABLE_DISASSEMBLER | 292 #else // ENABLE_DISASSEMBLER |
276 | 293 |
277 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} | 294 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} |
278 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } | 295 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } |
279 void Disassembler::Decode(FILE* f, Code* code) {} | 296 void Disassembler::Decode(FILE* f, Code* code) {} |
280 | 297 |
281 #endif // ENABLE_DISASSEMBLER | 298 #endif // ENABLE_DISASSEMBLER |
282 | 299 |
283 } } // namespace v8::internal | 300 } } // namespace v8::internal |
OLD | NEW |