diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index 396e6ad3417..d8ae13404be 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -5307,21 +5307,29 @@ void FullSnapshotWriter::WriteFullSnapshot() { WriteIsolateFullSnapshot(num_base_objects); + if (FLAG_print_snapshot_sizes) { + OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize()); + OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize()); + } + intptr_t total_size = VmIsolateSnapshotSize() + IsolateSnapshotSize(); + if (Snapshot::IncludesCode(kind_)) { instructions_writer_->Write( *vm_isolate_snapshot_buffer_, vm_isolate_snapshot_size_, *isolate_snapshot_buffer_, isolate_snapshot_size_); - OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize()); - OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize()); - OS::Print("ReadOnlyData(CodeSize): %" Pd "\n", - instructions_writer_->data_size()); - OS::Print("Instructions(CodeSize): %" Pd "\n", - instructions_writer_->text_size()); - intptr_t total = VmIsolateSnapshotSize() + IsolateSnapshotSize() + - instructions_writer_->data_size() + - instructions_writer_->text_size(); - OS::Print("Total(CodeSize): %" Pd "\n", total); + if (FLAG_print_snapshot_sizes) { + OS::Print("ReadOnlyData(CodeSize): %" Pd "\n", + instructions_writer_->data_size()); + OS::Print("Instructions(CodeSize): %" Pd "\n", + instructions_writer_->text_size()); + } + total_size += + instructions_writer_->data_size() + instructions_writer_->text_size(); + } + + if (FLAG_print_snapshot_sizes) { + OS::Print("Total(CodeSize): %" Pd "\n", total_size); } } diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h index 94c0425f661..7c1a288bda3 100644 --- a/runtime/vm/flag_list.h +++ b/runtime/vm/flag_list.h @@ -122,6 +122,8 @@ "Polymorphic calls with deoptimization / megamorphic call") \ P(precompiled_mode, bool, false, "Precompilation compiler mode") \ C(precompiled_runtime, true, false, bool, false, "Precompiled runtime mode") \ + R(print_snapshot_sizes, false, bool, false, \ + "Print sizes of generated snapshots.") \ R(print_ssa_liveranges, false, bool, false, \ "Print live ranges after allocation.") \ C(print_stop_message, false, false, bool, false, "Print stop message.") \