989 address tend = tstart + _total_size;
990 if (_blob != nullptr) {
991 guarantee(tstart >= _blob->content_begin(), "sanity");
992 guarantee(tend <= _blob->content_end(), "sanity");
993 }
994 // Verify disjointness.
995 for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
996 CodeSection* sect = code_section(n);
997 if (!sect->is_allocated() || sect->is_empty()) {
998 continue;
999 }
1000 guarantee(_blob == nullptr || is_aligned(sect->start(), sect->alignment()),
1001 "start is aligned");
1002 for (int m = n + 1; m < (int) SECT_LIMIT; m++) {
1003 CodeSection* other = code_section(m);
1004 if (!other->is_allocated() || other == sect) {
1005 continue;
1006 }
1007 guarantee(other->disjoint(sect), "sanity");
1008 }
1009 guarantee(sect->end() <= tend, "sanity");
1010 guarantee(sect->end() <= sect->limit(), "sanity");
1011 }
1012 }
1013
1014 void CodeBuffer::log_section_sizes(const char* name) {
1015 if (xtty != nullptr) {
1016 ttyLocker ttyl;
1017 // log info about buffer usage
1018 xtty->print_cr("<blob name='%s' total_size='%d'>", name, _total_size);
1019 for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
1020 CodeSection* sect = code_section(n);
1021 if (!sect->is_allocated() || sect->is_empty()) continue;
1022 xtty->print_cr("<sect index='%d' capacity='%d' size='%d' remaining='%d'/>",
1023 n, sect->capacity(), sect->size(), sect->remaining());
1024 }
1025 xtty->print_cr("</blob>");
1026 }
1027 }
1028
1029 bool CodeBuffer::finalize_stubs() {
1030 if (_finalize_stubs && !pd_finalize_stubs()) {
1031 // stub allocation failure
1032 return false;
1033 }
1034 _finalize_stubs = false;
1035 return true;
1036 }
1037
1038 void CodeBuffer::shared_stub_to_interp_for(ciMethod* callee, csize_t call_offset) {
1039 if (_shared_stub_to_interp_requests == nullptr) {
1040 _shared_stub_to_interp_requests = new SharedStubToInterpRequests(8);
1041 }
1042 SharedStubToInterpRequest request(callee, call_offset);
1043 _shared_stub_to_interp_requests->push(request);
1044 _finalize_stubs = true;
1045 }
1091 }
1092 }
1093
1094 CHeapString::~CHeapString() {
1095 os::free((void*)_string);
1096 _string = nullptr;
1097 }
1098
1099 // ----- AsmRemarks ------------------------------------------------------------
1100 //
1101 // Acting as interface to reference counted mapping [offset -> remark], where
1102 // offset is a byte offset into an instruction stream (CodeBuffer, CodeBlob or
1103 // other memory buffer) and remark is a string (comment).
1104 //
1105 AsmRemarks::AsmRemarks() {
1106 init();
1107 assert(_remarks != nullptr, "Allocation failure!");
1108 }
1109
1110 AsmRemarks::~AsmRemarks() {
1111 assert(_remarks == nullptr, "Must 'clear()' before deleting!");
1112 }
1113
1114 void AsmRemarks::init() {
1115 _remarks = new AsmRemarkCollection();
1116 }
1117
1118 const char* AsmRemarks::insert(uint offset, const char* remstr) {
1119 precond(remstr != nullptr);
1120 return _remarks->insert(offset, remstr);
1121 }
1122
1123 bool AsmRemarks::is_empty() const {
1124 return _remarks->is_empty();
1125 }
1126
1127 void AsmRemarks::share(const AsmRemarks &src) {
1128 precond(_remarks == nullptr || is_empty());
1129 clear();
1130 _remarks = src._remarks->reuse();
1131 }
1148 strm->print_raw(remstr);
1149 // Advance to next line iff string didn't contain a cr() at the end.
1150 strm->bol();
1151 remstr = _remarks->next(offset);
1152 count++;
1153 }
1154 return count;
1155 }
1156
1157 // ----- DbgStrings ------------------------------------------------------------
1158 //
1159 // Acting as interface to reference counted collection of (debug) strings used
1160 // in the code generated, and thus requiring a fixed address.
1161 //
1162 DbgStrings::DbgStrings() {
1163 init();
1164 assert(_strings != nullptr, "Allocation failure!");
1165 }
1166
1167 DbgStrings::~DbgStrings() {
1168 assert(_strings == nullptr, "Must 'clear()' before deleting!");
1169 }
1170
1171 void DbgStrings::init() {
1172 _strings = new DbgStringCollection();
1173 }
1174
1175 const char* DbgStrings::insert(const char* dbgstr) {
1176 const char* str = _strings->lookup(dbgstr);
1177 return str != nullptr ? str : _strings->insert(dbgstr);
1178 }
1179
1180 bool DbgStrings::is_empty() const {
1181 return _strings->is_empty();
1182 }
1183
1184 void DbgStrings::share(const DbgStrings &src) {
1185 precond(_strings == nullptr || is_empty());
1186 clear();
1187 _strings = src._strings->reuse();
1188 }
|
989 address tend = tstart + _total_size;
990 if (_blob != nullptr) {
991 guarantee(tstart >= _blob->content_begin(), "sanity");
992 guarantee(tend <= _blob->content_end(), "sanity");
993 }
994 // Verify disjointness.
995 for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
996 CodeSection* sect = code_section(n);
997 if (!sect->is_allocated() || sect->is_empty()) {
998 continue;
999 }
1000 guarantee(_blob == nullptr || is_aligned(sect->start(), sect->alignment()),
1001 "start is aligned");
1002 for (int m = n + 1; m < (int) SECT_LIMIT; m++) {
1003 CodeSection* other = code_section(m);
1004 if (!other->is_allocated() || other == sect) {
1005 continue;
1006 }
1007 guarantee(other->disjoint(sect), "sanity");
1008 }
1009 guarantee(sect->end() <= tend, "sanity, sect_end: " PTR_FORMAT " tend: " PTR_FORMAT " size: %d", p2i(sect->end()), p2i(tend), (int)_total_size);
1010 guarantee(sect->end() <= sect->limit(), "sanity, sect_end: " PTR_FORMAT " sect_limit: " PTR_FORMAT, p2i(sect->end()), p2i(sect->limit()));
1011 }
1012 }
1013
1014 void CodeBuffer::log_section_sizes(const char* name) {
1015 if (xtty != nullptr) {
1016 ttyLocker ttyl;
1017 // log info about buffer usage
1018 xtty->head("blob name='%s' total_size='%d'", name, _total_size);
1019 for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
1020 CodeSection* sect = code_section(n);
1021 if (!sect->is_allocated() || sect->is_empty()) continue;
1022 xtty->elem("sect index='%d' capacity='%d' size='%d' remaining='%d'",
1023 n, sect->capacity(), sect->size(), sect->remaining());
1024 }
1025 xtty->tail("blob");
1026 }
1027 }
1028
1029 bool CodeBuffer::finalize_stubs() {
1030 if (_finalize_stubs && !pd_finalize_stubs()) {
1031 // stub allocation failure
1032 return false;
1033 }
1034 _finalize_stubs = false;
1035 return true;
1036 }
1037
1038 void CodeBuffer::shared_stub_to_interp_for(ciMethod* callee, csize_t call_offset) {
1039 if (_shared_stub_to_interp_requests == nullptr) {
1040 _shared_stub_to_interp_requests = new SharedStubToInterpRequests(8);
1041 }
1042 SharedStubToInterpRequest request(callee, call_offset);
1043 _shared_stub_to_interp_requests->push(request);
1044 _finalize_stubs = true;
1045 }
1091 }
1092 }
1093
1094 CHeapString::~CHeapString() {
1095 os::free((void*)_string);
1096 _string = nullptr;
1097 }
1098
1099 // ----- AsmRemarks ------------------------------------------------------------
1100 //
1101 // Acting as interface to reference counted mapping [offset -> remark], where
1102 // offset is a byte offset into an instruction stream (CodeBuffer, CodeBlob or
1103 // other memory buffer) and remark is a string (comment).
1104 //
1105 AsmRemarks::AsmRemarks() {
1106 init();
1107 assert(_remarks != nullptr, "Allocation failure!");
1108 }
1109
1110 AsmRemarks::~AsmRemarks() {
1111 if (_remarks != nullptr) {
1112 clear();
1113 }
1114 assert(_remarks == nullptr, "must be");
1115 }
1116
1117 void AsmRemarks::init() {
1118 _remarks = new AsmRemarkCollection();
1119 }
1120
1121 const char* AsmRemarks::insert(uint offset, const char* remstr) {
1122 precond(remstr != nullptr);
1123 return _remarks->insert(offset, remstr);
1124 }
1125
1126 bool AsmRemarks::is_empty() const {
1127 return _remarks->is_empty();
1128 }
1129
1130 void AsmRemarks::share(const AsmRemarks &src) {
1131 precond(_remarks == nullptr || is_empty());
1132 clear();
1133 _remarks = src._remarks->reuse();
1134 }
1151 strm->print_raw(remstr);
1152 // Advance to next line iff string didn't contain a cr() at the end.
1153 strm->bol();
1154 remstr = _remarks->next(offset);
1155 count++;
1156 }
1157 return count;
1158 }
1159
1160 // ----- DbgStrings ------------------------------------------------------------
1161 //
1162 // Acting as interface to reference counted collection of (debug) strings used
1163 // in the code generated, and thus requiring a fixed address.
1164 //
1165 DbgStrings::DbgStrings() {
1166 init();
1167 assert(_strings != nullptr, "Allocation failure!");
1168 }
1169
1170 DbgStrings::~DbgStrings() {
1171 if (_strings != nullptr) {
1172 clear();
1173 }
1174 assert(_strings == nullptr, "must be");
1175 }
1176
1177 void DbgStrings::init() {
1178 _strings = new DbgStringCollection();
1179 }
1180
1181 const char* DbgStrings::insert(const char* dbgstr) {
1182 const char* str = _strings->lookup(dbgstr);
1183 return str != nullptr ? str : _strings->insert(dbgstr);
1184 }
1185
1186 bool DbgStrings::is_empty() const {
1187 return _strings->is_empty();
1188 }
1189
1190 void DbgStrings::share(const DbgStrings &src) {
1191 precond(_strings == nullptr || is_empty());
1192 clear();
1193 _strings = src._strings->reuse();
1194 }
|