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 } GetAppSlowPathDurationMs()73 uint64_t GetAppSlowPathDurationMs() const { return app_slow_path_duration_ms_; } SetAppSlowPathDurationMs(uint64_t duration)74 void SetAppSlowPathDurationMs(uint64_t duration) { app_slow_path_duration_ms_ = duration; } 75 void Reset(GcCause gc_cause, bool clear_soft_references); 76 // Returns the estimated throughput of the iteration. 77 uint64_t GetEstimatedThroughput() const; GetClearSoftReferences()78 bool GetClearSoftReferences() const { 79 return clear_soft_references_; 80 } SetClearSoftReferences(bool clear_soft_references)81 void SetClearSoftReferences(bool clear_soft_references) { 82 clear_soft_references_ = clear_soft_references; 83 } GetGcCause()84 GcCause GetGcCause() const { 85 return gc_cause_; 86 } 87 88 private: SetDurationNs(uint64_t duration)89 void SetDurationNs(uint64_t duration) { 90 duration_ns_ = duration; 91 } 92 93 GcCause gc_cause_; 94 bool clear_soft_references_; 95 uint64_t duration_ns_; 96 uint64_t app_slow_path_duration_ms_; 97 uint64_t bytes_scanned_; 98 TimingLogger timings_; 99 ObjectBytePair freed_; 100 ObjectBytePair freed_los_; 101 uint64_t freed_bytes_revoke_; // see Heap::num_bytes_freed_revoke_. 102 std::vector<uint64_t> pause_times_; 103 104 friend class GarbageCollector; 105 DISALLOW_COPY_AND_ASSIGN(Iteration); 106 }; 107 108 } // namespace collector 109 } // namespace gc 110 } // namespace art 111 112 #endif // ART_RUNTIME_GC_COLLECTOR_ITERATION_H_ 113