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