| 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/v8.h" | 5 #include "src/v8.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.h" | 9 #include "src/debug.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer; | 78 v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer; |
| 79 StringBuilder out(out_buffer.start(), out_buffer.length()); | 79 StringBuilder out(out_buffer.start(), out_buffer.length()); |
| 80 byte* pc = begin; | 80 byte* pc = begin; |
| 81 disasm::Disassembler d(converter); | 81 disasm::Disassembler d(converter); |
| 82 RelocIterator* it = NULL; | 82 RelocIterator* it = NULL; |
| 83 if (converter.code() != NULL) { | 83 if (converter.code() != NULL) { |
| 84 it = new RelocIterator(converter.code()); | 84 it = new RelocIterator(converter.code()); |
| 85 } else { | 85 } else { |
| 86 // No relocation information when printing code stubs. | 86 // No relocation information when printing code stubs. |
| 87 } | 87 } |
| 88 #if !V8_TARGET_ARCH_PPC | |
| 89 int constants = -1; // no constants being decoded at the start | 88 int constants = -1; // no constants being decoded at the start |
| 90 #endif | |
| 91 | 89 |
| 92 while (pc < end) { | 90 while (pc < end) { |
| 93 // First decode instruction so that we know its length. | 91 // First decode instruction so that we know its length. |
| 94 byte* prev_pc = pc; | 92 byte* prev_pc = pc; |
| 95 #if !V8_TARGET_ARCH_PPC | |
| 96 if (constants > 0) { | 93 if (constants > 0) { |
| 97 SNPrintF(decode_buffer, | 94 SNPrintF(decode_buffer, |
| 98 "%08x constant", | 95 "%08x constant", |
| 99 *reinterpret_cast<int32_t*>(pc)); | 96 *reinterpret_cast<int32_t*>(pc)); |
| 100 constants--; | 97 constants--; |
| 101 pc += 4; | 98 pc += 4; |
| 102 } else { | 99 } else { |
| 103 int num_const = d.ConstantPoolSizeAt(pc); | 100 int num_const = d.ConstantPoolSizeAt(pc); |
| 104 if (num_const >= 0) { | 101 if (num_const >= 0) { |
| 105 SNPrintF(decode_buffer, | 102 SNPrintF(decode_buffer, |
| 106 "%08x constant pool begin", | 103 "%08x constant pool begin", |
| 107 *reinterpret_cast<int32_t*>(pc)); | 104 *reinterpret_cast<int32_t*>(pc)); |
| 108 constants = num_const; | 105 constants = num_const; |
| 109 pc += 4; | 106 pc += 4; |
| 110 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && | 107 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && |
| 111 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { | 108 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { |
| 112 // raw pointer embedded in code stream, e.g., jump table | 109 // raw pointer embedded in code stream, e.g., jump table |
| 113 byte* ptr = *reinterpret_cast<byte**>(pc); | 110 byte* ptr = *reinterpret_cast<byte**>(pc); |
| 114 SNPrintF(decode_buffer, | 111 SNPrintF(decode_buffer, |
| 115 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, | 112 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, |
| 116 reinterpret_cast<intptr_t>(ptr), | 113 reinterpret_cast<intptr_t>(ptr), |
| 117 ptr - begin); | 114 ptr - begin); |
| 118 pc += sizeof(ptr); | 115 pc += sizeof(ptr); |
| 119 } else { | 116 } else { |
| 120 decode_buffer[0] = '\0'; | 117 decode_buffer[0] = '\0'; |
| 121 pc += d.InstructionDecode(decode_buffer, pc); | 118 pc += d.InstructionDecode(decode_buffer, pc); |
| 122 } | 119 } |
| 123 } | 120 } |
| 124 #else // !V8_TARGET_ARCH_PPC | |
| 125 #if ABI_USES_FUNCTION_DESCRIPTORS || V8_OOL_CONSTANT_POOL | |
| 126 // Function descriptors are specially decoded and skipped. | |
| 127 // Other internal references (load of ool constant pool pointer) | |
| 128 // are not since they are a encoded as a regular mov sequence. | |
| 129 int skip; | |
| 130 if (it != NULL && !it->done() && it->rinfo()->pc() == pc && | |
| 131 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE && | |
| 132 (skip = Assembler::DecodeInternalReference(decode_buffer, pc))) { | |
| 133 pc += skip; | |
| 134 } else { | |
| 135 decode_buffer[0] = '\0'; | |
| 136 pc += d.InstructionDecode(decode_buffer, pc); | |
| 137 } | |
| 138 #else | |
| 139 decode_buffer[0] = '\0'; | |
| 140 pc += d.InstructionDecode(decode_buffer, pc); | |
| 141 #endif // ABI_USES_FUNCTION_DESCRIPTORS || V8_OOL_CONSTANT_POOL | |
| 142 #endif // !V8_TARGET_ARCH_PPC | |
| 143 | 121 |
| 144 // Collect RelocInfo for this instruction (prev_pc .. pc-1) | 122 // Collect RelocInfo for this instruction (prev_pc .. pc-1) |
| 145 List<const char*> comments(4); | 123 List<const char*> comments(4); |
| 146 List<byte*> pcs(1); | 124 List<byte*> pcs(1); |
| 147 List<RelocInfo::Mode> rmodes(1); | 125 List<RelocInfo::Mode> rmodes(1); |
| 148 List<intptr_t> datas(1); | 126 List<intptr_t> datas(1); |
| 149 if (it != NULL) { | 127 if (it != NULL) { |
| 150 while (!it->done() && it->rinfo()->pc() < pc) { | 128 while (!it->done() && it->rinfo()->pc() < pc) { |
| 151 if (RelocInfo::IsComment(it->rinfo()->rmode())) { | 129 if (RelocInfo::IsComment(it->rinfo()->rmode())) { |
| 152 // For comments just collect the text. | 130 // For comments just collect the text. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 #else // ENABLE_DISASSEMBLER | 289 #else // ENABLE_DISASSEMBLER |
| 312 | 290 |
| 313 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, | 291 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, |
| 314 byte* end, Code* code) { | 292 byte* end, Code* code) { |
| 315 return 0; | 293 return 0; |
| 316 } | 294 } |
| 317 | 295 |
| 318 #endif // ENABLE_DISASSEMBLER | 296 #endif // ENABLE_DISASSEMBLER |
| 319 | 297 |
| 320 } } // namespace v8::internal | 298 } } // namespace v8::internal |
| OLD | NEW |