comparison src/share/vm/compiler/disassembler.cpp @ 8767:a5de0cc2f91c

8008555: Debugging code in compiled method sometimes leaks memory Summary: support for strings that have same life-time as code that uses them. Reviewed-by: kvn, twisti
author roland
date Mon, 18 Mar 2013 13:19:06 +0100
parents 070d523b96a7
children b9a918201d47 de6a9e811145
comparison
equal deleted inserted replaced
8765:592f9722c72e 8767:a5de0cc2f91c
156 156
157 class decode_env { 157 class decode_env {
158 private: 158 private:
159 nmethod* _nm; 159 nmethod* _nm;
160 CodeBlob* _code; 160 CodeBlob* _code;
161 CodeComments _comments; 161 CodeStrings _strings;
162 outputStream* _output; 162 outputStream* _output;
163 address _start, _end; 163 address _start, _end;
164 164
165 char _option_buf[512]; 165 char _option_buf[512];
166 char _print_raw; 166 char _print_raw;
196 void print_insn_labels(); 196 void print_insn_labels();
197 void print_insn_bytes(address pc0, address pc); 197 void print_insn_bytes(address pc0, address pc);
198 void print_address(address value); 198 void print_address(address value);
199 199
200 public: 200 public:
201 decode_env(CodeBlob* code, outputStream* output, CodeComments c = CodeComments()); 201 decode_env(CodeBlob* code, outputStream* output, CodeStrings c = CodeStrings());
202 202
203 address decode_instructions(address start, address end); 203 address decode_instructions(address start, address end);
204 204
205 void start_insn(address pc) { 205 void start_insn(address pc) {
206 _cur_insn = pc; 206 _cur_insn = pc;
240 int total_ticks() { return _total_ticks; } 240 int total_ticks() { return _total_ticks; }
241 void set_total_ticks(int n) { _total_ticks = n; } 241 void set_total_ticks(int n) { _total_ticks = n; }
242 const char* options() { return _option_buf; } 242 const char* options() { return _option_buf; }
243 }; 243 };
244 244
245 decode_env::decode_env(CodeBlob* code, outputStream* output, CodeComments c) { 245 decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) {
246 memset(this, 0, sizeof(*this)); 246 memset(this, 0, sizeof(*this));
247 _output = output ? output : tty; 247 _output = output ? output : tty;
248 _code = code; 248 _code = code;
249 if (code != NULL && code->is_nmethod()) 249 if (code != NULL && code->is_nmethod())
250 _nm = (nmethod*) code; 250 _nm = (nmethod*) code;
251 _comments.assign(c); 251 _strings.assign(c);
252 252
253 // by default, output pc but not bytes: 253 // by default, output pc but not bytes:
254 _print_pc = true; 254 _print_pc = true;
255 _print_bytes = false; 255 _print_bytes = false;
256 _bytes_per_line = Disassembler::pd_instruction_alignment(); 256 _bytes_per_line = Disassembler::pd_instruction_alignment();
368 outputStream* st = output(); 368 outputStream* st = output();
369 CodeBlob* cb = _code; 369 CodeBlob* cb = _code;
370 if (cb != NULL) { 370 if (cb != NULL) {
371 cb->print_block_comment(st, p); 371 cb->print_block_comment(st, p);
372 } 372 }
373 _comments.print_block_comment(st, (intptr_t)(p - _start)); 373 _strings.print_block_comment(st, (intptr_t)(p - _start));
374 if (_print_pc) { 374 if (_print_pc) {
375 st->print(" " PTR_FORMAT ": ", p); 375 st->print(" " PTR_FORMAT ": ", p);
376 } 376 }
377 } 377 }
378 378
496 decode_env env(cb, st); 496 decode_env env(cb, st);
497 env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb); 497 env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb);
498 env.decode_instructions(cb->code_begin(), cb->code_end()); 498 env.decode_instructions(cb->code_begin(), cb->code_end());
499 } 499 }
500 500
501 void Disassembler::decode(address start, address end, outputStream* st, CodeComments c) { 501 void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
502 if (!load_library()) return; 502 if (!load_library()) return;
503 decode_env env(CodeCache::find_blob_unsafe(start), st, c); 503 decode_env env(CodeCache::find_blob_unsafe(start), st, c);
504 env.decode_instructions(start, end); 504 env.decode_instructions(start, end);
505 } 505 }
506 506