blob: 81781ceeb7865da7c8e86b0ece6c2b24a964eebf [file] [log] [blame]
Hiroshi Yamauchi6f4ffe42014-01-13 12:30:44 -08001/*
2 * Copyright (C) 2014 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_GC_CAUSE_H_
18#define ART_RUNTIME_GC_GC_CAUSE_H_
19
Mathieu Chartier3cf22532015-07-09 15:15:09 -070020#include <iosfwd>
Hiroshi Yamauchi6f4ffe42014-01-13 12:30:44 -080021
22namespace art {
23namespace gc {
24
25// What caused the GC?
26enum GcCause {
Mathieu Chartier87a619f2017-06-26 17:49:09 -070027 // Invalid GC cause used as a placeholder.
28 kGcCauseNone,
Hiroshi Yamauchi6f4ffe42014-01-13 12:30:44 -080029 // GC triggered by a failed allocation. Thread doing allocation is blocked waiting for GC before
30 // retrying allocation.
31 kGcCauseForAlloc,
32 // A background GC trying to ensure there is free memory ahead of allocations.
33 kGcCauseBackground,
34 // An explicit System.gc() call.
35 kGcCauseExplicit,
Richard Uhlerda1da8a2017-05-16 13:37:32 +000036 // GC triggered for a native allocation when NativeAllocationGcWatermark is exceeded.
37 // (This may be a blocking GC depending on whether we run a non-concurrent collector).
Hiroshi Yamauchi6f4ffe42014-01-13 12:30:44 -080038 kGcCauseForNativeAlloc,
39 // GC triggered for a collector transition.
40 kGcCauseCollectorTransition,
Mathieu Chartier89a201e2014-05-02 10:27:26 -070041 // Not a real GC cause, used when we disable moving GC (currently for GetPrimitiveArrayCritical).
42 kGcCauseDisableMovingGc,
43 // Not a real GC cause, used when we trim the heap.
44 kGcCauseTrim,
Mathieu Chartieraa516822015-10-02 15:53:37 -070045 // Not a real GC cause, used to implement exclusion between GC and instrumentation.
46 kGcCauseInstrumentation,
Mathieu Chartier61d2b2d2016-02-04 13:31:46 -080047 // Not a real GC cause, used to add or remove app image spaces.
48 kGcCauseAddRemoveAppImageSpace,
Hiroshi Yamauchi8f95cf32016-04-19 11:14:06 -070049 // Not a real GC cause, used to implement exclusion between GC and debugger.
50 kGcCauseDebugger,
Zuo Wangf37a88b2014-07-10 04:26:41 -070051 // GC triggered for background transition when both foreground and background collector are CMS.
52 kGcCauseHomogeneousSpaceCompact,
Mathieu Chartier1b1e31f2016-05-19 10:13:04 -070053 // Class linker cause, used to guard filling art methods with special values.
54 kGcCauseClassLinker,
Nicolas Geoffraycf48fa02016-07-30 22:49:11 +010055 // Not a real GC cause, used to implement exclusion between code cache metadata and GC.
56 kGcCauseJitCodeCache,
Andreas Gampefda57142016-09-08 20:29:18 -070057 // Not a real GC cause, used to add or remove system-weak holders.
58 kGcCauseAddRemoveSystemWeakHolder,
Mathieu Chartiere8649c72017-03-03 18:02:18 -080059 // Not a real GC cause, used to prevent hprof running in the middle of GC.
Mathieu Chartierecc82302017-02-16 10:20:12 -080060 kGcCauseHprof,
Mathieu Chartiere8649c72017-03-03 18:02:18 -080061 // Not a real GC cause, used to prevent GetObjectsAllocated running in the middle of GC.
62 kGcCauseGetObjectsAllocated,
Mathieu Chartier39100372017-05-17 13:14:10 -070063 // GC cause for the profile saver.
64 kGcCauseProfileSaver,
Hiroshi Yamauchi6f4ffe42014-01-13 12:30:44 -080065};
66
67const char* PrettyCause(GcCause cause);
68std::ostream& operator<<(std::ostream& os, const GcCause& gc_cause);
69
70} // namespace gc
71} // namespace art
72
73#endif // ART_RUNTIME_GC_GC_CAUSE_H_