Chromium Code Reviews| Index: src/snapshot/serialize.cc |
| diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc |
| index b8fc206f2bdb73258cd055931277e078ca43ba78..53c883c6e34939089ef6d5b307f068a9991778c9 100644 |
| --- a/src/snapshot/serialize.cc |
| +++ b/src/snapshot/serialize.cc |
| @@ -1209,7 +1209,8 @@ Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink) |
| root_index_map_(isolate), |
| code_address_map_(NULL), |
| large_objects_total_size_(0), |
| - seen_large_objects_index_(0) { |
| + seen_large_objects_index_(0), |
| + instance_type_count_(NULL) { |
| // The serializer is meant to be used only to generate initial heap images |
| // from a context in which there is only one isolate. |
| for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) { |
| @@ -1217,11 +1218,44 @@ Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink) |
| max_chunk_size_[i] = static_cast<uint32_t>( |
| MemoryAllocator::PageAreaSize(static_cast<AllocationSpace>(i))); |
| } |
| + |
| + if (FLAG_serialization_statistics) { |
| + instance_type_count_ = NewArray<int>(kInstanceTypes); |
| + for (int i = 0; i < kInstanceTypes; i++) instance_type_count_[i] = 0; |
| + } |
| } |
| Serializer::~Serializer() { |
| if (code_address_map_ != NULL) delete code_address_map_; |
| + if (instance_type_count_ != NULL) DeleteArray(instance_type_count_); |
| +} |
| + |
| + |
| +void Serializer::OutputStatistics(const char* name) { |
| + if (!FLAG_serialization_statistics) return; |
| + PrintF("%s:\n", name); |
| + PrintF(" Spaces:\n"); |
|
Jakob Kummerow
2015/04/16 12:32:25
nit: maybe " Space usage (bytes):\n"?
Yang
2015/04/16 13:00:43
Done.
|
| + for (int space = 0; space < kNumberOfSpaces; space++) { |
| + PrintF("%16s", AllocationSpaceName(static_cast<AllocationSpace>(space))); |
| + } |
| + PrintF("\n"); |
| + for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) { |
| + int s = pending_chunk_[space]; |
|
Jakob Kummerow
2015/04/16 12:32:25
s/int/uint32_t/, as pending_chunk_ is a uint32_t (
Yang
2015/04/16 13:00:43
Done.
|
| + for (uint32_t chunk_size : completed_chunks_[space]) s += chunk_size; |
| + PrintF("%16d", s); |
| + } |
| + PrintF("%16d\n", large_objects_total_size_); |
| +#ifdef OBJECT_PRINT |
| + PrintF(" Instance types:\n"); |
|
Jakob Kummerow
2015/04/16 12:32:25
nit: maybe " Instance types (count):\n"?
I can h
Yang
2015/04/16 13:00:43
Wish and you shall receive.
|
| +#define PRINT_INSTANCE_TYPE(Name) \ |
| + if (instance_type_count_[Name]) { \ |
| + PrintF("%10d %s\n", instance_type_count_[Name], #Name); \ |
| + } |
| + INSTANCE_TYPE_LIST(PRINT_INSTANCE_TYPE) |
| +#undef PRINT_INSTANCE_TYPE |
| + PrintF("\n"); |
| +#endif // OBJECT_PRINT |
| } |
| @@ -1637,6 +1671,10 @@ void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space, |
| sink_->PutInt(encoded_size, "ObjectSizeInWords"); |
| } |
| + if (FLAG_serialization_statistics) { |
| + serializer_->CountInstanceType(object_->map()->instance_type()); |
| + } |
| + |
| // Mark this object as already serialized. |
| serializer_->back_reference_map()->Add(object_, back_reference); |