@@ -140,7 +140,7 @@ CodeBuffer::~CodeBuffer() {
140
140
141
141
// Claim is that stack allocation ensures resources are cleaned up.
142
142
// This is resource clean up, let's hope that all were properly copied out.
143
- free_strings ();
143
+ NOT_PRODUCT ( free_strings ();)
144
144
145
145
#ifdef ASSERT
146
146
// Save allocation type to execute assert in ~ResourceObj()
@@ -267,13 +267,14 @@ bool CodeBuffer::is_backward_branch(Label& L) {
267
267
return L.is_bound () && insts_end () <= locator_address (L.loc ());
268
268
}
269
269
270
+ #ifndef PRODUCT
270
271
address CodeBuffer::decode_begin () {
271
272
address begin = _insts.start ();
272
273
if (_decode_begin != NULL && _decode_begin > begin)
273
274
begin = _decode_begin;
274
275
return begin;
275
276
}
276
-
277
+ # endif // !PRODUCT
277
278
278
279
GrowableArray<int >* CodeBuffer::create_patch_overflow () {
279
280
if (_overflow_arena == NULL ) {
@@ -752,7 +753,7 @@ void CodeBuffer::copy_code_to(CodeBlob* dest_blob) {
752
753
relocate_code_to (&dest);
753
754
754
755
// transfer strings and comments from buffer to blob
755
- dest_blob->set_strings (_code_strings);
756
+ NOT_PRODUCT ( dest_blob->set_strings (_code_strings);)
756
757
757
758
// Done moving code bytes; were they the right size?
758
759
assert ((int )align_up (dest.total_content_size (), oopSize) == dest_blob->content_size (), " sanity" );
@@ -957,12 +958,11 @@ void CodeBuffer::expand(CodeSection* which_cs, csize_t amount) {
957
958
debug_only (Copy::fill_to_bytes (bxp->_total_start , bxp->_total_size ,
958
959
badCodeHeapFreeVal));
959
960
960
- _decode_begin = NULL ; // sanity
961
-
962
961
// Make certain that the new sections are all snugly inside the new blob.
963
962
verify_section_allocation ();
964
963
965
964
#ifndef PRODUCT
965
+ _decode_begin = NULL ; // sanity
966
966
if (PrintNMethods && (WizardMode || Verbose)) {
967
967
tty->print (" expanded CodeBuffer:" );
968
968
this ->print ();
@@ -1032,10 +1032,6 @@ void CodeBuffer::log_section_sizes(const char* name) {
1032
1032
1033
1033
#ifndef PRODUCT
1034
1034
1035
- void CodeSection::decode () {
1036
- Disassembler::decode (start (), end ());
1037
- }
1038
-
1039
1035
void CodeBuffer::block_comment (intptr_t offset, const char * comment) {
1040
1036
if (_collect_comments) {
1041
1037
_code_strings.add_comment (offset, comment);
@@ -1054,8 +1050,12 @@ class CodeString: public CHeapObj<mtCode> {
1054
1050
CodeString* _prev;
1055
1051
intptr_t _offset;
1056
1052
1053
+ static long allocated_code_strings;
1054
+
1057
1055
~CodeString () {
1058
1056
assert (_next == NULL && _prev == NULL , " wrong interface for freeing list" );
1057
+ allocated_code_strings--;
1058
+ log_trace (codestrings)(" Freeing CodeString [%s] (%p)" , _string, (void *)_string);
1059
1059
os::free ((void *)_string);
1060
1060
}
1061
1061
@@ -1064,12 +1064,14 @@ class CodeString: public CHeapObj<mtCode> {
1064
1064
public:
1065
1065
CodeString (const char * string, intptr_t offset = -1 )
1066
1066
: _next(NULL ), _prev(NULL ), _offset(offset) {
1067
+ allocated_code_strings++;
1067
1068
_string = os::strdup (string, mtCode);
1069
+ log_trace (codestrings)(" Created CodeString [%s] (%p)" , _string, (void *)_string);
1068
1070
}
1069
1071
1070
1072
const char * string () const { return _string; }
1071
1073
intptr_t offset () const { assert (_offset >= 0 , " offset for non comment?" ); return _offset; }
1072
- CodeString* next () const { return _next; }
1074
+ CodeString* next () const { return _next; }
1073
1075
1074
1076
void set_next (CodeString* next) {
1075
1077
_next = next;
@@ -1094,6 +1096,10 @@ class CodeString: public CHeapObj<mtCode> {
1094
1096
}
1095
1097
};
1096
1098
1099
+ // For tracing statistics. Will use raw increment/decrement, so it might not be
1100
+ // exact
1101
+ long CodeString::allocated_code_strings = 0 ;
1102
+
1097
1103
CodeString* CodeStrings::find (intptr_t offset) const {
1098
1104
CodeString* a = _strings->first_comment ();
1099
1105
while (a != NULL && a->offset () != offset) {
@@ -1116,7 +1122,7 @@ void CodeStrings::add_comment(intptr_t offset, const char * comment) {
1116
1122
CodeString* c = new CodeString (comment, offset);
1117
1123
CodeString* inspos = (_strings == NULL ) ? NULL : find_last (offset);
1118
1124
1119
- if (inspos) {
1125
+ if (inspos != NULL ) {
1120
1126
// insert after already existing comments with same offset
1121
1127
c->set_next (inspos->next ());
1122
1128
inspos->set_next (c);
@@ -1130,29 +1136,22 @@ void CodeStrings::add_comment(intptr_t offset, const char * comment) {
1130
1136
}
1131
1137
}
1132
1138
1133
- void CodeStrings::assign (CodeStrings& other) {
1134
- other.check_valid ();
1135
- assert (is_null (), " Cannot assign onto non-empty CodeStrings" );
1136
- _strings = other._strings ;
1137
- _strings_last = other._strings_last ;
1138
- #ifdef ASSERT
1139
- _defunct = false ;
1140
- #endif
1141
- other.set_null_and_invalidate ();
1142
- }
1143
-
1144
1139
// Deep copy of CodeStrings for consistent memory management.
1145
- // Only used for actual disassembly so this is cheaper than reference counting
1146
- // for the "normal" fastdebug case.
1147
1140
void CodeStrings::copy (CodeStrings& other) {
1141
+ log_debug (codestrings)(" Copying %d Codestring(s)" , other.count ());
1142
+
1148
1143
other.check_valid ();
1149
1144
check_valid ();
1150
1145
assert (is_null (), " Cannot copy onto non-empty CodeStrings" );
1151
1146
CodeString* n = other._strings ;
1152
1147
CodeString** ps = &_strings;
1153
1148
CodeString* prev = NULL ;
1154
1149
while (n != NULL ) {
1155
- *ps = new CodeString (n->string (),n->offset ());
1150
+ if (n->is_comment ()) {
1151
+ *ps = new CodeString (n->string (), n->offset ());
1152
+ } else {
1153
+ *ps = new CodeString (n->string ());
1154
+ }
1156
1155
(*ps)->_prev = prev;
1157
1156
prev = *ps;
1158
1157
ps = &((*ps)->_next );
@@ -1162,13 +1161,6 @@ void CodeStrings::copy(CodeStrings& other) {
1162
1161
1163
1162
const char * CodeStrings::_prefix = " ;; " ; // default: can be changed via set_prefix
1164
1163
1165
- // Check if any block comments are pending for the given offset.
1166
- bool CodeStrings::has_block_comment (intptr_t offset) const {
1167
- if (_strings == NULL ) return false ;
1168
- CodeString* c = find (offset);
1169
- return c != NULL ;
1170
- }
1171
-
1172
1164
void CodeStrings::print_block_comment (outputStream* stream, intptr_t offset) const {
1173
1165
check_valid ();
1174
1166
if (_strings != NULL ) {
@@ -1184,8 +1176,19 @@ void CodeStrings::print_block_comment(outputStream* stream, intptr_t offset) con
1184
1176
}
1185
1177
}
1186
1178
1187
- // Also sets isNull()
1179
+ int CodeStrings::count () const {
1180
+ int i = 0 ;
1181
+ CodeString* s = _strings;
1182
+ while (s != NULL ) {
1183
+ i++;
1184
+ s = s->_next ;
1185
+ }
1186
+ return i;
1187
+ }
1188
+
1189
+ // Also sets is_null()
1188
1190
void CodeStrings::free () {
1191
+ log_debug (codestrings)(" Freeing %d out of approx. %ld CodeString(s), " , count (), CodeString::allocated_code_strings);
1189
1192
CodeString* n = _strings;
1190
1193
while (n) {
1191
1194
// unlink the node from the list saving a pointer to the next
@@ -1215,7 +1218,7 @@ const char* CodeStrings::add_string(const char * string) {
1215
1218
1216
1219
void CodeBuffer::decode () {
1217
1220
ttyLocker ttyl;
1218
- Disassembler::decode (decode_begin (), insts_end (), tty);
1221
+ Disassembler::decode (decode_begin (), insts_end (), tty NOT_PRODUCT (COMMA & strings ()) );
1219
1222
_decode_begin = insts_end ();
1220
1223
}
1221
1224
@@ -1246,10 +1249,4 @@ void CodeBuffer::print() {
1246
1249
}
1247
1250
}
1248
1251
1249
- // Directly disassemble code buffer.
1250
- void CodeBuffer::decode (address start, address end) {
1251
- ttyLocker ttyl;
1252
- Disassembler::decode (this , start, end, tty);
1253
- }
1254
-
1255
1252
#endif // PRODUCT
0 commit comments