Mercurial > hg > graal-compiler
comparison src/share/vm/gc_interface/gcCause.hpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | 9d679effd28c |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
5891:fd8832ae511d | 6275:957c266d8bc5 |
---|---|
86 | 86 |
87 // Return a string describing the GCCause. | 87 // Return a string describing the GCCause. |
88 static const char* to_string(GCCause::Cause cause); | 88 static const char* to_string(GCCause::Cause cause); |
89 }; | 89 }; |
90 | 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 int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str); | |
112 _position += res; | |
113 assert(res >= 0 && _position <= _length, | |
114 err_msg("Need to increase the buffer size in GCCauseString? %d", res)); | |
115 return *this; | |
116 } | |
117 | |
118 operator const char*() { | |
119 return _buffer; | |
120 } | |
121 }; | |
122 | |
91 #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP | 123 #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP |