287 } |
287 } |
288 |
288 |
289 const char* add_string(const char * string) PRODUCT_RETURN_(return NULL;); |
289 const char* add_string(const char * string) PRODUCT_RETURN_(return NULL;); |
290 |
290 |
291 void add_comment(intptr_t offset, const char * comment) PRODUCT_RETURN; |
291 void add_comment(intptr_t offset, const char * comment) PRODUCT_RETURN; |
|
292 bool has_block_comment(intptr_t offset) const; |
292 void print_block_comment(outputStream* stream, intptr_t offset) const PRODUCT_RETURN; |
293 void print_block_comment(outputStream* stream, intptr_t offset) const PRODUCT_RETURN; |
293 // MOVE strings from other to this; invalidate other. |
294 // MOVE strings from other to this; invalidate other. |
294 void assign(CodeStrings& other) PRODUCT_RETURN; |
295 void assign(CodeStrings& other) PRODUCT_RETURN; |
295 // COPY strings from other to this; leave other valid. |
296 // COPY strings from other to this; leave other valid. |
296 void copy(CodeStrings& other) PRODUCT_RETURN; |
297 void copy(CodeStrings& other) PRODUCT_RETURN; |
297 // FREE strings; invalidate this. |
298 // FREE strings; invalidate this. |
298 void free() PRODUCT_RETURN; |
299 void free() PRODUCT_RETURN; |
|
300 |
299 // Guarantee that _strings are used at most once; assign and free invalidate a buffer. |
301 // Guarantee that _strings are used at most once; assign and free invalidate a buffer. |
300 inline void check_valid() const { |
302 inline void check_valid() const { |
301 #ifdef ASSERT |
303 #ifdef ASSERT |
302 assert(!_defunct, "Use of invalid CodeStrings"); |
304 assert(!_defunct, "Use of invalid CodeStrings"); |
303 #endif |
305 #endif |
375 address _total_start; // first address of combined memory buffer |
377 address _total_start; // first address of combined memory buffer |
376 csize_t _total_size; // size in bytes of combined memory buffer |
378 csize_t _total_size; // size in bytes of combined memory buffer |
377 |
379 |
378 OopRecorder* _oop_recorder; |
380 OopRecorder* _oop_recorder; |
379 CodeStrings _code_strings; |
381 CodeStrings _code_strings; |
|
382 bool _collect_comments; // Indicate if we need to collect block comments at all. |
380 OopRecorder _default_oop_recorder; // override with initialize_oop_recorder |
383 OopRecorder _default_oop_recorder; // override with initialize_oop_recorder |
381 Arena* _overflow_arena; |
384 Arena* _overflow_arena; |
382 |
385 |
383 address _last_insn; // used to merge consecutive memory barriers, loads or stores. |
386 address _last_insn; // used to merge consecutive memory barriers, loads or stores. |
384 |
387 |
401 _code_strings = CodeStrings(); |
404 _code_strings = CodeStrings(); |
402 _last_insn = NULL; |
405 _last_insn = NULL; |
403 #if INCLUDE_AOT |
406 #if INCLUDE_AOT |
404 _immutable_PIC = false; |
407 _immutable_PIC = false; |
405 #endif |
408 #endif |
|
409 |
|
410 // Collect block comments, but restrict collection to cases where a disassembly is output. |
|
411 _collect_comments = ( PrintAssembly |
|
412 || PrintStubCode |
|
413 || PrintMethodHandleStubs |
|
414 || PrintInterpreter |
|
415 || PrintSignatureHandlers |
|
416 ); |
406 } |
417 } |
407 |
418 |
408 void initialize(address code_start, csize_t code_size) { |
419 void initialize(address code_start, csize_t code_size) { |
409 _consts.initialize_outer(this, SECT_CONSTS); |
420 _consts.initialize_outer(this, SECT_CONSTS); |
410 _insts.initialize_outer(this, SECT_INSTS); |
421 _insts.initialize_outer(this, SECT_INSTS); |
602 if (!_code_strings.is_null()) { |
613 if (!_code_strings.is_null()) { |
603 _code_strings.free(); // sets _strings Null as a side-effect. |
614 _code_strings.free(); // sets _strings Null as a side-effect. |
604 } |
615 } |
605 } |
616 } |
606 |
617 |
|
618 // Directly disassemble code buffer. |
|
619 // Print the comment associated with offset on stream, if there is one. |
|
620 virtual void print_block_comment(outputStream* stream, address block_begin) { |
|
621 #ifndef PRODUCT |
|
622 intptr_t offset = (intptr_t)(block_begin - _total_start); // I assume total_start is not correct for all code sections. |
|
623 _code_strings.print_block_comment(stream, offset); |
|
624 #endif |
|
625 } |
|
626 bool has_block_comment(address block_begin) { |
|
627 #ifndef PRODUCT |
|
628 intptr_t offset = (intptr_t)(block_begin - _total_start); // I assume total_start is not correct for all code sections. |
|
629 return _code_strings.has_block_comment(offset); |
|
630 #else |
|
631 return false; |
|
632 #endif |
|
633 } |
|
634 |
607 // Code generation |
635 // Code generation |
608 void relocate(address at, RelocationHolder const& rspec, int format = 0) { |
636 void relocate(address at, RelocationHolder const& rspec, int format = 0) { |
609 _insts.relocate(at, rspec, format); |
637 _insts.relocate(at, rspec, format); |
610 } |
638 } |
611 void relocate(address at, relocInfo::relocType rtype, int format = 0) { |
639 void relocate(address at, relocInfo::relocType rtype, int format = 0) { |
648 // Printing / Decoding |
676 // Printing / Decoding |
649 // decodes from decode_begin() to code_end() and sets decode_begin to end |
677 // decodes from decode_begin() to code_end() and sets decode_begin to end |
650 void decode(); |
678 void decode(); |
651 void print(); |
679 void print(); |
652 #endif |
680 #endif |
653 |
681 // Directly disassemble code buffer. |
|
682 void decode(address start, address end); |
654 |
683 |
655 // The following header contains architecture-specific implementations |
684 // The following header contains architecture-specific implementations |
656 #include CPU_HEADER(codeBuffer) |
685 #include CPU_HEADER(codeBuffer) |
657 |
686 |
658 }; |
687 }; |