Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Chartier | 3cf2253 | 2015-07-09 15:15:09 -0700 | [diff] [blame] | 20 | #include <iosfwd> |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 21 | |
| 22 | namespace art { |
| 23 | namespace gc { |
| 24 | |
| 25 | // What caused the GC? |
| 26 | enum GcCause { |
Mathieu Chartier | 87a619f | 2017-06-26 17:49:09 -0700 | [diff] [blame] | 27 | // Invalid GC cause used as a placeholder. |
| 28 | kGcCauseNone, |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 29 | // 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 Uhler | da1da8a | 2017-05-16 13:37:32 +0000 | [diff] [blame] | 36 | // 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 Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 38 | kGcCauseForNativeAlloc, |
| 39 | // GC triggered for a collector transition. |
| 40 | kGcCauseCollectorTransition, |
Mathieu Chartier | 89a201e | 2014-05-02 10:27:26 -0700 | [diff] [blame] | 41 | // 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 Chartier | aa51682 | 2015-10-02 15:53:37 -0700 | [diff] [blame] | 45 | // Not a real GC cause, used to implement exclusion between GC and instrumentation. |
| 46 | kGcCauseInstrumentation, |
Mathieu Chartier | 61d2b2d | 2016-02-04 13:31:46 -0800 | [diff] [blame] | 47 | // Not a real GC cause, used to add or remove app image spaces. |
| 48 | kGcCauseAddRemoveAppImageSpace, |
Hiroshi Yamauchi | 8f95cf3 | 2016-04-19 11:14:06 -0700 | [diff] [blame] | 49 | // Not a real GC cause, used to implement exclusion between GC and debugger. |
| 50 | kGcCauseDebugger, |
Zuo Wang | f37a88b | 2014-07-10 04:26:41 -0700 | [diff] [blame] | 51 | // GC triggered for background transition when both foreground and background collector are CMS. |
| 52 | kGcCauseHomogeneousSpaceCompact, |
Mathieu Chartier | 1b1e31f | 2016-05-19 10:13:04 -0700 | [diff] [blame] | 53 | // Class linker cause, used to guard filling art methods with special values. |
| 54 | kGcCauseClassLinker, |
Nicolas Geoffray | cf48fa0 | 2016-07-30 22:49:11 +0100 | [diff] [blame] | 55 | // Not a real GC cause, used to implement exclusion between code cache metadata and GC. |
| 56 | kGcCauseJitCodeCache, |
Andreas Gampe | fda5714 | 2016-09-08 20:29:18 -0700 | [diff] [blame] | 57 | // Not a real GC cause, used to add or remove system-weak holders. |
| 58 | kGcCauseAddRemoveSystemWeakHolder, |
Mathieu Chartier | e8649c7 | 2017-03-03 18:02:18 -0800 | [diff] [blame] | 59 | // Not a real GC cause, used to prevent hprof running in the middle of GC. |
Mathieu Chartier | ecc8230 | 2017-02-16 10:20:12 -0800 | [diff] [blame] | 60 | kGcCauseHprof, |
Mathieu Chartier | e8649c7 | 2017-03-03 18:02:18 -0800 | [diff] [blame] | 61 | // Not a real GC cause, used to prevent GetObjectsAllocated running in the middle of GC. |
| 62 | kGcCauseGetObjectsAllocated, |
Mathieu Chartier | 3910037 | 2017-05-17 13:14:10 -0700 | [diff] [blame] | 63 | // GC cause for the profile saver. |
| 64 | kGcCauseProfileSaver, |
Hiroshi Yamauchi | 6f4ffe4 | 2014-01-13 12:30:44 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | const char* PrettyCause(GcCause cause); |
| 68 | std::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_ |