Mercurial > hg > graal-jvmci-8
comparison src/share/vm/compiler/disassembler.cpp @ 6796:b31471cdc53e
7200163: add CodeComments functionality to assember stubs
Summary: Pass the codeBuffer to the Stub constructor, and adapts the disassembler to print the comments.
Reviewed-by: jrose, kvn, twisti
Contributed-by: goetz.lindenmaier@sap.com
author | kvn |
---|---|
date | Mon, 24 Sep 2012 10:30:14 -0700 |
parents | 3e23978ea0c3 |
children | f2e12eb74117 |
comparison
equal
deleted
inserted
replaced
6795:7eca5de9e0b6 | 6796:b31471cdc53e |
---|---|
146 | 146 |
147 class decode_env { | 147 class decode_env { |
148 private: | 148 private: |
149 nmethod* _nm; | 149 nmethod* _nm; |
150 CodeBlob* _code; | 150 CodeBlob* _code; |
151 CodeComments _comments; | |
151 outputStream* _output; | 152 outputStream* _output; |
152 address _start, _end; | 153 address _start, _end; |
153 | 154 |
154 char _option_buf[512]; | 155 char _option_buf[512]; |
155 char _print_raw; | 156 char _print_raw; |
185 void print_insn_labels(); | 186 void print_insn_labels(); |
186 void print_insn_bytes(address pc0, address pc); | 187 void print_insn_bytes(address pc0, address pc); |
187 void print_address(address value); | 188 void print_address(address value); |
188 | 189 |
189 public: | 190 public: |
190 decode_env(CodeBlob* code, outputStream* output); | 191 decode_env(CodeBlob* code, outputStream* output, CodeComments c = CodeComments()); |
191 | 192 |
192 address decode_instructions(address start, address end); | 193 address decode_instructions(address start, address end); |
193 | 194 |
194 void start_insn(address pc) { | 195 void start_insn(address pc) { |
195 _cur_insn = pc; | 196 _cur_insn = pc; |
227 int total_ticks() { return _total_ticks; } | 228 int total_ticks() { return _total_ticks; } |
228 void set_total_ticks(int n) { _total_ticks = n; } | 229 void set_total_ticks(int n) { _total_ticks = n; } |
229 const char* options() { return _option_buf; } | 230 const char* options() { return _option_buf; } |
230 }; | 231 }; |
231 | 232 |
232 decode_env::decode_env(CodeBlob* code, outputStream* output) { | 233 decode_env::decode_env(CodeBlob* code, outputStream* output, CodeComments c) { |
233 memset(this, 0, sizeof(*this)); | 234 memset(this, 0, sizeof(*this)); |
234 _output = output ? output : tty; | 235 _output = output ? output : tty; |
235 _code = code; | 236 _code = code; |
236 if (code != NULL && code->is_nmethod()) | 237 if (code != NULL && code->is_nmethod()) |
237 _nm = (nmethod*) code; | 238 _nm = (nmethod*) code; |
239 _comments.assign(c); | |
238 | 240 |
239 // by default, output pc but not bytes: | 241 // by default, output pc but not bytes: |
240 _print_pc = true; | 242 _print_pc = true; |
241 _print_bytes = false; | 243 _print_bytes = false; |
242 _bytes_per_line = Disassembler::pd_instruction_alignment(); | 244 _bytes_per_line = Disassembler::pd_instruction_alignment(); |
354 outputStream* st = output(); | 356 outputStream* st = output(); |
355 CodeBlob* cb = _code; | 357 CodeBlob* cb = _code; |
356 if (cb != NULL) { | 358 if (cb != NULL) { |
357 cb->print_block_comment(st, p); | 359 cb->print_block_comment(st, p); |
358 } | 360 } |
361 _comments.print_block_comment(st, (intptr_t)(p - _start)); | |
359 if (_print_pc) { | 362 if (_print_pc) { |
360 st->print(" " PTR_FORMAT ": ", p); | 363 st->print(" " PTR_FORMAT ": ", p); |
361 } | 364 } |
362 } | 365 } |
363 | 366 |
465 decode_env env(cb, st); | 468 decode_env env(cb, st); |
466 env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb); | 469 env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb); |
467 env.decode_instructions(cb->code_begin(), cb->code_end()); | 470 env.decode_instructions(cb->code_begin(), cb->code_end()); |
468 } | 471 } |
469 | 472 |
470 | 473 void Disassembler::decode(address start, address end, outputStream* st, CodeComments c) { |
471 void Disassembler::decode(address start, address end, outputStream* st) { | |
472 if (!load_library()) return; | 474 if (!load_library()) return; |
473 decode_env env(CodeCache::find_blob_unsafe(start), st); | 475 decode_env env(CodeCache::find_blob_unsafe(start), st, c); |
474 env.decode_instructions(start, end); | 476 env.decode_instructions(start, end); |
475 } | 477 } |
476 | 478 |
477 void Disassembler::decode(nmethod* nm, outputStream* st) { | 479 void Disassembler::decode(nmethod* nm, outputStream* st) { |
478 if (!load_library()) return; | 480 if (!load_library()) return; |