< prev index next >

src/hotspot/share/interpreter/bytecodeTracer.cpp

Print this page

153 };
154 
155 
156 // Implementation of BytecodeTracer
157 
158 // %%% This set_closure thing seems overly general, given that
159 // nobody uses it.  Also, if BytecodePrinter weren't hidden
160 // then Method* could use instances of it directly and it
161 // would be easier to remove races on _current_method and bcp.
162 // Since this is not product functionality, we can defer cleanup.
163 
164 BytecodeClosure* BytecodeTracer::_closure = NULL;
165 
166 static BytecodePrinter std_closure;
167 BytecodeClosure* BytecodeTracer::std_closure() {
168   return &::std_closure;
169 }
170 
171 
172 void BytecodeTracer::trace(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {

173   if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) {
174     ttyLocker ttyl;  // 5065316: keep the following output coherent
175     // The ttyLocker also prevents races between two threads
176     // trying to use the single instance of BytecodePrinter.
177     // Using the ttyLocker prevents the system from coming to
178     // a safepoint within this code, which is sensitive to Method*
179     // movement.
180     //
181     // There used to be a leaf mutex here, but the ttyLocker will
182     // work just as well, as long as the printing operations never block.
183     //
184     // We put the locker on the static trace method, not the
185     // virtual one, because the clients of this module go through
186     // the static method.
187     _closure->trace(method, bcp, tos, tos2, st);
188   }
189 }
190 
191 void BytecodeTracer::trace(const methodHandle& method, address bcp, outputStream* st) {

192   ttyLocker ttyl;  // 5065316: keep the following output coherent
193   _closure->trace(method, bcp, st);
194 }
195 
196 void print_symbol(Symbol* sym, outputStream* st) {
197   char buf[40];
198   int len = sym->utf8_length();
199   if (len >= (int)sizeof(buf)) {
200     st->print_cr(" %s...[%d]", sym->as_C_string(buf, sizeof(buf)), len);
201   } else {
202     st->print(" ");
203     sym->print_on(st); st->cr();
204   }
205 }
206 
207 void print_oop(oop value, outputStream* st) {
208   if (value == NULL) {
209     st->print_cr(" NULL");
210   } else if (java_lang_String::is_instance(value)) {
211     char buf[40];

153 };
154 
155 
156 // Implementation of BytecodeTracer
157 
158 // %%% This set_closure thing seems overly general, given that
159 // nobody uses it.  Also, if BytecodePrinter weren't hidden
160 // then Method* could use instances of it directly and it
161 // would be easier to remove races on _current_method and bcp.
162 // Since this is not product functionality, we can defer cleanup.
163 
164 BytecodeClosure* BytecodeTracer::_closure = NULL;
165 
166 static BytecodePrinter std_closure;
167 BytecodeClosure* BytecodeTracer::std_closure() {
168   return &::std_closure;
169 }
170 
171 
172 void BytecodeTracer::trace(const methodHandle& method, address bcp, uintptr_t tos, uintptr_t tos2, outputStream* st) {
173   if (_closure == NULL) return;
174   if (TraceBytecodes && BytecodeCounter::counter_value() >= TraceBytecodesAt) {
175     ttyLocker ttyl;  // 5065316: keep the following output coherent
176     // The ttyLocker also prevents races between two threads
177     // trying to use the single instance of BytecodePrinter.
178     // Using the ttyLocker prevents the system from coming to
179     // a safepoint within this code, which is sensitive to Method*
180     // movement.
181     //
182     // There used to be a leaf mutex here, but the ttyLocker will
183     // work just as well, as long as the printing operations never block.
184     //
185     // We put the locker on the static trace method, not the
186     // virtual one, because the clients of this module go through
187     // the static method.
188     _closure->trace(method, bcp, tos, tos2, st);
189   }
190 }
191 
192 void BytecodeTracer::trace(const methodHandle& method, address bcp, outputStream* st) {
193   if (_closure == NULL) return;
194   ttyLocker ttyl;  // 5065316: keep the following output coherent
195   _closure->trace(method, bcp, st);
196 }
197 
198 void print_symbol(Symbol* sym, outputStream* st) {
199   char buf[40];
200   int len = sym->utf8_length();
201   if (len >= (int)sizeof(buf)) {
202     st->print_cr(" %s...[%d]", sym->as_C_string(buf, sizeof(buf)), len);
203   } else {
204     st->print(" ");
205     sym->print_on(st); st->cr();
206   }
207 }
208 
209 void print_oop(oop value, outputStream* st) {
210   if (value == NULL) {
211     st->print_cr(" NULL");
212   } else if (java_lang_String::is_instance(value)) {
213     char buf[40];
< prev index next >