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 "string-stream.h" | 5 #include "string-stream.h" |
6 | 6 |
7 #include "handles-inl.h" | 7 #include "handles-inl.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, | 230 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, |
231 FmtElm arg2, FmtElm arg3, FmtElm arg4) { | 231 FmtElm arg2, FmtElm arg3, FmtElm arg4) { |
232 const char argc = 5; | 232 const char argc = 5; |
233 FmtElm argv[argc] = { arg0, arg1, arg2, arg3, arg4 }; | 233 FmtElm argv[argc] = { arg0, arg1, arg2, arg3, arg4 }; |
234 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); | 234 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 SmartArrayPointer<const char> StringStream::ToCString() const { | 238 SmartArrayPointer<const char> StringStream::ToCString() const { |
239 char* str = NewArray<char>(length_ + 1); | 239 char* str = NewArray<char>(length_ + 1); |
240 OS::MemCopy(str, buffer_, length_); | 240 MemCopy(str, buffer_, length_); |
241 str[length_] = '\0'; | 241 str[length_] = '\0'; |
242 return SmartArrayPointer<const char>(str); | 242 return SmartArrayPointer<const char>(str); |
243 } | 243 } |
244 | 244 |
245 | 245 |
246 void StringStream::Log(Isolate* isolate) { | 246 void StringStream::Log(Isolate* isolate) { |
247 LOG(isolate, StringEvent("StackDump", buffer_)); | 247 LOG(isolate, StringEvent("StackDump", buffer_)); |
248 } | 248 } |
249 | 249 |
250 | 250 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 char* HeapStringAllocator::grow(unsigned* bytes) { | 539 char* HeapStringAllocator::grow(unsigned* bytes) { |
540 unsigned new_bytes = *bytes * 2; | 540 unsigned new_bytes = *bytes * 2; |
541 // Check for overflow. | 541 // Check for overflow. |
542 if (new_bytes <= *bytes) { | 542 if (new_bytes <= *bytes) { |
543 return space_; | 543 return space_; |
544 } | 544 } |
545 char* new_space = NewArray<char>(new_bytes); | 545 char* new_space = NewArray<char>(new_bytes); |
546 if (new_space == NULL) { | 546 if (new_space == NULL) { |
547 return space_; | 547 return space_; |
548 } | 548 } |
549 OS::MemCopy(new_space, space_, *bytes); | 549 MemCopy(new_space, space_, *bytes); |
550 *bytes = new_bytes; | 550 *bytes = new_bytes; |
551 DeleteArray(space_); | 551 DeleteArray(space_); |
552 space_ = new_space; | 552 space_ = new_space; |
553 return new_space; | 553 return new_space; |
554 } | 554 } |
555 | 555 |
556 | 556 |
557 // Only grow once to the maximum allowable size. | 557 // Only grow once to the maximum allowable size. |
558 char* NoAllocationStringAllocator::grow(unsigned* bytes) { | 558 char* NoAllocationStringAllocator::grow(unsigned* bytes) { |
559 ASSERT(size_ >= *bytes); | 559 ASSERT(size_ >= *bytes); |
560 *bytes = size_; | 560 *bytes = size_; |
561 return space_; | 561 return space_; |
562 } | 562 } |
563 | 563 |
564 | 564 |
565 } } // namespace v8::internal | 565 } } // namespace v8::internal |
OLD | NEW |