< prev index next >

src/hotspot/share/asm/codeBuffer.cpp

Print this page
rev 51079 : 8205118: CodeStrings::copy() assertion caused by -XX:+VerifyOops -XX:+PrintStubCode
Reviewed-by: shade


1058  private:
1059   friend class CodeStrings;
1060   const char * _string;
1061   CodeString*  _next;
1062   intptr_t     _offset;
1063 
1064   ~CodeString() {
1065     assert(_next == NULL, "wrong interface for freeing list");
1066     os::free((void*)_string);
1067   }
1068 
1069   bool is_comment() const { return _offset >= 0; }
1070 
1071  public:
1072   CodeString(const char * string, intptr_t offset = -1)
1073     : _next(NULL), _offset(offset) {
1074     _string = os::strdup(string, mtCode);
1075   }
1076 
1077   const char * string() const { return _string; }
1078   intptr_t     offset() const { assert(_offset >= 0, "offset for non comment?"); return _offset;  }




1079   CodeString* next()    const { return _next; }
1080 
1081   void set_next(CodeString* next) { _next = next; }
1082 
1083   CodeString* first_comment() {
1084     if (is_comment()) {
1085       return this;
1086     } else {
1087       return next_comment();
1088     }
1089   }
1090   CodeString* next_comment() const {
1091     CodeString* s = _next;
1092     while (s != NULL && !s->is_comment()) {
1093       s = s->_next;
1094     }
1095     return s;
1096   }
1097 };
1098 


1135 void CodeStrings::assign(CodeStrings& other) {
1136   other.check_valid();
1137   assert(is_null(), "Cannot assign onto non-empty CodeStrings");
1138   _strings = other._strings;
1139 #ifdef ASSERT
1140   _defunct = false;
1141 #endif
1142   other.set_null_and_invalidate();
1143 }
1144 
1145 // Deep copy of CodeStrings for consistent memory management.
1146 // Only used for actual disassembly so this is cheaper than reference counting
1147 // for the "normal" fastdebug case.
1148 void CodeStrings::copy(CodeStrings& other) {
1149   other.check_valid();
1150   check_valid();
1151   assert(is_null(), "Cannot copy onto non-empty CodeStrings");
1152   CodeString* n = other._strings;
1153   CodeString** ps = &_strings;
1154   while (n != NULL) {
1155     *ps = new CodeString(n->string(),n->offset());
1156     ps = &((*ps)->_next);
1157     n = n->next();
1158   }
1159 }
1160 
1161 const char* CodeStrings::_prefix = " ;; ";  // default: can be changed via set_prefix
1162 
1163 void CodeStrings::print_block_comment(outputStream* stream, intptr_t offset) const {
1164     check_valid();
1165     if (_strings != NULL) {
1166     CodeString* c = find(offset);
1167     while (c && c->offset() == offset) {
1168       stream->bol();
1169       stream->print("%s", _prefix);
1170       // Don't interpret as format strings since it could contain %
1171       stream->print_raw_cr(c->string());
1172       c = c->next_comment();
1173     }
1174   }
1175 }




1058  private:
1059   friend class CodeStrings;
1060   const char * _string;
1061   CodeString*  _next;
1062   intptr_t     _offset;
1063 
1064   ~CodeString() {
1065     assert(_next == NULL, "wrong interface for freeing list");
1066     os::free((void*)_string);
1067   }
1068 
1069   bool is_comment() const { return _offset >= 0; }
1070 
1071  public:
1072   CodeString(const char * string, intptr_t offset = -1)
1073     : _next(NULL), _offset(offset) {
1074     _string = os::strdup(string, mtCode);
1075   }
1076 
1077   const char * string() const { return _string; }
1078   intptr_t     offset() const {
1079     assert(_offset >= 0, "offset for non comment?");
1080     return offset_raw();
1081   }
1082   intptr_t offset_raw() const { return _offset; }
1083   CodeString* next()    const { return _next; }
1084 
1085   void set_next(CodeString* next) { _next = next; }
1086 
1087   CodeString* first_comment() {
1088     if (is_comment()) {
1089       return this;
1090     } else {
1091       return next_comment();
1092     }
1093   }
1094   CodeString* next_comment() const {
1095     CodeString* s = _next;
1096     while (s != NULL && !s->is_comment()) {
1097       s = s->_next;
1098     }
1099     return s;
1100   }
1101 };
1102 


1139 void CodeStrings::assign(CodeStrings& other) {
1140   other.check_valid();
1141   assert(is_null(), "Cannot assign onto non-empty CodeStrings");
1142   _strings = other._strings;
1143 #ifdef ASSERT
1144   _defunct = false;
1145 #endif
1146   other.set_null_and_invalidate();
1147 }
1148 
1149 // Deep copy of CodeStrings for consistent memory management.
1150 // Only used for actual disassembly so this is cheaper than reference counting
1151 // for the "normal" fastdebug case.
1152 void CodeStrings::copy(CodeStrings& other) {
1153   other.check_valid();
1154   check_valid();
1155   assert(is_null(), "Cannot copy onto non-empty CodeStrings");
1156   CodeString* n = other._strings;
1157   CodeString** ps = &_strings;
1158   while (n != NULL) {
1159     *ps = new CodeString(n->string(), n->offset_raw());
1160     ps = &((*ps)->_next);
1161     n = n->next();
1162   }
1163 }
1164 
1165 const char* CodeStrings::_prefix = " ;; ";  // default: can be changed via set_prefix
1166 
1167 void CodeStrings::print_block_comment(outputStream* stream, intptr_t offset) const {
1168     check_valid();
1169     if (_strings != NULL) {
1170     CodeString* c = find(offset);
1171     while (c && c->offset() == offset) {
1172       stream->bol();
1173       stream->print("%s", _prefix);
1174       // Don't interpret as format strings since it could contain %
1175       stream->print_raw_cr(c->string());
1176       c = c->next_comment();
1177     }
1178   }
1179 }


< prev index next >