12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/codeBuffer.hpp"
27 #include "code/compiledIC.hpp"
28 #include "code/oopRecorder.inline.hpp"
29 #include "compiler/disassembler.hpp"
30 #include "logging/log.hpp"
31 #include "oops/klass.inline.hpp"
32 #include "oops/methodData.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/icache.hpp"
35 #include "runtime/safepointVerifiers.hpp"
36 #include "utilities/align.hpp"
37 #include "utilities/copy.hpp"
38 #include "utilities/powerOfTwo.hpp"
39 #include "utilities/xmlstream.hpp"
40
41 // The structure of a CodeSection:
42 //
43 // _start -> +----------------+
44 // | machine code...|
45 // _end -> |----------------|
46 // | |
47 // | (empty) |
48 // | |
49 // | |
50 // +----------------+
51 // _limit -> | |
520 void CodeBuffer::finalize_oop_references(const methodHandle& mh) {
521 NoSafepointVerifier nsv;
522
523 GrowableArray<oop> oops;
524
525 // Make sure that immediate metadata records something in the OopRecorder
526 for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
527 // pull code out of each section
528 CodeSection* cs = code_section(n);
529 if (cs->is_empty() || (cs->locs_count() == 0)) continue; // skip trivial section
530 RelocIterator iter(cs);
531 while (iter.next()) {
532 if (iter.type() == relocInfo::metadata_type) {
533 metadata_Relocation* md = iter.metadata_reloc();
534 if (md->metadata_is_immediate()) {
535 Metadata* m = md->metadata_value();
536 if (oop_recorder()->is_real(m)) {
537 if (m->is_methodData()) {
538 m = ((MethodData*)m)->method();
539 }
540 if (m->is_method()) {
541 m = ((Method*)m)->method_holder();
542 }
543 if (m->is_klass()) {
544 append_oop_references(&oops, (Klass*)m);
545 } else {
546 // XXX This will currently occur for MDO which don't
547 // have a backpointer. This has to be fixed later.
548 m->print();
549 ShouldNotReachHere();
550 }
551 }
552 }
553 }
554 }
555 }
556
557 if (!oop_recorder()->is_unused()) {
558 for (int i = 0; i < oop_recorder()->metadata_count(); i++) {
559 Metadata* m = oop_recorder()->metadata_at(i);
560 if (oop_recorder()->is_real(m)) {
561 if (m->is_methodData()) {
562 m = ((MethodData*)m)->method();
563 }
564 if (m->is_method()) {
565 m = ((Method*)m)->method_holder();
566 }
567 if (m->is_klass()) {
568 append_oop_references(&oops, (Klass*)m);
569 } else {
570 m->print();
571 ShouldNotReachHere();
572 }
573 }
574 }
575
576 }
577
578 // Add the class loader of Method* for the nmethod itself
579 append_oop_references(&oops, mh->method_holder());
580
581 // Add any oops that we've found
582 Thread* thread = Thread::current();
583 for (int i = 0; i < oops.length(); i++) {
706 csize_t CodeBuffer::copy_relocations_to(CodeBlob* dest) const {
707 address buf = nullptr;
708 csize_t buf_offset = 0;
709 csize_t buf_limit = 0;
710
711 if (dest != nullptr) {
712 buf = (address)dest->relocation_begin();
713 buf_limit = (address)dest->relocation_end() - buf;
714 }
715 // if dest is null, this is just the sizing pass
716 //
717 buf_offset = copy_relocations_to(buf, buf_limit, false);
718
719 return buf_offset;
720 }
721
722 void CodeBuffer::copy_code_to(CodeBlob* dest_blob) {
723 #ifndef PRODUCT
724 if (PrintNMethods && (WizardMode || Verbose)) {
725 tty->print("done with CodeBuffer:");
726 ((CodeBuffer*)this)->print();
727 }
728 #endif //PRODUCT
729
730 CodeBuffer dest(dest_blob);
731 assert(dest_blob->content_size() >= total_content_size(), "good sizing");
732 this->compute_final_layout(&dest);
733
734 // Set beginning of constant table before relocating.
735 dest_blob->set_ctable_begin(dest.consts()->start());
736
737 relocate_code_to(&dest);
738
739 // Share assembly remarks and debug strings with the blob.
740 NOT_PRODUCT(dest_blob->use_remarks(_asm_remarks));
741 NOT_PRODUCT(dest_blob->use_strings(_dbg_strings));
742
743 // Done moving code bytes; were they the right size?
744 assert((int)align_up(dest.total_content_size(), oopSize) == dest_blob->content_size(), "sanity");
745
746 // Flush generated code
845 exp = 0;
846 }
847 // Allow for inter-section slop:
848 exp += CodeSection::end_slop();
849 csize_t new_cap = sect->size() + exp;
850 if (new_cap < sect->capacity()) {
851 // No need to expand after all.
852 new_cap = sect->capacity();
853 }
854 new_capacity[n] = new_cap;
855 new_total_cap += new_cap;
856 }
857
858 return new_total_cap;
859 }
860
861 void CodeBuffer::expand(CodeSection* which_cs, csize_t amount) {
862 #ifndef PRODUCT
863 if (PrintNMethods && (WizardMode || Verbose)) {
864 tty->print("expanding CodeBuffer:");
865 this->print();
866 }
867
868 if (StressCodeBuffers && blob() != nullptr) {
869 static int expand_count = 0;
870 if (expand_count >= 0) expand_count += 1;
871 if (expand_count > 100 && is_power_of_2(expand_count)) {
872 tty->print_cr("StressCodeBuffers: have expanded %d times", expand_count);
873 // simulate an occasional allocation failure:
874 free_blob();
875 }
876 }
877 #endif //PRODUCT
878
879 // Resizing must be allowed
880 {
881 if (blob() == nullptr) return; // caller must check if blob is null
882 }
883
884 // Figure new capacity for each section.
885 csize_t new_capacity[SECT_LIMIT];
932 // some internal addresses, _last_insn _last_label, are used during code emission,
933 // adjust them in expansion
934 adjust_internal_address(insts_begin(), cb.insts_begin());
935
936 // Copy the temporary code buffer into the current code buffer.
937 // Basically, do {*this = cb}, except for some control information.
938 this->take_over_code_from(&cb);
939 cb.set_blob(nullptr);
940
941 // Zap the old code buffer contents, to avoid mistakenly using them.
942 debug_only(Copy::fill_to_bytes(bxp->_total_start, bxp->_total_size,
943 badCodeHeapFreeVal);)
944
945 // Make certain that the new sections are all snugly inside the new blob.
946 debug_only(verify_section_allocation();)
947
948 #ifndef PRODUCT
949 _decode_begin = nullptr; // sanity
950 if (PrintNMethods && (WizardMode || Verbose)) {
951 tty->print("expanded CodeBuffer:");
952 this->print();
953 }
954 #endif //PRODUCT
955 }
956
957 void CodeBuffer::adjust_internal_address(address from, address to) {
958 if (_last_insn != nullptr) {
959 _last_insn += to - from;
960 }
961 if (_last_label != nullptr) {
962 _last_label += to - from;
963 }
964 }
965
966 void CodeBuffer::take_over_code_from(CodeBuffer* cb) {
967 // Must already have disposed of the old blob somehow.
968 assert(blob() == nullptr, "must be empty");
969 // Take the new blob away from cb.
970 set_blob(cb->blob());
971 // Take over all the section pointers.
972 for (int n = 0; n < (int)SECT_LIMIT; n++) {
984 address tend = tstart + _total_size;
985 if (_blob != nullptr) {
986 guarantee(tstart >= _blob->content_begin(), "sanity");
987 guarantee(tend <= _blob->content_end(), "sanity");
988 }
989 // Verify disjointness.
990 for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
991 CodeSection* sect = code_section(n);
992 if (!sect->is_allocated() || sect->is_empty()) {
993 continue;
994 }
995 guarantee(_blob == nullptr || is_aligned(sect->start(), sect->alignment()),
996 "start is aligned");
997 for (int m = n + 1; m < (int) SECT_LIMIT; m++) {
998 CodeSection* other = code_section(m);
999 if (!other->is_allocated() || other == sect) {
1000 continue;
1001 }
1002 guarantee(other->disjoint(sect), "sanity");
1003 }
1004 guarantee(sect->end() <= tend, "sanity");
1005 guarantee(sect->end() <= sect->limit(), "sanity");
1006 }
1007 }
1008
1009 void CodeBuffer::log_section_sizes(const char* name) {
1010 if (xtty != nullptr) {
1011 ttyLocker ttyl;
1012 // log info about buffer usage
1013 xtty->print_cr("<blob name='%s' total_size='%d'>", name, _total_size);
1014 for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
1015 CodeSection* sect = code_section(n);
1016 if (!sect->is_allocated() || sect->is_empty()) continue;
1017 xtty->print_cr("<sect index='%d' capacity='%d' size='%d' remaining='%d'/>",
1018 n, sect->capacity(), sect->size(), sect->remaining());
1019 }
1020 xtty->print_cr("</blob>");
1021 }
1022 }
1023
1024 bool CodeBuffer::finalize_stubs() {
1025 if (_finalize_stubs && !pd_finalize_stubs()) {
1026 // stub allocation failure
1027 return false;
1028 }
1029 _finalize_stubs = false;
1030 return true;
1031 }
1032
1033 void CodeBuffer::shared_stub_to_interp_for(ciMethod* callee, csize_t call_offset) {
1034 if (_shared_stub_to_interp_requests == nullptr) {
1035 _shared_stub_to_interp_requests = new SharedStubToInterpRequests(8);
1036 }
1037 SharedStubToInterpRequest request(callee, call_offset);
1038 _shared_stub_to_interp_requests->push(request);
1039 _finalize_stubs = true;
1040 }
1042 #ifndef PRODUCT
1043 void CodeBuffer::block_comment(ptrdiff_t offset, const char* comment) {
1044 if (_collect_comments) {
1045 const char* str = _asm_remarks.insert(offset, comment);
1046 postcond(str != comment);
1047 }
1048 }
1049
1050 const char* CodeBuffer::code_string(const char* str) {
1051 const char* tmp = _dbg_strings.insert(str);
1052 postcond(tmp != str);
1053 return tmp;
1054 }
1055
1056 void CodeBuffer::decode() {
1057 ttyLocker ttyl;
1058 Disassembler::decode(decode_begin(), insts_end(), tty NOT_PRODUCT(COMMA &asm_remarks()));
1059 _decode_begin = insts_end();
1060 }
1061
1062 void CodeSection::print(const char* name) {
1063 csize_t locs_size = locs_end() - locs_start();
1064 tty->print_cr(" %7s.code = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d)",
1065 name, p2i(start()), p2i(end()), p2i(limit()), size(), capacity());
1066 tty->print_cr(" %7s.locs = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d) point=%d",
1067 name, p2i(locs_start()), p2i(locs_end()), p2i(locs_limit()), locs_size, locs_capacity(), locs_point_off());
1068 if (PrintRelocations && (locs_size != 0)) {
1069 RelocIterator iter(this);
1070 iter.print();
1071 }
1072 }
1073
1074 void CodeBuffer::print() {
1075 tty->print_cr("CodeBuffer:");
1076 for (int n = 0; n < (int)SECT_LIMIT; n++) {
1077 // print each section
1078 CodeSection* cs = code_section(n);
1079 cs->print(code_section_name(n));
1080 }
1081 }
1082
1083 // ----- CHeapString -----------------------------------------------------------
1084
1085 class CHeapString : public CHeapObj<mtCode> {
1086 public:
1087 CHeapString(const char* str) : _string(os::strdup(str)) {}
1088 ~CHeapString() {
1089 os::free((void*)_string);
1090 _string = nullptr;
1091 }
1092 const char* string() const { return _string; }
1093
1094 private:
1095 const char* _string;
1096 };
1097
1098 // ----- AsmRemarkCollection ---------------------------------------------------
1099
|
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "asm/codeBuffer.hpp"
27 #include "code/compiledIC.hpp"
28 #include "code/oopRecorder.inline.hpp"
29 #include "compiler/disassembler.hpp"
30 #include "logging/log.hpp"
31 #include "oops/klass.inline.hpp"
32 #include "oops/methodCounters.hpp"
33 #include "oops/methodData.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "runtime/icache.hpp"
36 #include "runtime/safepointVerifiers.hpp"
37 #include "utilities/align.hpp"
38 #include "utilities/copy.hpp"
39 #include "utilities/powerOfTwo.hpp"
40 #include "utilities/xmlstream.hpp"
41
42 // The structure of a CodeSection:
43 //
44 // _start -> +----------------+
45 // | machine code...|
46 // _end -> |----------------|
47 // | |
48 // | (empty) |
49 // | |
50 // | |
51 // +----------------+
52 // _limit -> | |
521 void CodeBuffer::finalize_oop_references(const methodHandle& mh) {
522 NoSafepointVerifier nsv;
523
524 GrowableArray<oop> oops;
525
526 // Make sure that immediate metadata records something in the OopRecorder
527 for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
528 // pull code out of each section
529 CodeSection* cs = code_section(n);
530 if (cs->is_empty() || (cs->locs_count() == 0)) continue; // skip trivial section
531 RelocIterator iter(cs);
532 while (iter.next()) {
533 if (iter.type() == relocInfo::metadata_type) {
534 metadata_Relocation* md = iter.metadata_reloc();
535 if (md->metadata_is_immediate()) {
536 Metadata* m = md->metadata_value();
537 if (oop_recorder()->is_real(m)) {
538 if (m->is_methodData()) {
539 m = ((MethodData*)m)->method();
540 }
541 if (m->is_methodCounters()) {
542 m = ((MethodCounters*)m)->method();
543 }
544 if (m->is_method()) {
545 m = ((Method*)m)->method_holder();
546 }
547 if (m->is_klass()) {
548 append_oop_references(&oops, (Klass*)m);
549 } else {
550 // XXX This will currently occur for MDO which don't
551 // have a backpointer. This has to be fixed later.
552 m->print();
553 ShouldNotReachHere();
554 }
555 }
556 }
557 }
558 }
559 }
560
561 if (!oop_recorder()->is_unused()) {
562 for (int i = 0; i < oop_recorder()->metadata_count(); i++) {
563 Metadata* m = oop_recorder()->metadata_at(i);
564 if (oop_recorder()->is_real(m)) {
565 if (m->is_methodData()) {
566 m = ((MethodData*)m)->method();
567 }
568 if (m->is_methodCounters()) {
569 m = ((MethodCounters*)m)->method();
570 }
571 if (m->is_method()) {
572 m = ((Method*)m)->method_holder();
573 }
574 if (m->is_klass()) {
575 append_oop_references(&oops, (Klass*)m);
576 } else {
577 m->print();
578 ShouldNotReachHere();
579 }
580 }
581 }
582
583 }
584
585 // Add the class loader of Method* for the nmethod itself
586 append_oop_references(&oops, mh->method_holder());
587
588 // Add any oops that we've found
589 Thread* thread = Thread::current();
590 for (int i = 0; i < oops.length(); i++) {
713 csize_t CodeBuffer::copy_relocations_to(CodeBlob* dest) const {
714 address buf = nullptr;
715 csize_t buf_offset = 0;
716 csize_t buf_limit = 0;
717
718 if (dest != nullptr) {
719 buf = (address)dest->relocation_begin();
720 buf_limit = (address)dest->relocation_end() - buf;
721 }
722 // if dest is null, this is just the sizing pass
723 //
724 buf_offset = copy_relocations_to(buf, buf_limit, false);
725
726 return buf_offset;
727 }
728
729 void CodeBuffer::copy_code_to(CodeBlob* dest_blob) {
730 #ifndef PRODUCT
731 if (PrintNMethods && (WizardMode || Verbose)) {
732 tty->print("done with CodeBuffer:");
733 ((CodeBuffer*)this)->print_on(tty);
734 }
735 #endif //PRODUCT
736
737 CodeBuffer dest(dest_blob);
738 assert(dest_blob->content_size() >= total_content_size(), "good sizing");
739 this->compute_final_layout(&dest);
740
741 // Set beginning of constant table before relocating.
742 dest_blob->set_ctable_begin(dest.consts()->start());
743
744 relocate_code_to(&dest);
745
746 // Share assembly remarks and debug strings with the blob.
747 NOT_PRODUCT(dest_blob->use_remarks(_asm_remarks));
748 NOT_PRODUCT(dest_blob->use_strings(_dbg_strings));
749
750 // Done moving code bytes; were they the right size?
751 assert((int)align_up(dest.total_content_size(), oopSize) == dest_blob->content_size(), "sanity");
752
753 // Flush generated code
852 exp = 0;
853 }
854 // Allow for inter-section slop:
855 exp += CodeSection::end_slop();
856 csize_t new_cap = sect->size() + exp;
857 if (new_cap < sect->capacity()) {
858 // No need to expand after all.
859 new_cap = sect->capacity();
860 }
861 new_capacity[n] = new_cap;
862 new_total_cap += new_cap;
863 }
864
865 return new_total_cap;
866 }
867
868 void CodeBuffer::expand(CodeSection* which_cs, csize_t amount) {
869 #ifndef PRODUCT
870 if (PrintNMethods && (WizardMode || Verbose)) {
871 tty->print("expanding CodeBuffer:");
872 this->print_on(tty);
873 }
874
875 if (StressCodeBuffers && blob() != nullptr) {
876 static int expand_count = 0;
877 if (expand_count >= 0) expand_count += 1;
878 if (expand_count > 100 && is_power_of_2(expand_count)) {
879 tty->print_cr("StressCodeBuffers: have expanded %d times", expand_count);
880 // simulate an occasional allocation failure:
881 free_blob();
882 }
883 }
884 #endif //PRODUCT
885
886 // Resizing must be allowed
887 {
888 if (blob() == nullptr) return; // caller must check if blob is null
889 }
890
891 // Figure new capacity for each section.
892 csize_t new_capacity[SECT_LIMIT];
939 // some internal addresses, _last_insn _last_label, are used during code emission,
940 // adjust them in expansion
941 adjust_internal_address(insts_begin(), cb.insts_begin());
942
943 // Copy the temporary code buffer into the current code buffer.
944 // Basically, do {*this = cb}, except for some control information.
945 this->take_over_code_from(&cb);
946 cb.set_blob(nullptr);
947
948 // Zap the old code buffer contents, to avoid mistakenly using them.
949 debug_only(Copy::fill_to_bytes(bxp->_total_start, bxp->_total_size,
950 badCodeHeapFreeVal);)
951
952 // Make certain that the new sections are all snugly inside the new blob.
953 debug_only(verify_section_allocation();)
954
955 #ifndef PRODUCT
956 _decode_begin = nullptr; // sanity
957 if (PrintNMethods && (WizardMode || Verbose)) {
958 tty->print("expanded CodeBuffer:");
959 this->print_on(tty);
960 }
961 #endif //PRODUCT
962 }
963
964 void CodeBuffer::adjust_internal_address(address from, address to) {
965 if (_last_insn != nullptr) {
966 _last_insn += to - from;
967 }
968 if (_last_label != nullptr) {
969 _last_label += to - from;
970 }
971 }
972
973 void CodeBuffer::take_over_code_from(CodeBuffer* cb) {
974 // Must already have disposed of the old blob somehow.
975 assert(blob() == nullptr, "must be empty");
976 // Take the new blob away from cb.
977 set_blob(cb->blob());
978 // Take over all the section pointers.
979 for (int n = 0; n < (int)SECT_LIMIT; n++) {
991 address tend = tstart + _total_size;
992 if (_blob != nullptr) {
993 guarantee(tstart >= _blob->content_begin(), "sanity");
994 guarantee(tend <= _blob->content_end(), "sanity");
995 }
996 // Verify disjointness.
997 for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
998 CodeSection* sect = code_section(n);
999 if (!sect->is_allocated() || sect->is_empty()) {
1000 continue;
1001 }
1002 guarantee(_blob == nullptr || is_aligned(sect->start(), sect->alignment()),
1003 "start is aligned");
1004 for (int m = n + 1; m < (int) SECT_LIMIT; m++) {
1005 CodeSection* other = code_section(m);
1006 if (!other->is_allocated() || other == sect) {
1007 continue;
1008 }
1009 guarantee(other->disjoint(sect), "sanity");
1010 }
1011 guarantee(sect->end() <= tend, "sanity, sect_end: " PTR_FORMAT " tend: " PTR_FORMAT " size: %d", p2i(sect->end()), p2i(tend), (int)_total_size);
1012 guarantee(sect->end() <= sect->limit(), "sanity, sect_end: " PTR_FORMAT " sect_limit: " PTR_FORMAT, p2i(sect->end()), p2i(sect->limit()));
1013 }
1014 }
1015
1016 void CodeBuffer::log_section_sizes(const char* name) {
1017 if (xtty != nullptr) {
1018 ttyLocker ttyl;
1019 // log info about buffer usage
1020 xtty->head("blob name='%s' total_size='%d'", name, _total_size);
1021 for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
1022 CodeSection* sect = code_section(n);
1023 if (!sect->is_allocated() || sect->is_empty()) continue;
1024 xtty->elem("sect index='%d' capacity='%d' size='%d' remaining='%d'",
1025 n, sect->capacity(), sect->size(), sect->remaining());
1026 }
1027 xtty->tail("blob");
1028 }
1029 }
1030
1031 bool CodeBuffer::finalize_stubs() {
1032 if (_finalize_stubs && !pd_finalize_stubs()) {
1033 // stub allocation failure
1034 return false;
1035 }
1036 _finalize_stubs = false;
1037 return true;
1038 }
1039
1040 void CodeBuffer::shared_stub_to_interp_for(ciMethod* callee, csize_t call_offset) {
1041 if (_shared_stub_to_interp_requests == nullptr) {
1042 _shared_stub_to_interp_requests = new SharedStubToInterpRequests(8);
1043 }
1044 SharedStubToInterpRequest request(callee, call_offset);
1045 _shared_stub_to_interp_requests->push(request);
1046 _finalize_stubs = true;
1047 }
1049 #ifndef PRODUCT
1050 void CodeBuffer::block_comment(ptrdiff_t offset, const char* comment) {
1051 if (_collect_comments) {
1052 const char* str = _asm_remarks.insert(offset, comment);
1053 postcond(str != comment);
1054 }
1055 }
1056
1057 const char* CodeBuffer::code_string(const char* str) {
1058 const char* tmp = _dbg_strings.insert(str);
1059 postcond(tmp != str);
1060 return tmp;
1061 }
1062
1063 void CodeBuffer::decode() {
1064 ttyLocker ttyl;
1065 Disassembler::decode(decode_begin(), insts_end(), tty NOT_PRODUCT(COMMA &asm_remarks()));
1066 _decode_begin = insts_end();
1067 }
1068
1069 void CodeSection::print_on(outputStream* st, const char* name) {
1070 csize_t locs_size = locs_end() - locs_start();
1071 st->print_cr(" %7s.code = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d)",
1072 name, p2i(start()), p2i(end()), p2i(limit()), size(), capacity());
1073 st->print_cr(" %7s.locs = " PTR_FORMAT " : " PTR_FORMAT " : " PTR_FORMAT " (%d of %d) point=%d",
1074 name, p2i(locs_start()), p2i(locs_end()), p2i(locs_limit()), locs_size, locs_capacity(), locs_point_off());
1075 if (PrintRelocations && (locs_size != 0)) {
1076 RelocIterator iter(this);
1077 iter.print_on(st);
1078 }
1079 }
1080
1081 void CodeBuffer::print_on(outputStream* st) {
1082 #if 0
1083 if (this == nullptr) { // gcc complains 'nonnull' argument 'this' compared to NULL
1084 st->print_cr("null CodeBuffer pointer");
1085 return;
1086 }
1087 #endif
1088
1089 st->print_cr("CodeBuffer:%s", name());
1090 for (int n = 0; n < (int)SECT_LIMIT; n++) {
1091 // print each section
1092 CodeSection* cs = code_section(n);
1093 cs->print_on(st, code_section_name(n));
1094 }
1095 }
1096
1097 // ----- CHeapString -----------------------------------------------------------
1098
1099 class CHeapString : public CHeapObj<mtCode> {
1100 public:
1101 CHeapString(const char* str) : _string(os::strdup(str)) {}
1102 ~CHeapString() {
1103 os::free((void*)_string);
1104 _string = nullptr;
1105 }
1106 const char* string() const { return _string; }
1107
1108 private:
1109 const char* _string;
1110 };
1111
1112 // ----- AsmRemarkCollection ---------------------------------------------------
1113
|