85 int width() const { return _width; }
86 int position() const { return _position; }
87 int newlines() const { return _newlines; }
88 julong count() const { return _precount + _position; }
89 void set_count(julong count) { _precount = count - _position; }
90 void set_position(int pos) { _position = pos; }
91
92 // printing
93 void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
94 void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
95 void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
96 void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
97 void print_raw(const char* str) { write(str, strlen(str)); }
98 void print_raw(const char* str, int len) { write(str, len); }
99 void print_raw_cr(const char* str) { write(str, strlen(str)); cr(); }
100 void print_raw_cr(const char* str, int len){ write(str, len); cr(); }
101 void print_data(void* data, size_t len, bool with_ascii);
102 void put(char ch);
103 void sp(int count = 1);
104 void cr();
105 void bol() { if (_position > 0) cr(); }
106
107 // Time stamp
108 TimeStamp& time_stamp() { return _stamp; }
109 void stamp();
110 void stamp(bool guard, const char* prefix, const char* suffix);
111 void stamp(bool guard) {
112 stamp(guard, "", ": ");
113 }
114 // Date stamp
115 void date_stamp(bool guard, const char* prefix, const char* suffix);
116 // A simplified call that includes a suffix of ": "
117 void date_stamp(bool guard) {
118 date_stamp(guard, "", ": ");
119 }
120
121 // portable printing of 64 bit integers
122 void print_jlong(jlong value);
123 void print_julong(julong value);
124
125 // flushing
126 virtual void flush() {}
134
135 void dec_cr() { dec(); cr(); }
136 void inc_cr() { inc(); cr(); }
137 };
138
139 // standard output
140 // ANSI C++ name collision
141 extern outputStream* tty; // tty output
142
143 class streamIndentor : public StackObj {
144 private:
145 outputStream* _str;
146 int _amount;
147
148 public:
149 streamIndentor(outputStream* str, int amt = 2) : _str(str), _amount(amt) {
150 _str->inc(_amount);
151 }
152 ~streamIndentor() { _str->dec(_amount); }
153 };
154
155
156 // advisory locking for the shared tty stream:
157 class ttyLocker: StackObj {
158 friend class ttyUnlocker;
159 private:
160 intx _holder;
161
162 public:
163 static intx hold_tty(); // returns a "holder" token
164 static void release_tty(intx holder); // must witness same token
165 static bool release_tty_if_locked(); // returns true if lock was released
166 static void break_tty_lock_for_safepoint(intx holder);
167
168 ttyLocker() { _holder = hold_tty(); }
169 ~ttyLocker() { release_tty(_holder); }
170 };
171
172 // Release the tty lock if it's held and reacquire it if it was
173 // locked. Used to avoid lock ordering problems.
174 class ttyUnlocker: StackObj {
|
85 int width() const { return _width; }
86 int position() const { return _position; }
87 int newlines() const { return _newlines; }
88 julong count() const { return _precount + _position; }
89 void set_count(julong count) { _precount = count - _position; }
90 void set_position(int pos) { _position = pos; }
91
92 // printing
93 void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
94 void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
95 void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
96 void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
97 void print_raw(const char* str) { write(str, strlen(str)); }
98 void print_raw(const char* str, int len) { write(str, len); }
99 void print_raw_cr(const char* str) { write(str, strlen(str)); cr(); }
100 void print_raw_cr(const char* str, int len){ write(str, len); cr(); }
101 void print_data(void* data, size_t len, bool with_ascii);
102 void put(char ch);
103 void sp(int count = 1);
104 void cr();
105 void cr_indent();
106 void bol() { if (_position > 0) cr(); }
107
108 // Print a human readable size.
109 // byte_size: size, in bytes, to be printed.
110 // scale: one of 1 (byte-wise printing), sizeof(word) (word-size printing), K, M, G (scaled by KB, MB, GB respectively,
111 // or 0, which means the best scale is choosen dynamically.
112 // width: printing width.
113 void print_human_readable_size(size_t byte_size, size_t scale = 0, int width = -1);
114
115 // Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values
116 // larger than 99% but not 100% are displayed as ">100%".
117 void print_percentage(size_t total, size_t part);
118
119 // Time stamp
120 TimeStamp& time_stamp() { return _stamp; }
121 void stamp();
122 void stamp(bool guard, const char* prefix, const char* suffix);
123 void stamp(bool guard) {
124 stamp(guard, "", ": ");
125 }
126 // Date stamp
127 void date_stamp(bool guard, const char* prefix, const char* suffix);
128 // A simplified call that includes a suffix of ": "
129 void date_stamp(bool guard) {
130 date_stamp(guard, "", ": ");
131 }
132
133 // portable printing of 64 bit integers
134 void print_jlong(jlong value);
135 void print_julong(julong value);
136
137 // flushing
138 virtual void flush() {}
146
147 void dec_cr() { dec(); cr(); }
148 void inc_cr() { inc(); cr(); }
149 };
150
151 // standard output
152 // ANSI C++ name collision
153 extern outputStream* tty; // tty output
154
155 class streamIndentor : public StackObj {
156 private:
157 outputStream* _str;
158 int _amount;
159
160 public:
161 streamIndentor(outputStream* str, int amt = 2) : _str(str), _amount(amt) {
162 _str->inc(_amount);
163 }
164 ~streamIndentor() { _str->dec(_amount); }
165 };
166
167 // advisory locking for the shared tty stream:
168 class ttyLocker: StackObj {
169 friend class ttyUnlocker;
170 private:
171 intx _holder;
172
173 public:
174 static intx hold_tty(); // returns a "holder" token
175 static void release_tty(intx holder); // must witness same token
176 static bool release_tty_if_locked(); // returns true if lock was released
177 static void break_tty_lock_for_safepoint(intx holder);
178
179 ttyLocker() { _holder = hold_tty(); }
180 ~ttyLocker() { release_tty(_holder); }
181 };
182
183 // Release the tty lock if it's held and reacquire it if it was
184 // locked. Used to avoid lock ordering problems.
185 class ttyUnlocker: StackObj {
|