| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 pc += 4; | 133 pc += 4; |
| 134 } else { | 134 } else { |
| 135 int num_const = d.ConstantPoolSizeAt(pc); | 135 int num_const = d.ConstantPoolSizeAt(pc); |
| 136 if (num_const >= 0) { | 136 if (num_const >= 0) { |
| 137 OS::SNPrintF(decode_buffer, | 137 OS::SNPrintF(decode_buffer, |
| 138 "%08x constant pool begin", | 138 "%08x constant pool begin", |
| 139 *reinterpret_cast<int32_t*>(pc)); | 139 *reinterpret_cast<int32_t*>(pc)); |
| 140 constants = num_const; | 140 constants = num_const; |
| 141 pc += 4; | 141 pc += 4; |
| 142 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && | 142 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && |
| 143 it->rinfo()->rmode() == internal_reference) { | 143 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { |
| 144 // raw pointer embedded in code stream, e.g., jump table | 144 // raw pointer embedded in code stream, e.g., jump table |
| 145 byte* ptr = *reinterpret_cast<byte**>(pc); | 145 byte* ptr = *reinterpret_cast<byte**>(pc); |
| 146 OS::SNPrintF(decode_buffer, | 146 OS::SNPrintF(decode_buffer, |
| 147 "%08x jump table entry %4d", | 147 "%08x jump table entry %4d", |
| 148 reinterpret_cast<int32_t>(ptr), | 148 reinterpret_cast<int32_t>(ptr), |
| 149 ptr - begin); | 149 ptr - begin); |
| 150 pc += 4; | 150 pc += 4; |
| 151 } else { | 151 } else { |
| 152 decode_buffer[0] = '\0'; | 152 decode_buffer[0] = '\0'; |
| 153 pc += d.InstructionDecode(decode_buffer, pc); | 153 pc += d.InstructionDecode(decode_buffer, pc); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Collect RelocInfo for this instruction (prev_pc .. pc-1) | 157 // Collect RelocInfo for this instruction (prev_pc .. pc-1) |
| 158 List<const char*> comments(4); | 158 List<const char*> comments(4); |
| 159 List<byte*> pcs(1); | 159 List<byte*> pcs(1); |
| 160 List<RelocMode> rmodes(1); | 160 List<RelocInfo::Mode> rmodes(1); |
| 161 List<intptr_t> datas(1); | 161 List<intptr_t> datas(1); |
| 162 if (it != NULL) { | 162 if (it != NULL) { |
| 163 while (!it->done() && it->rinfo()->pc() < pc) { | 163 while (!it->done() && it->rinfo()->pc() < pc) { |
| 164 if (is_comment(it->rinfo()->rmode())) { | 164 if (RelocInfo::IsComment(it->rinfo()->rmode())) { |
| 165 // For comments just collect the text. | 165 // For comments just collect the text. |
| 166 comments.Add(reinterpret_cast<const char*>(it->rinfo()->data())); | 166 comments.Add(reinterpret_cast<const char*>(it->rinfo()->data())); |
| 167 } else { | 167 } else { |
| 168 // For other reloc info collect all data. | 168 // For other reloc info collect all data. |
| 169 pcs.Add(it->rinfo()->pc()); | 169 pcs.Add(it->rinfo()->pc()); |
| 170 rmodes.Add(it->rinfo()->rmode()); | 170 rmodes.Add(it->rinfo()->rmode()); |
| 171 datas.Add(it->rinfo()->data()); | 171 datas.Add(it->rinfo()->data()); |
| 172 } | 172 } |
| 173 it->next(); | 173 it->next(); |
| 174 } | 174 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 199 // Indent the printing of the reloc info. | 199 // Indent the printing of the reloc info. |
| 200 if (i == 0) { | 200 if (i == 0) { |
| 201 // The first reloc info is printed after the disassembled instruction. | 201 // The first reloc info is printed after the disassembled instruction. |
| 202 out.AddPadding(' ', kRelocInfoPosition - out.position()); | 202 out.AddPadding(' ', kRelocInfoPosition - out.position()); |
| 203 } else { | 203 } else { |
| 204 // Additional reloc infos are printed on separate lines. | 204 // Additional reloc infos are printed on separate lines. |
| 205 out.AddFormatted("\n"); | 205 out.AddFormatted("\n"); |
| 206 out.AddPadding(' ', kRelocInfoPosition); | 206 out.AddPadding(' ', kRelocInfoPosition); |
| 207 } | 207 } |
| 208 | 208 |
| 209 RelocMode rmode = relocinfo.rmode(); | 209 RelocInfo::Mode rmode = relocinfo.rmode(); |
| 210 if (is_position(rmode)) { | 210 if (RelocInfo::IsPosition(rmode)) { |
| 211 if (is_statement_position(rmode)) { | 211 if (RelocInfo::IsStatementPosition(rmode)) { |
| 212 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); | 212 out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); |
| 213 } else { | 213 } else { |
| 214 out.AddFormatted(" ;; debug: position %d", relocinfo.data()); | 214 out.AddFormatted(" ;; debug: position %d", relocinfo.data()); |
| 215 } | 215 } |
| 216 } else if (rmode == embedded_object) { | 216 } else if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
| 217 HeapStringAllocator allocator; | 217 HeapStringAllocator allocator; |
| 218 StringStream accumulator(&allocator); | 218 StringStream accumulator(&allocator); |
| 219 relocinfo.target_object()->ShortPrint(&accumulator); | 219 relocinfo.target_object()->ShortPrint(&accumulator); |
| 220 SmartPointer<char> obj_name = accumulator.ToCString(); | 220 SmartPointer<char> obj_name = accumulator.ToCString(); |
| 221 out.AddFormatted(" ;; object: %s", *obj_name); | 221 out.AddFormatted(" ;; object: %s", *obj_name); |
| 222 } else if (rmode == external_reference) { | 222 } else if (rmode == RelocInfo::EXTERNAL_REFERENCE) { |
| 223 const char* reference_name = | 223 const char* reference_name = |
| 224 ref_encoder.NameOfAddress(*relocinfo.target_reference_address()); | 224 ref_encoder.NameOfAddress(*relocinfo.target_reference_address()); |
| 225 out.AddFormatted(" ;; external reference (%s)", reference_name); | 225 out.AddFormatted(" ;; external reference (%s)", reference_name); |
| 226 } else if (is_code_target(rmode)) { | 226 } else if (RelocInfo::IsCodeTarget(rmode)) { |
| 227 out.AddFormatted(" ;; code:"); | 227 out.AddFormatted(" ;; code:"); |
| 228 if (rmode == js_construct_call) { | 228 if (rmode == RelocInfo::CONSTRUCT_CALL) { |
| 229 out.AddFormatted(" constructor,"); | 229 out.AddFormatted(" constructor,"); |
| 230 } | 230 } |
| 231 Code* code = Debug::GetCodeTarget(relocinfo.target_address()); | 231 Code* code = Debug::GetCodeTarget(relocinfo.target_address()); |
| 232 Code::Kind kind = code->kind(); | 232 Code::Kind kind = code->kind(); |
| 233 if (code->is_inline_cache_stub()) { | 233 if (code->is_inline_cache_stub()) { |
| 234 if (rmode == code_target_context) { | 234 if (rmode == RelocInfo::CODE_TARGET_CONTEXT) { |
| 235 out.AddFormatted(" contextual,"); | 235 out.AddFormatted(" contextual,"); |
| 236 } | 236 } |
| 237 InlineCacheState ic_state = code->ic_state(); | 237 InlineCacheState ic_state = code->ic_state(); |
| 238 out.AddFormatted(" %s, %s", Code::Kind2String(kind), | 238 out.AddFormatted(" %s, %s", Code::Kind2String(kind), |
| 239 Code::ICState2String(ic_state)); | 239 Code::ICState2String(ic_state)); |
| 240 if (kind == Code::CALL_IC) { | 240 if (kind == Code::CALL_IC) { |
| 241 out.AddFormatted(", argc = %d", code->arguments_count()); | 241 out.AddFormatted(", argc = %d", code->arguments_count()); |
| 242 } | 242 } |
| 243 } else if (kind == Code::STUB) { | 243 } else if (kind == Code::STUB) { |
| 244 // Reverse lookup required as the minor key cannot be retrieved | 244 // Reverse lookup required as the minor key cannot be retrieved |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 300 |
| 301 #else // ENABLE_DISASSEMBLER | 301 #else // ENABLE_DISASSEMBLER |
| 302 | 302 |
| 303 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} | 303 void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} |
| 304 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } | 304 int Disassembler::Decode(FILE* f, byte* begin, byte* end) { return 0; } |
| 305 void Disassembler::Decode(FILE* f, Code* code) {} | 305 void Disassembler::Decode(FILE* f, Code* code) {} |
| 306 | 306 |
| 307 #endif // ENABLE_DISASSEMBLER | 307 #endif // ENABLE_DISASSEMBLER |
| 308 | 308 |
| 309 } } // namespace v8::internal | 309 } } // namespace v8::internal |
| OLD | NEW |