| Index: src/snapshot/serialize.cc
|
| diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc
|
| index b8fc206f2bdb73258cd055931277e078ca43ba78..9aac959a10b92e5631d97efb744fc38028c8c0af 100644
|
| --- a/src/snapshot/serialize.cc
|
| +++ b/src/snapshot/serialize.cc
|
| @@ -1217,11 +1217,68 @@ Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink)
|
| max_chunk_size_[i] = static_cast<uint32_t>(
|
| MemoryAllocator::PageAreaSize(static_cast<AllocationSpace>(i)));
|
| }
|
| +
|
| +#ifdef OBJECT_PRINT
|
| + if (FLAG_serialization_statistics) {
|
| + instance_type_count_ = NewArray<int>(kInstanceTypes);
|
| + instance_type_size_ = NewArray<size_t>(kInstanceTypes);
|
| + for (int i = 0; i < kInstanceTypes; i++) {
|
| + instance_type_count_[i] = 0;
|
| + instance_type_size_[i] = 0;
|
| + }
|
| + } else {
|
| + instance_type_count_ = NULL;
|
| + instance_type_size_ = NULL;
|
| + }
|
| +#endif // OBJECT_PRINT
|
| }
|
|
|
|
|
| Serializer::~Serializer() {
|
| if (code_address_map_ != NULL) delete code_address_map_;
|
| +#ifdef OBJECT_PRINT
|
| + if (instance_type_count_ != NULL) {
|
| + DeleteArray(instance_type_count_);
|
| + DeleteArray(instance_type_size_);
|
| + }
|
| +#endif // OBJECT_PRINT
|
| +}
|
| +
|
| +
|
| +#ifdef OBJECT_PRINT
|
| +void Serializer::CountInstanceType(HeapObject* obj) {
|
| + int instance_type = obj->map()->instance_type();
|
| + instance_type_count_[instance_type]++;
|
| + instance_type_size_[instance_type] += obj->Size();
|
| +}
|
| +#endif // OBJECT_PRINT
|
| +
|
| +
|
| +void Serializer::OutputStatistics(const char* name) {
|
| + if (!FLAG_serialization_statistics) return;
|
| + PrintF("%s:\n", name);
|
| + PrintF(" Spaces (bytes):\n");
|
| + for (int space = 0; space < kNumberOfSpaces; space++) {
|
| + PrintF("%16s", AllocationSpaceName(static_cast<AllocationSpace>(space)));
|
| + }
|
| + PrintF("\n");
|
| + for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) {
|
| + size_t s = pending_chunk_[space];
|
| + for (uint32_t chunk_size : completed_chunks_[space]) s += chunk_size;
|
| + PrintF("%16" V8_PTR_PREFIX "d", s);
|
| + }
|
| + PrintF("%16d\n", large_objects_total_size_);
|
| +#ifdef OBJECT_PRINT
|
| + PrintF(" Instance types (count and bytes):\n");
|
| +#define PRINT_INSTANCE_TYPE(Name) \
|
| + if (instance_type_count_[Name]) { \
|
| + PrintF("%10d %10" V8_PTR_PREFIX "d %s\n", instance_type_count_[Name], \
|
| + instance_type_size_[Name], #Name); \
|
| + }
|
| + INSTANCE_TYPE_LIST(PRINT_INSTANCE_TYPE)
|
| +#undef PRINT_INSTANCE_TYPE
|
| + PrintF("\n");
|
| +#endif // OBJECT_PRINT
|
| }
|
|
|
|
|
| @@ -1637,6 +1694,12 @@ void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space,
|
| sink_->PutInt(encoded_size, "ObjectSizeInWords");
|
| }
|
|
|
| +#ifdef OBJECT_PRINT
|
| + if (FLAG_serialization_statistics) {
|
| + serializer_->CountInstanceType(object_);
|
| + }
|
| +#endif // OBJECT_PRINT
|
| +
|
| // Mark this object as already serialized.
|
| serializer_->back_reference_map()->Add(object_, back_reference);
|
|
|
|
|