OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 mark_compact_collector_(this), | 137 mark_compact_collector_(this), |
138 store_buffer_(this), | 138 store_buffer_(this), |
139 marking_(this), | 139 marking_(this), |
140 incremental_marking_(this), | 140 incremental_marking_(this), |
141 gc_count_at_last_idle_gc_(0), | 141 gc_count_at_last_idle_gc_(0), |
142 full_codegen_bytes_generated_(0), | 142 full_codegen_bytes_generated_(0), |
143 crankshaft_codegen_bytes_generated_(0), | 143 crankshaft_codegen_bytes_generated_(0), |
144 new_space_allocation_counter_(0), | 144 new_space_allocation_counter_(0), |
145 gcs_since_last_deopt_(0), | 145 gcs_since_last_deopt_(0), |
146 allocation_sites_scratchpad_length_(0), | 146 allocation_sites_scratchpad_length_(0), |
| 147 ring_buffer_full_(false), |
| 148 ring_buffer_end_(0), |
147 promotion_queue_(this), | 149 promotion_queue_(this), |
148 configured_(false), | 150 configured_(false), |
149 external_string_table_(this), | 151 external_string_table_(this), |
150 chunks_queued_for_free_(NULL), | 152 chunks_queued_for_free_(NULL), |
151 gc_callbacks_depth_(0), | 153 gc_callbacks_depth_(0), |
152 deserialization_complete_(false), | 154 deserialization_complete_(false), |
153 concurrent_sweeping_enabled_(false), | 155 concurrent_sweeping_enabled_(false), |
154 strong_roots_list_(NULL) { | 156 strong_roots_list_(NULL) { |
155 // Allow build-time customization of the max semispace size. Building | 157 // Allow build-time customization of the max semispace size. Building |
156 // V8 with snapshots and a non-default max semispace size is much | 158 // V8 with snapshots and a non-default max semispace size is much |
(...skipping 5096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5253 FixedArray::SizeFor(JSObject::kInitialMaxFastElementArray) + | 5255 FixedArray::SizeFor(JSObject::kInitialMaxFastElementArray) + |
5254 AllocationMemento::kSize)); | 5256 AllocationMemento::kSize)); |
5255 | 5257 |
5256 code_range_size_ = code_range_size * MB; | 5258 code_range_size_ = code_range_size * MB; |
5257 | 5259 |
5258 configured_ = true; | 5260 configured_ = true; |
5259 return true; | 5261 return true; |
5260 } | 5262 } |
5261 | 5263 |
5262 | 5264 |
| 5265 void Heap::AddToRingBuffer(const char* string) { |
| 5266 size_t first_part = |
| 5267 Min(strlen(string), kTraceRingBufferSize - ring_buffer_end_); |
| 5268 memcpy(trace_ring_buffer_ + ring_buffer_end_, string, first_part); |
| 5269 ring_buffer_end_ += first_part; |
| 5270 if (first_part < strlen(string)) { |
| 5271 ring_buffer_full_ = true; |
| 5272 size_t second_part = strlen(string) - first_part; |
| 5273 memcpy(trace_ring_buffer_, string + first_part, second_part); |
| 5274 ring_buffer_end_ = second_part; |
| 5275 } |
| 5276 } |
| 5277 |
| 5278 |
| 5279 void Heap::GetFromRingBuffer(char* buffer) { |
| 5280 size_t copied = 0; |
| 5281 if (ring_buffer_full_) { |
| 5282 copied = kTraceRingBufferSize - ring_buffer_end_; |
| 5283 memcpy(buffer, trace_ring_buffer_ + ring_buffer_end_, copied); |
| 5284 } |
| 5285 memcpy(buffer + copied, trace_ring_buffer_, ring_buffer_end_); |
| 5286 } |
| 5287 |
| 5288 |
5263 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } | 5289 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } |
5264 | 5290 |
5265 | 5291 |
5266 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 5292 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { |
5267 *stats->start_marker = HeapStats::kStartMarker; | 5293 *stats->start_marker = HeapStats::kStartMarker; |
5268 *stats->end_marker = HeapStats::kEndMarker; | 5294 *stats->end_marker = HeapStats::kEndMarker; |
5269 *stats->new_space_size = new_space_.SizeAsInt(); | 5295 *stats->new_space_size = new_space_.SizeAsInt(); |
5270 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 5296 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); |
5271 *stats->old_space_size = old_space_->SizeOfObjects(); | 5297 *stats->old_space_size = old_space_->SizeOfObjects(); |
5272 *stats->old_space_capacity = old_space_->Capacity(); | 5298 *stats->old_space_capacity = old_space_->Capacity(); |
(...skipping 12 matching lines...) Expand all Loading... |
5285 if (take_snapshot) { | 5311 if (take_snapshot) { |
5286 HeapIterator iterator(this); | 5312 HeapIterator iterator(this); |
5287 for (HeapObject* obj = iterator.next(); obj != NULL; | 5313 for (HeapObject* obj = iterator.next(); obj != NULL; |
5288 obj = iterator.next()) { | 5314 obj = iterator.next()) { |
5289 InstanceType type = obj->map()->instance_type(); | 5315 InstanceType type = obj->map()->instance_type(); |
5290 DCHECK(0 <= type && type <= LAST_TYPE); | 5316 DCHECK(0 <= type && type <= LAST_TYPE); |
5291 stats->objects_per_type[type]++; | 5317 stats->objects_per_type[type]++; |
5292 stats->size_per_type[type] += obj->Size(); | 5318 stats->size_per_type[type] += obj->Size(); |
5293 } | 5319 } |
5294 } | 5320 } |
| 5321 if (stats->last_few_messages != NULL) |
| 5322 GetFromRingBuffer(stats->last_few_messages); |
5295 } | 5323 } |
5296 | 5324 |
5297 | 5325 |
5298 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 5326 intptr_t Heap::PromotedSpaceSizeOfObjects() { |
5299 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + | 5327 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + |
5300 map_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); | 5328 map_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); |
5301 } | 5329 } |
5302 | 5330 |
5303 | 5331 |
5304 int64_t Heap::PromotedExternalMemorySize() { | 5332 int64_t Heap::PromotedExternalMemorySize() { |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6590 *object_type = "CODE_TYPE"; \ | 6618 *object_type = "CODE_TYPE"; \ |
6591 *object_sub_type = "CODE_AGE/" #name; \ | 6619 *object_sub_type = "CODE_AGE/" #name; \ |
6592 return true; | 6620 return true; |
6593 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6621 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6594 #undef COMPARE_AND_RETURN_NAME | 6622 #undef COMPARE_AND_RETURN_NAME |
6595 } | 6623 } |
6596 return false; | 6624 return false; |
6597 } | 6625 } |
6598 } | 6626 } |
6599 } // namespace v8::internal | 6627 } // namespace v8::internal |
OLD | NEW |