< prev index next >

src/share/vm/gc/shared/gcCause.hpp

Print this page




 119     return (cause == GCCause::_allocation_failure ||
 120             cause == GCCause::_adaptive_size_policy ||
 121             cause == GCCause::_last_ditch_collection);
 122   }
 123 
 124   // Return a string describing the GCCause.
 125   static const char* to_string(GCCause::Cause cause);
 126 };
 127 
 128 // Helper class for doing logging that includes the GC Cause
 129 // as a string.
 130 class GCCauseString : StackObj {
 131  private:
 132    static const int _length = 128;
 133    char _buffer[_length];
 134    int _position;
 135 
 136  public:
 137    GCCauseString(const char* prefix, GCCause::Cause cause) {
 138      if (PrintGCCause) {
 139       _position = jio_snprintf(_buffer, _length, "%s (%s) ", prefix, GCCause::to_string(cause));
 140      } else {
 141       _position = jio_snprintf(_buffer, _length, "%s ", prefix);
 142      }
 143      assert(_position >= 0 && _position <= _length,
 144             "Need to increase the buffer size in GCCauseString? %d", _position);
 145    }
 146 
 147    GCCauseString& append(const char* str) {
 148      int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str);
 149      _position += res;
 150      assert(res >= 0 && _position <= _length,
 151             "Need to increase the buffer size in GCCauseString? %d", res);
 152      return *this;
 153    }
 154 
 155    operator const char*() {
 156      return _buffer;
 157    }
 158 };
 159 
 160 #endif // SHARE_VM_GC_SHARED_GCCAUSE_HPP


 119     return (cause == GCCause::_allocation_failure ||
 120             cause == GCCause::_adaptive_size_policy ||
 121             cause == GCCause::_last_ditch_collection);
 122   }
 123 
 124   // Return a string describing the GCCause.
 125   static const char* to_string(GCCause::Cause cause);
 126 };
 127 
 128 // Helper class for doing logging that includes the GC Cause
 129 // as a string.
 130 class GCCauseString : StackObj {
 131  private:
 132    static const int _length = 128;
 133    char _buffer[_length];
 134    int _position;
 135 
 136  public:
 137    GCCauseString(const char* prefix, GCCause::Cause cause) {
 138      if (PrintGCCause) {
 139       _position = jio_snprintf(_buffer, _length, "%s (%s)", prefix, GCCause::to_string(cause));
 140      } else {
 141       _position = jio_snprintf(_buffer, _length, "%s", prefix);
 142      }
 143      assert(_position >= 0 && _position <= _length,
 144             "Need to increase the buffer size in GCCauseString? %d", _position);
 145    }
 146 
 147    GCCauseString& append(const char* str) {
 148      int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str);
 149      _position += res;
 150      assert(res >= 0 && _position <= _length,
 151             "Need to increase the buffer size in GCCauseString? %d", res);
 152      return *this;
 153    }
 154 
 155    operator const char*() {
 156      return _buffer;
 157    }
 158 };
 159 
 160 #endif // SHARE_VM_GC_SHARED_GCCAUSE_HPP
< prev index next >