| 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 |
| 88 int constants = -1; // no constants being decoded at the start | 89 int constants = -1; // no constants being decoded at the start |
| 90 #endif |
| 89 | 91 |
| 90 while (pc < end) { | 92 while (pc < end) { |
| 91 // First decode instruction so that we know its length. | 93 // First decode instruction so that we know its length. |
| 92 byte* prev_pc = pc; | 94 byte* prev_pc = pc; |
| 95 #if !V8_TARGET_ARCH_PPC |
| 93 if (constants > 0) { | 96 if (constants > 0) { |
| 94 SNPrintF(decode_buffer, | 97 SNPrintF(decode_buffer, |
| 95 "%08x constant", | 98 "%08x constant", |
| 96 *reinterpret_cast<int32_t*>(pc)); | 99 *reinterpret_cast<int32_t*>(pc)); |
| 97 constants--; | 100 constants--; |
| 98 pc += 4; | 101 pc += 4; |
| 99 } else { | 102 } else { |
| 100 int num_const = d.ConstantPoolSizeAt(pc); | 103 int num_const = d.ConstantPoolSizeAt(pc); |
| 101 if (num_const >= 0) { | 104 if (num_const >= 0) { |
| 102 SNPrintF(decode_buffer, | 105 SNPrintF(decode_buffer, |
| 103 "%08x constant pool begin", | 106 "%08x constant pool begin", |
| 104 *reinterpret_cast<int32_t*>(pc)); | 107 *reinterpret_cast<int32_t*>(pc)); |
| 105 constants = num_const; | 108 constants = num_const; |
| 106 pc += 4; | 109 pc += 4; |
| 107 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && | 110 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && |
| 108 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { | 111 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { |
| 109 // raw pointer embedded in code stream, e.g., jump table | 112 // raw pointer embedded in code stream, e.g., jump table |
| 110 byte* ptr = *reinterpret_cast<byte**>(pc); | 113 byte* ptr = *reinterpret_cast<byte**>(pc); |
| 111 SNPrintF(decode_buffer, | 114 SNPrintF(decode_buffer, |
| 112 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, | 115 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, |
| 113 reinterpret_cast<intptr_t>(ptr), | 116 reinterpret_cast<intptr_t>(ptr), |
| 114 ptr - begin); | 117 ptr - begin); |
| 115 pc += 4; | 118 pc += 4; |
| 116 } else { | 119 } else { |
| 117 decode_buffer[0] = '\0'; | 120 decode_buffer[0] = '\0'; |
| 118 pc += d.InstructionDecode(decode_buffer, pc); | 121 pc += d.InstructionDecode(decode_buffer, pc); |
| 119 } | 122 } |
| 120 } | 123 } |
| 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 |
| 121 | 143 |
| 122 // Collect RelocInfo for this instruction (prev_pc .. pc-1) | 144 // Collect RelocInfo for this instruction (prev_pc .. pc-1) |
| 123 List<const char*> comments(4); | 145 List<const char*> comments(4); |
| 124 List<byte*> pcs(1); | 146 List<byte*> pcs(1); |
| 125 List<RelocInfo::Mode> rmodes(1); | 147 List<RelocInfo::Mode> rmodes(1); |
| 126 List<intptr_t> datas(1); | 148 List<intptr_t> datas(1); |
| 127 if (it != NULL) { | 149 if (it != NULL) { |
| 128 while (!it->done() && it->rinfo()->pc() < pc) { | 150 while (!it->done() && it->rinfo()->pc() < pc) { |
| 129 if (RelocInfo::IsComment(it->rinfo()->rmode())) { | 151 if (RelocInfo::IsComment(it->rinfo()->rmode())) { |
| 130 // For comments just collect the text. | 152 // For comments just collect the text. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 #else // ENABLE_DISASSEMBLER | 306 #else // ENABLE_DISASSEMBLER |
| 285 | 307 |
| 286 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, | 308 int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin, |
| 287 byte* end, Code* code) { | 309 byte* end, Code* code) { |
| 288 return 0; | 310 return 0; |
| 289 } | 311 } |
| 290 | 312 |
| 291 #endif // ENABLE_DISASSEMBLER | 313 #endif // ENABLE_DISASSEMBLER |
| 292 | 314 |
| 293 } } // namespace v8::internal | 315 } } // namespace v8::internal |
| OLD | NEW |