1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_GC_COLLECTOR_ITERATION_H_ 18 #define ART_RUNTIME_GC_COLLECTOR_ITERATION_H_ 19 20 #include <inttypes.h> 21 #include <vector> 22 23 #include "android-base/macros.h" 24 #include "base/macros.h" 25 #include "base/timing_logger.h" 26 #include "gc/gc_cause.h" 27 #include "object_byte_pair.h" 28 29 namespace art HIDDEN { 30 namespace gc { 31 namespace collector { 32 33 // A information related single garbage collector iteration. Since we only ever have one GC running 34 // at any given time, we can have a single iteration info. 35 class Iteration { 36 public: 37 Iteration(); 38 // Returns how long the mutators were paused in nanoseconds. GetPauseTimes()39 const std::vector<uint64_t>& GetPauseTimes() const { 40 return pause_times_; 41 } GetTimings()42 TimingLogger* GetTimings() { 43 return &timings_; 44 } 45 // Returns how long the GC took to complete in nanoseconds. GetDurationNs()46 uint64_t GetDurationNs() const { 47 return duration_ns_; 48 } GetFreedBytes()49 int64_t GetFreedBytes() const { 50 return freed_.bytes; 51 } GetFreedLargeObjectBytes()52 int64_t GetFreedLargeObjectBytes() const { 53 return freed_los_.bytes; 54 } GetFreedObjects()55 uint64_t GetFreedObjects() const { 56 return freed_.objects; 57 } GetFreedLargeObjects()58 uint64_t GetFreedLargeObjects() const { 59 return freed_los_.objects; 60 } GetFreedRevokeBytes()61 uint64_t GetFreedRevokeBytes() const { 62 return freed_bytes_revoke_; 63 } GetScannedBytes()64 uint64_t GetScannedBytes() const { 65 return bytes_scanned_; 66 } SetScannedBytes(uint64_t bytes)67 void SetScannedBytes(uint64_t bytes) { 68 bytes_scanned_ = bytes; 69 } SetFreedRevoke(uint64_t freed)70 void SetFreedRevoke(uint64_t freed) { 71 freed_bytes_revoke_ = freed; 72 } 73 void Reset(GcCause gc_cause, bool clear_soft_references); 74 // Returns the estimated throughput of the iteration. 75 uint64_t GetEstimatedThroughput() const; GetClearSoftReferences()76 bool GetClearSoftReferences() const { 77 return clear_soft_references_; 78 } SetClearSoftReferences(bool clear_soft_references)79 void SetClearSoftReferences(bool clear_soft_references) { 80 clear_soft_references_ = clear_soft_references; 81 } GetGcCause()82 GcCause GetGcCause() const { 83 return gc_cause_; 84 } 85 86 private: SetDurationNs(uint64_t duration)87 void SetDurationNs(uint64_t duration) { 88 duration_ns_ = duration; 89 } 90 91 GcCause gc_cause_; 92 bool clear_soft_references_; 93 uint64_t duration_ns_; 94 uint64_t bytes_scanned_; 95 TimingLogger timings_; 96 ObjectBytePair freed_; 97 ObjectBytePair freed_los_; 98 uint64_t freed_bytes_revoke_; // see Heap::num_bytes_freed_revoke_. 99 std::vector<uint64_t> pause_times_; 100 101 friend class GarbageCollector; 102 DISALLOW_COPY_AND_ASSIGN(Iteration); 103 }; 104 105 } // namespace collector 106 } // namespace gc 107 } // namespace art 108 109 #endif // ART_RUNTIME_GC_COLLECTOR_ITERATION_H_ 110