71 _last_ditch_collection, 72 _last_gc_cause 73 }; 74 75 inline static bool is_user_requested_gc(GCCause::Cause cause) { 76 return (cause == GCCause::_java_lang_system_gc || 77 cause == GCCause::_jvmti_force_gc); 78 } 79 80 inline static bool is_serviceability_requested_gc(GCCause::Cause 81 cause) { 82 return (cause == GCCause::_jvmti_force_gc || 83 cause == GCCause::_heap_inspection || 84 cause == GCCause::_heap_dump); 85 } 86 87 // Return a string describing the GCCause. 88 static const char* to_string(GCCause::Cause cause); 89 }; 90 91 #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP | 71 _last_ditch_collection, 72 _last_gc_cause 73 }; 74 75 inline static bool is_user_requested_gc(GCCause::Cause cause) { 76 return (cause == GCCause::_java_lang_system_gc || 77 cause == GCCause::_jvmti_force_gc); 78 } 79 80 inline static bool is_serviceability_requested_gc(GCCause::Cause 81 cause) { 82 return (cause == GCCause::_jvmti_force_gc || 83 cause == GCCause::_heap_inspection || 84 cause == GCCause::_heap_dump); 85 } 86 87 // Return a string describing the GCCause. 88 static const char* to_string(GCCause::Cause cause); 89 }; 90 91 // Helper class for doing logging that includes the GC Cause 92 // as a string. 93 class GCCauseString : StackObj { 94 private: 95 static const int length = 128; 96 char buffer[length]; 97 int position; 98 99 public: 100 GCCauseString(const char* prefix, GCCause::Cause cause) { 101 if (PrintGCCause) { 102 position = jio_snprintf(buffer, length, "%s (%s)", prefix, GCCause::to_string(cause)); 103 } else { 104 position = jio_snprintf(buffer, length, "%s", prefix); 105 } 106 assert(position > 0 && position <= length, 107 err_msg("Need to increase the buffer size in GCCauseString? %d", position)); 108 } 109 110 GCCauseString& append(const char* str) { 111 position += jio_snprintf(buffer + position, length - position, "%", str); 112 assert(position > 0 && position <= length, 113 err_msg("Need to increase the buffer size in GCCauseString? %d", position)); 114 return *this; 115 } 116 117 operator const char*() { 118 return buffer; 119 } 120 }; 121 122 #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP |