| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "heap-snapshot-generator-inl.h" | 7 #include "heap-snapshot-generator-inl.h" |
| 8 | 8 |
| 9 #include "allocation-tracker.h" | 9 #include "allocation-tracker.h" |
| 10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
| (...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2676 MaybeWriteChunk(); | 2676 MaybeWriteChunk(); |
| 2677 } | 2677 } |
| 2678 void AddString(const char* s) { | 2678 void AddString(const char* s) { |
| 2679 AddSubstring(s, StrLength(s)); | 2679 AddSubstring(s, StrLength(s)); |
| 2680 } | 2680 } |
| 2681 void AddSubstring(const char* s, int n) { | 2681 void AddSubstring(const char* s, int n) { |
| 2682 if (n <= 0) return; | 2682 if (n <= 0) return; |
| 2683 ASSERT(static_cast<size_t>(n) <= strlen(s)); | 2683 ASSERT(static_cast<size_t>(n) <= strlen(s)); |
| 2684 const char* s_end = s + n; | 2684 const char* s_end = s + n; |
| 2685 while (s < s_end) { | 2685 while (s < s_end) { |
| 2686 int s_chunk_size = Min( | 2686 int s_chunk_size = |
| 2687 chunk_size_ - chunk_pos_, static_cast<int>(s_end - s)); | 2687 Min(chunk_size_ - chunk_pos_, static_cast<int>(s_end - s)); |
| 2688 ASSERT(s_chunk_size > 0); | 2688 ASSERT(s_chunk_size > 0); |
| 2689 OS::MemCopy(chunk_.start() + chunk_pos_, s, s_chunk_size); | 2689 MemCopy(chunk_.start() + chunk_pos_, s, s_chunk_size); |
| 2690 s += s_chunk_size; | 2690 s += s_chunk_size; |
| 2691 chunk_pos_ += s_chunk_size; | 2691 chunk_pos_ += s_chunk_size; |
| 2692 MaybeWriteChunk(); | 2692 MaybeWriteChunk(); |
| 2693 } | 2693 } |
| 2694 } | 2694 } |
| 2695 void AddNumber(unsigned n) { AddNumberImpl<unsigned>(n, "%u"); } | 2695 void AddNumber(unsigned n) { AddNumberImpl<unsigned>(n, "%u"); } |
| 2696 void Finalize() { | 2696 void Finalize() { |
| 2697 if (aborted_) return; | 2697 if (aborted_) return; |
| 2698 ASSERT(chunk_pos_ < chunk_size_); | 2698 ASSERT(chunk_pos_ < chunk_size_); |
| 2699 if (chunk_pos_ != 0) { | 2699 if (chunk_pos_ != 0) { |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3167 writer_->AddString("\"<dummy>\""); | 3167 writer_->AddString("\"<dummy>\""); |
| 3168 for (int i = 1; i < sorted_strings.length(); ++i) { | 3168 for (int i = 1; i < sorted_strings.length(); ++i) { |
| 3169 writer_->AddCharacter(','); | 3169 writer_->AddCharacter(','); |
| 3170 SerializeString(sorted_strings[i]); | 3170 SerializeString(sorted_strings[i]); |
| 3171 if (writer_->aborted()) return; | 3171 if (writer_->aborted()) return; |
| 3172 } | 3172 } |
| 3173 } | 3173 } |
| 3174 | 3174 |
| 3175 | 3175 |
| 3176 } } // namespace v8::internal | 3176 } } // namespace v8::internal |
| OLD | NEW |