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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 private: | 43 private: |
44 Code* code_; | 44 Code* code_; |
45 | 45 |
46 EmbeddedVector<char, 128> v8_buffer_; | 46 EmbeddedVector<char, 128> v8_buffer_; |
47 }; | 47 }; |
48 | 48 |
49 | 49 |
50 const char* V8NameConverter::NameOfAddress(byte* pc) const { | 50 const char* V8NameConverter::NameOfAddress(byte* pc) const { |
51 const char* name = code_->GetIsolate()->builtins()->Lookup(pc); | 51 const char* name = code_->GetIsolate()->builtins()->Lookup(pc); |
52 if (name != NULL) { | 52 if (name != NULL) { |
53 OS::SNPrintF(v8_buffer_, "%s (%p)", name, pc); | 53 SNPrintF(v8_buffer_, "%s (%p)", name, pc); |
54 return v8_buffer_.start(); | 54 return v8_buffer_.start(); |
55 } | 55 } |
56 | 56 |
57 if (code_ != NULL) { | 57 if (code_ != NULL) { |
58 int offs = static_cast<int>(pc - code_->instruction_start()); | 58 int offs = static_cast<int>(pc - code_->instruction_start()); |
59 // print as code offset, if it seems reasonable | 59 // print as code offset, if it seems reasonable |
60 if (0 <= offs && offs < code_->instruction_size()) { | 60 if (0 <= offs && offs < code_->instruction_size()) { |
61 OS::SNPrintF(v8_buffer_, "%d (%p)", offs, pc); | 61 SNPrintF(v8_buffer_, "%d (%p)", offs, pc); |
62 return v8_buffer_.start(); | 62 return v8_buffer_.start(); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 return disasm::NameConverter::NameOfAddress(pc); | 66 return disasm::NameConverter::NameOfAddress(pc); |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 const char* V8NameConverter::NameInCode(byte* addr) const { | 70 const char* V8NameConverter::NameInCode(byte* addr) const { |
71 // The V8NameConverter is used for well known code, so we can "safely" | 71 // The V8NameConverter is used for well known code, so we can "safely" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 it = new RelocIterator(converter.code()); | 107 it = new RelocIterator(converter.code()); |
108 } else { | 108 } else { |
109 // No relocation information when printing code stubs. | 109 // No relocation information when printing code stubs. |
110 } | 110 } |
111 int constants = -1; // no constants being decoded at the start | 111 int constants = -1; // no constants being decoded at the start |
112 | 112 |
113 while (pc < end) { | 113 while (pc < end) { |
114 // First decode instruction so that we know its length. | 114 // First decode instruction so that we know its length. |
115 byte* prev_pc = pc; | 115 byte* prev_pc = pc; |
116 if (constants > 0) { | 116 if (constants > 0) { |
117 OS::SNPrintF(decode_buffer, | 117 SNPrintF(decode_buffer, |
118 "%08x constant", | 118 "%08x constant", |
119 *reinterpret_cast<int32_t*>(pc)); | 119 *reinterpret_cast<int32_t*>(pc)); |
120 constants--; | 120 constants--; |
121 pc += 4; | 121 pc += 4; |
122 } else { | 122 } else { |
123 int num_const = d.ConstantPoolSizeAt(pc); | 123 int num_const = d.ConstantPoolSizeAt(pc); |
124 if (num_const >= 0) { | 124 if (num_const >= 0) { |
125 OS::SNPrintF(decode_buffer, | 125 SNPrintF(decode_buffer, |
126 "%08x constant pool begin", | 126 "%08x constant pool begin", |
127 *reinterpret_cast<int32_t*>(pc)); | 127 *reinterpret_cast<int32_t*>(pc)); |
128 constants = num_const; | 128 constants = num_const; |
129 pc += 4; | 129 pc += 4; |
130 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && | 130 } else if (it != NULL && !it->done() && it->rinfo()->pc() == pc && |
131 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { | 131 it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) { |
132 // raw pointer embedded in code stream, e.g., jump table | 132 // raw pointer embedded in code stream, e.g., jump table |
133 byte* ptr = *reinterpret_cast<byte**>(pc); | 133 byte* ptr = *reinterpret_cast<byte**>(pc); |
134 OS::SNPrintF(decode_buffer, | 134 SNPrintF(decode_buffer, |
135 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, | 135 "%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR, |
136 ptr, | 136 reinterpret_cast<intptr_t>(ptr), |
137 ptr - begin); | 137 ptr - begin); |
138 pc += 4; | 138 pc += 4; |
139 } else { | 139 } else { |
140 decode_buffer[0] = '\0'; | 140 decode_buffer[0] = '\0'; |
141 pc += d.InstructionDecode(decode_buffer, pc); | 141 pc += d.InstructionDecode(decode_buffer, pc); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 // Collect RelocInfo for this instruction (prev_pc .. pc-1) | 145 // Collect RelocInfo for this instruction (prev_pc .. pc-1) |
146 List<const char*> comments(4); | 146 List<const char*> comments(4); |
147 List<byte*> pcs(1); | 147 List<byte*> pcs(1); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) { | 335 int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) { |
336 return 0; | 336 return 0; |
337 } | 337 } |
338 | 338 |
339 | 339 |
340 void Disassembler::Decode(FILE* f, Code* code) {} | 340 void Disassembler::Decode(FILE* f, Code* code) {} |
341 | 341 |
342 #endif // ENABLE_DISASSEMBLER | 342 #endif // ENABLE_DISASSEMBLER |
343 | 343 |
344 } } // namespace v8::internal | 344 } } // namespace v8::internal |
OLD | NEW |