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/safepoint-table.h" | 7 #include "src/safepoint-table.h" |
8 | 8 |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/disasm.h" | 10 #include "src/disasm.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 SafepointEntry SafepointTable::FindEntry(Address pc) const { | 54 SafepointEntry SafepointTable::FindEntry(Address pc) const { |
55 unsigned pc_offset = static_cast<unsigned>(pc - code_->instruction_start()); | 55 unsigned pc_offset = static_cast<unsigned>(pc - code_->instruction_start()); |
56 for (unsigned i = 0; i < length(); i++) { | 56 for (unsigned i = 0; i < length(); i++) { |
57 // TODO(kasperl): Replace the linear search with binary search. | 57 // TODO(kasperl): Replace the linear search with binary search. |
58 if (GetPcOffset(i) == pc_offset) return GetEntry(i); | 58 if (GetPcOffset(i) == pc_offset) return GetEntry(i); |
59 } | 59 } |
60 return SafepointEntry(); | 60 return SafepointEntry(); |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 void SafepointTable::PrintEntry(unsigned index, OStream& os) const { // NOLINT | 64 void SafepointTable::PrintEntry(unsigned index, |
| 65 std::ostream& os) const { // NOLINT |
65 disasm::NameConverter converter; | 66 disasm::NameConverter converter; |
66 SafepointEntry entry = GetEntry(index); | 67 SafepointEntry entry = GetEntry(index); |
67 uint8_t* bits = entry.bits(); | 68 uint8_t* bits = entry.bits(); |
68 | 69 |
69 // Print the stack slot bits. | 70 // Print the stack slot bits. |
70 if (entry_size_ > 0) { | 71 if (entry_size_ > 0) { |
71 DCHECK(IsAligned(kNumSafepointRegisters, kBitsPerByte)); | 72 DCHECK(IsAligned(kNumSafepointRegisters, kBitsPerByte)); |
72 const int first = kNumSafepointRegisters >> kBitsPerByteLog2; | 73 const int first = kNumSafepointRegisters >> kBitsPerByteLog2; |
73 int last = entry_size_ - 1; | 74 int last = entry_size_ - 1; |
74 for (int i = first; i < last; i++) PrintBits(os, bits[i], kBitsPerByte); | 75 for (int i = first; i < last; i++) PrintBits(os, bits[i], kBitsPerByte); |
75 int last_bits = code_->stack_slots() - ((last - first) * kBitsPerByte); | 76 int last_bits = code_->stack_slots() - ((last - first) * kBitsPerByte); |
76 PrintBits(os, bits[last], last_bits); | 77 PrintBits(os, bits[last], last_bits); |
77 | 78 |
78 // Print the registers (if any). | 79 // Print the registers (if any). |
79 if (!entry.HasRegisters()) return; | 80 if (!entry.HasRegisters()) return; |
80 for (int j = 0; j < kNumSafepointRegisters; j++) { | 81 for (int j = 0; j < kNumSafepointRegisters; j++) { |
81 if (entry.HasRegisterAt(j)) { | 82 if (entry.HasRegisterAt(j)) { |
82 os << " | " << converter.NameOfCPURegister(j); | 83 os << " | " << converter.NameOfCPURegister(j); |
83 } | 84 } |
84 } | 85 } |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 | 89 |
89 void SafepointTable::PrintBits(OStream& os, // NOLINT | 90 void SafepointTable::PrintBits(std::ostream& os, // NOLINT |
90 uint8_t byte, int digits) { | 91 uint8_t byte, int digits) { |
91 DCHECK(digits >= 0 && digits <= kBitsPerByte); | 92 DCHECK(digits >= 0 && digits <= kBitsPerByte); |
92 for (int i = 0; i < digits; i++) { | 93 for (int i = 0; i < digits; i++) { |
93 os << (((byte & (1 << i)) == 0) ? "0" : "1"); | 94 os << (((byte & (1 << i)) == 0) ? "0" : "1"); |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 | 98 |
98 void Safepoint::DefinePointerRegister(Register reg, Zone* zone) { | 99 void Safepoint::DefinePointerRegister(Register reg, Zone* zone) { |
99 registers_->Add(reg.code(), zone); | 100 registers_->Add(reg.code(), zone); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 unsigned index) { | 208 unsigned index) { |
208 uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index); | 209 uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index); |
209 encoding |= SafepointEntry::ArgumentsField::encode(info.arguments); | 210 encoding |= SafepointEntry::ArgumentsField::encode(info.arguments); |
210 encoding |= SafepointEntry::SaveDoublesField::encode(info.has_doubles); | 211 encoding |= SafepointEntry::SaveDoublesField::encode(info.has_doubles); |
211 return encoding; | 212 return encoding; |
212 } | 213 } |
213 | 214 |
214 | 215 |
215 | 216 |
216 } } // namespace v8::internal | 217 } } // namespace v8::internal |
OLD | NEW |