blob: fbe41664f75153e02f9a7ef2f351d28e30013d07 [file] [log] [blame]
Andreas Gamped4901292017-05-30 18:41:34 -07001/*
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/timing_logger.h"
25#include "object_byte_pair.h"
26
27namespace art {
28namespace gc {
29namespace collector {
30
31// A information related single garbage collector iteration. Since we only ever have one GC running
32// at any given time, we can have a single iteration info.
33class Iteration {
34 public:
35 Iteration();
36 // Returns how long the mutators were paused in nanoseconds.
37 const std::vector<uint64_t>& GetPauseTimes() const {
38 return pause_times_;
39 }
40 TimingLogger* GetTimings() {
41 return &timings_;
42 }
43 // Returns how long the GC took to complete in nanoseconds.
44 uint64_t GetDurationNs() const {
45 return duration_ns_;
46 }
47 int64_t GetFreedBytes() const {
48 return freed_.bytes;
49 }
50 int64_t GetFreedLargeObjectBytes() const {
51 return freed_los_.bytes;
52 }
53 uint64_t GetFreedObjects() const {
54 return freed_.objects;
55 }
56 uint64_t GetFreedLargeObjects() const {
57 return freed_los_.objects;
58 }
59 uint64_t GetFreedRevokeBytes() const {
60 return freed_bytes_revoke_;
61 }
62 void SetFreedRevoke(uint64_t freed) {
63 freed_bytes_revoke_ = freed;
64 }
65 void Reset(GcCause gc_cause, bool clear_soft_references);
66 // Returns the estimated throughput of the iteration.
67 uint64_t GetEstimatedThroughput() const;
68 bool GetClearSoftReferences() const {
69 return clear_soft_references_;
70 }
71 void SetClearSoftReferences(bool clear_soft_references) {
72 clear_soft_references_ = clear_soft_references;
73 }
74 GcCause GetGcCause() const {
75 return gc_cause_;
76 }
77
78 private:
79 void SetDurationNs(uint64_t duration) {
80 duration_ns_ = duration;
81 }
82
83 GcCause gc_cause_;
84 bool clear_soft_references_;
85 uint64_t duration_ns_;
86 TimingLogger timings_;
87 ObjectBytePair freed_;
88 ObjectBytePair freed_los_;
89 uint64_t freed_bytes_revoke_; // see Heap::num_bytes_freed_revoke_.
90 std::vector<uint64_t> pause_times_;
91
92 friend class GarbageCollector;
93 DISALLOW_COPY_AND_ASSIGN(Iteration);
94};
95
96} // namespace collector
97} // namespace gc
98} // namespace art
99
100#endif // ART_RUNTIME_GC_COLLECTOR_ITERATION_H_