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

Side by Side Diff: src/string-stream.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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/string-search.h ('k') | src/strtod.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/string-stream.h" 5 #include "src/string-stream.h"
6 6
7 #include "src/handles-inl.h" 7 #include "src/handles-inl.h"
8 #include "src/prototype.h" 8 #include "src/prototype.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 static const int kMentionedObjectCacheMaxSize = 256; 13 static const int kMentionedObjectCacheMaxSize = 256;
14 14
15 char* HeapStringAllocator::allocate(unsigned bytes) { 15 char* HeapStringAllocator::allocate(unsigned bytes) {
16 space_ = NewArray<char>(bytes); 16 space_ = NewArray<char>(bytes);
17 return space_; 17 return space_;
18 } 18 }
19 19
20 20
21 bool StringStream::Put(char c) { 21 bool StringStream::Put(char c) {
22 if (full()) return false; 22 if (full()) return false;
23 ASSERT(length_ < capacity_); 23 DCHECK(length_ < capacity_);
24 // Since the trailing '\0' is not accounted for in length_ fullness is 24 // Since the trailing '\0' is not accounted for in length_ fullness is
25 // indicated by a difference of 1 between length_ and capacity_. Thus when 25 // indicated by a difference of 1 between length_ and capacity_. Thus when
26 // reaching a difference of 2 we need to grow the buffer. 26 // reaching a difference of 2 we need to grow the buffer.
27 if (length_ == capacity_ - 2) { 27 if (length_ == capacity_ - 2) {
28 unsigned new_capacity = capacity_; 28 unsigned new_capacity = capacity_;
29 char* new_buffer = allocator_->grow(&new_capacity); 29 char* new_buffer = allocator_->grow(&new_capacity);
30 if (new_capacity > capacity_) { 30 if (new_capacity > capacity_) {
31 capacity_ = new_capacity; 31 capacity_ = new_capacity;
32 buffer_ = new_buffer; 32 buffer_ = new_buffer;
33 } else { 33 } else {
34 // Reached the end of the available buffer. 34 // Reached the end of the available buffer.
35 ASSERT(capacity_ >= 5); 35 DCHECK(capacity_ >= 5);
36 length_ = capacity_ - 1; // Indicate fullness of the stream. 36 length_ = capacity_ - 1; // Indicate fullness of the stream.
37 buffer_[length_ - 4] = '.'; 37 buffer_[length_ - 4] = '.';
38 buffer_[length_ - 3] = '.'; 38 buffer_[length_ - 3] = '.';
39 buffer_[length_ - 2] = '.'; 39 buffer_[length_ - 2] = '.';
40 buffer_[length_ - 1] = '\n'; 40 buffer_[length_ - 1] = '\n';
41 buffer_[length_] = '\0'; 41 buffer_[length_] = '\0';
42 return false; 42 return false;
43 } 43 }
44 } 44 }
45 buffer_[length_] = c; 45 buffer_[length_] = c;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 temp[format_length++] = format[offset++]; 83 temp[format_length++] = format[offset++];
84 if (offset >= format.length()) 84 if (offset >= format.length())
85 return; 85 return;
86 char type = format[offset]; 86 char type = format[offset];
87 temp[format_length++] = type; 87 temp[format_length++] = type;
88 temp[format_length] = '\0'; 88 temp[format_length] = '\0';
89 offset++; 89 offset++;
90 FmtElm current = elms[elm++]; 90 FmtElm current = elms[elm++];
91 switch (type) { 91 switch (type) {
92 case 's': { 92 case 's': {
93 ASSERT_EQ(FmtElm::C_STR, current.type_); 93 DCHECK_EQ(FmtElm::C_STR, current.type_);
94 const char* value = current.data_.u_c_str_; 94 const char* value = current.data_.u_c_str_;
95 Add(value); 95 Add(value);
96 break; 96 break;
97 } 97 }
98 case 'w': { 98 case 'w': {
99 ASSERT_EQ(FmtElm::LC_STR, current.type_); 99 DCHECK_EQ(FmtElm::LC_STR, current.type_);
100 Vector<const uc16> value = *current.data_.u_lc_str_; 100 Vector<const uc16> value = *current.data_.u_lc_str_;
101 for (int i = 0; i < value.length(); i++) 101 for (int i = 0; i < value.length(); i++)
102 Put(static_cast<char>(value[i])); 102 Put(static_cast<char>(value[i]));
103 break; 103 break;
104 } 104 }
105 case 'o': { 105 case 'o': {
106 ASSERT_EQ(FmtElm::OBJ, current.type_); 106 DCHECK_EQ(FmtElm::OBJ, current.type_);
107 Object* obj = current.data_.u_obj_; 107 Object* obj = current.data_.u_obj_;
108 PrintObject(obj); 108 PrintObject(obj);
109 break; 109 break;
110 } 110 }
111 case 'k': { 111 case 'k': {
112 ASSERT_EQ(FmtElm::INT, current.type_); 112 DCHECK_EQ(FmtElm::INT, current.type_);
113 int value = current.data_.u_int_; 113 int value = current.data_.u_int_;
114 if (0x20 <= value && value <= 0x7F) { 114 if (0x20 <= value && value <= 0x7F) {
115 Put(value); 115 Put(value);
116 } else if (value <= 0xff) { 116 } else if (value <= 0xff) {
117 Add("\\x%02x", value); 117 Add("\\x%02x", value);
118 } else { 118 } else {
119 Add("\\u%04x", value); 119 Add("\\u%04x", value);
120 } 120 }
121 break; 121 break;
122 } 122 }
(...skipping 27 matching lines...) Expand all
150 Add(formatted.start()); 150 Add(formatted.start());
151 break; 151 break;
152 } 152 }
153 default: 153 default:
154 UNREACHABLE(); 154 UNREACHABLE();
155 break; 155 break;
156 } 156 }
157 } 157 }
158 158
159 // Verify that the buffer is 0-terminated 159 // Verify that the buffer is 0-terminated
160 ASSERT(buffer_[length_] == '\0'); 160 DCHECK(buffer_[length_] == '\0');
161 } 161 }
162 162
163 163
164 void StringStream::PrintObject(Object* o) { 164 void StringStream::PrintObject(Object* o) {
165 o->ShortPrint(this); 165 o->ShortPrint(this);
166 if (o->IsString()) { 166 if (o->IsString()) {
167 if (String::cast(o)->length() <= String::kMaxShortPrintLength) { 167 if (String::cast(o)->length() <= String::kMaxShortPrintLength) {
168 return; 168 return;
169 } 169 }
170 } else if (o->IsNumber() || o->IsOddball()) { 170 } else if (o->IsNumber() || o->IsOddball()) {
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } 552 }
553 MemCopy(new_space, space_, *bytes); 553 MemCopy(new_space, space_, *bytes);
554 *bytes = new_bytes; 554 *bytes = new_bytes;
555 DeleteArray(space_); 555 DeleteArray(space_);
556 space_ = new_space; 556 space_ = new_space;
557 return new_space; 557 return new_space;
558 } 558 }
559 559
560 560
561 } } // namespace v8::internal 561 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/string-search.h ('k') | src/strtod.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698