Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Side by Side Diff: src/safepoint-table.cc

Issue 363323003: More OStreamsUse OStreams more often. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased and polished. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/safepoint-table.h ('k') | src/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 SafepointEntry SafepointTable::FindEntry(Address pc) const { 53 SafepointEntry SafepointTable::FindEntry(Address pc) const {
54 unsigned pc_offset = static_cast<unsigned>(pc - code_->instruction_start()); 54 unsigned pc_offset = static_cast<unsigned>(pc - code_->instruction_start());
55 for (unsigned i = 0; i < length(); i++) { 55 for (unsigned i = 0; i < length(); i++) {
56 // TODO(kasperl): Replace the linear search with binary search. 56 // TODO(kasperl): Replace the linear search with binary search.
57 if (GetPcOffset(i) == pc_offset) return GetEntry(i); 57 if (GetPcOffset(i) == pc_offset) return GetEntry(i);
58 } 58 }
59 return SafepointEntry(); 59 return SafepointEntry();
60 } 60 }
61 61
62 62
63 void SafepointTable::PrintEntry(unsigned index, FILE* out) const { 63 void SafepointTable::PrintEntry(unsigned index, OStream& os) const { // NOLINT
64 disasm::NameConverter converter; 64 disasm::NameConverter converter;
65 SafepointEntry entry = GetEntry(index); 65 SafepointEntry entry = GetEntry(index);
66 uint8_t* bits = entry.bits(); 66 uint8_t* bits = entry.bits();
67 67
68 // Print the stack slot bits. 68 // Print the stack slot bits.
69 if (entry_size_ > 0) { 69 if (entry_size_ > 0) {
70 ASSERT(IsAligned(kNumSafepointRegisters, kBitsPerByte)); 70 ASSERT(IsAligned(kNumSafepointRegisters, kBitsPerByte));
71 const int first = kNumSafepointRegisters >> kBitsPerByteLog2; 71 const int first = kNumSafepointRegisters >> kBitsPerByteLog2;
72 int last = entry_size_ - 1; 72 int last = entry_size_ - 1;
73 for (int i = first; i < last; i++) PrintBits(out, bits[i], kBitsPerByte); 73 for (int i = first; i < last; i++) PrintBits(os, bits[i], kBitsPerByte);
74 int last_bits = code_->stack_slots() - ((last - first) * kBitsPerByte); 74 int last_bits = code_->stack_slots() - ((last - first) * kBitsPerByte);
75 PrintBits(out, bits[last], last_bits); 75 PrintBits(os, bits[last], last_bits);
76 76
77 // Print the registers (if any). 77 // Print the registers (if any).
78 if (!entry.HasRegisters()) return; 78 if (!entry.HasRegisters()) return;
79 for (int j = 0; j < kNumSafepointRegisters; j++) { 79 for (int j = 0; j < kNumSafepointRegisters; j++) {
80 if (entry.HasRegisterAt(j)) { 80 if (entry.HasRegisterAt(j)) {
81 PrintF(out, " | %s", converter.NameOfCPURegister(j)); 81 os << " | " << converter.NameOfCPURegister(j);
82 } 82 }
83 } 83 }
84 } 84 }
85 } 85 }
86 86
87 87
88 void SafepointTable::PrintBits(FILE* out, uint8_t byte, int digits) { 88 void SafepointTable::PrintBits(OStream& os, // NOLINT
89 uint8_t byte, int digits) {
89 ASSERT(digits >= 0 && digits <= kBitsPerByte); 90 ASSERT(digits >= 0 && digits <= kBitsPerByte);
90 for (int i = 0; i < digits; i++) { 91 for (int i = 0; i < digits; i++) {
91 PrintF(out, "%c", ((byte & (1 << i)) == 0) ? '0' : '1'); 92 os << (((byte & (1 << i)) == 0) ? "0" : "1");
92 } 93 }
93 } 94 }
94 95
95 96
96 void Safepoint::DefinePointerRegister(Register reg, Zone* zone) { 97 void Safepoint::DefinePointerRegister(Register reg, Zone* zone) {
97 registers_->Add(reg.code(), zone); 98 registers_->Add(reg.code(), zone);
98 } 99 }
99 100
100 101
101 Safepoint SafepointTableBuilder::DefineSafepoint( 102 Safepoint SafepointTableBuilder::DefineSafepoint(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 unsigned index) { 206 unsigned index) {
206 uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index); 207 uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index);
207 encoding |= SafepointEntry::ArgumentsField::encode(info.arguments); 208 encoding |= SafepointEntry::ArgumentsField::encode(info.arguments);
208 encoding |= SafepointEntry::SaveDoublesField::encode(info.has_doubles); 209 encoding |= SafepointEntry::SaveDoublesField::encode(info.has_doubles);
209 return encoding; 210 return encoding;
210 } 211 }
211 212
212 213
213 214
214 } } // namespace v8::internal 215 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/safepoint-table.h ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698