OLD | NEW |
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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/handles-inl.h" | 9 #include "src/handles-inl.h" |
10 #include "src/prototype.h" | 10 #include "src/prototype.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if (debug_object_cache->length() < kMentionedObjectCacheMaxSize) { | 197 if (debug_object_cache->length() < kMentionedObjectCacheMaxSize) { |
198 Add("#%d#", debug_object_cache->length()); | 198 Add("#%d#", debug_object_cache->length()); |
199 debug_object_cache->Add(HeapObject::cast(o)); | 199 debug_object_cache->Add(HeapObject::cast(o)); |
200 } else { | 200 } else { |
201 Add("@%p", o); | 201 Add("@%p", o); |
202 } | 202 } |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 void StringStream::Add(const char* format) { | |
208 Add(CStrVector(format)); | |
209 } | |
210 | |
211 | |
212 void StringStream::Add(Vector<const char> format) { | |
213 Add(format, Vector<FmtElm>::empty()); | |
214 } | |
215 | |
216 | |
217 void StringStream::Add(const char* format, FmtElm arg0) { | |
218 const char argc = 1; | |
219 FmtElm argv[argc] = { arg0 }; | |
220 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); | |
221 } | |
222 | |
223 | |
224 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1) { | |
225 const char argc = 2; | |
226 FmtElm argv[argc] = { arg0, arg1 }; | |
227 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); | |
228 } | |
229 | |
230 | |
231 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, | |
232 FmtElm arg2) { | |
233 const char argc = 3; | |
234 FmtElm argv[argc] = { arg0, arg1, arg2 }; | |
235 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); | |
236 } | |
237 | |
238 | |
239 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, | |
240 FmtElm arg2, FmtElm arg3) { | |
241 const char argc = 4; | |
242 FmtElm argv[argc] = { arg0, arg1, arg2, arg3 }; | |
243 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); | |
244 } | |
245 | |
246 | |
247 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, | |
248 FmtElm arg2, FmtElm arg3, FmtElm arg4) { | |
249 const char argc = 5; | |
250 FmtElm argv[argc] = { arg0, arg1, arg2, arg3, arg4 }; | |
251 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); | |
252 } | |
253 | |
254 std::unique_ptr<char[]> StringStream::ToCString() const { | 207 std::unique_ptr<char[]> StringStream::ToCString() const { |
255 char* str = NewArray<char>(length_ + 1); | 208 char* str = NewArray<char>(length_ + 1); |
256 MemCopy(str, buffer_, length_); | 209 MemCopy(str, buffer_, length_); |
257 str[length_] = '\0'; | 210 str[length_] = '\0'; |
258 return std::unique_ptr<char[]>(str); | 211 return std::unique_ptr<char[]>(str); |
259 } | 212 } |
260 | 213 |
261 | 214 |
262 void StringStream::Log(Isolate* isolate) { | 215 void StringStream::Log(Isolate* isolate) { |
263 LOG(isolate, StringEvent("StackDump", buffer_)); | 216 LOG(isolate, StringEvent("StackDump", buffer_)); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 MemCopy(new_space, space_, *bytes); | 532 MemCopy(new_space, space_, *bytes); |
580 *bytes = new_bytes; | 533 *bytes = new_bytes; |
581 DeleteArray(space_); | 534 DeleteArray(space_); |
582 space_ = new_space; | 535 space_ = new_space; |
583 return new_space; | 536 return new_space; |
584 } | 537 } |
585 | 538 |
586 | 539 |
587 } // namespace internal | 540 } // namespace internal |
588 } // namespace v8 | 541 } // namespace v8 |
OLD | NEW |