hotspot/src/share/vm/asm/codeBuffer.cpp
changeset 13887 89b873bcc55b
parent 13728 882756847a04
child 14294 130e947dfbe6
equal deleted inserted replaced
13886:8d82c4dfa722 13887:89b873bcc55b
  1024     while (a != NULL && a->_offset != offset) {
  1024     while (a != NULL && a->_offset != offset) {
  1025       a = a->_next;
  1025       a = a->_next;
  1026     }
  1026     }
  1027     return a;
  1027     return a;
  1028   }
  1028   }
       
  1029 
       
  1030   // Convenience for add_comment.
       
  1031   CodeComment* find_last(intptr_t offset) {
       
  1032     CodeComment* a = find(offset);
       
  1033     if (a != NULL) {
       
  1034       while ((a->_next != NULL) && (a->_next->_offset == offset)) {
       
  1035         a = a->_next;
       
  1036       }
       
  1037     }
       
  1038     return a;
       
  1039   }
  1029 };
  1040 };
  1030 
  1041 
  1031 
  1042 
  1032 void CodeComments::add_comment(intptr_t offset, const char * comment) {
  1043 void CodeComments::add_comment(intptr_t offset, const char * comment) {
  1033   CodeComment* c = new CodeComment(offset, comment);
  1044   CodeComment* c      = new CodeComment(offset, comment);
  1034   CodeComment* insert = NULL;
  1045   CodeComment* inspos = (_comments == NULL) ? NULL : _comments->find_last(offset);
  1035   if (_comments != NULL) {
  1046 
  1036     CodeComment* c = _comments->find(offset);
  1047   if (inspos) {
  1037     insert = c;
  1048     // insert after already existing comments with same offset
  1038     while (c && c->offset() == offset) {
  1049     c->set_next(inspos->next());
  1039       insert = c;
  1050     inspos->set_next(c);
  1040       c = c->next();
       
  1041     }
       
  1042   }
       
  1043   if (insert) {
       
  1044     // insert after comments with same offset
       
  1045     c->set_next(insert->next());
       
  1046     insert->set_next(c);
       
  1047   } else {
  1051   } else {
       
  1052     // no comments with such offset, yet. Insert before anything else.
  1048     c->set_next(_comments);
  1053     c->set_next(_comments);
  1049     _comments = c;
  1054     _comments = c;
  1050   }
  1055   }
  1051 }
  1056 }
  1052 
  1057 
  1053 
  1058 
  1054 void CodeComments::assign(CodeComments& other) {
  1059 void CodeComments::assign(CodeComments& other) {
  1055   assert(_comments == NULL, "don't overwrite old value");
       
  1056   _comments = other._comments;
  1060   _comments = other._comments;
  1057 }
  1061 }
  1058 
  1062 
  1059 
  1063 
  1060 void CodeComments::print_block_comment(outputStream* stream, intptr_t offset) {
  1064 void CodeComments::print_block_comment(outputStream* stream, intptr_t offset) const {
  1061   if (_comments != NULL) {
  1065   if (_comments != NULL) {
  1062     CodeComment* c = _comments->find(offset);
  1066     CodeComment* c = _comments->find(offset);
  1063     while (c && c->offset() == offset) {
  1067     while (c && c->offset() == offset) {
  1064       stream->bol();
  1068       stream->bol();
  1065       stream->print("  ;; ");
  1069       stream->print("  ;; ");
  1083 }
  1087 }
  1084 
  1088 
  1085 
  1089 
  1086 
  1090 
  1087 void CodeBuffer::decode() {
  1091 void CodeBuffer::decode() {
       
  1092   ttyLocker ttyl;
  1088   Disassembler::decode(decode_begin(), insts_end());
  1093   Disassembler::decode(decode_begin(), insts_end());
  1089   _decode_begin = insts_end();
  1094   _decode_begin = insts_end();
  1090 }
  1095 }
  1091 
  1096 
  1092 
  1097 
  1094   _decode_begin = insts_end();
  1099   _decode_begin = insts_end();
  1095 }
  1100 }
  1096 
  1101 
  1097 
  1102 
  1098 void CodeBuffer::decode_all() {
  1103 void CodeBuffer::decode_all() {
       
  1104   ttyLocker ttyl;
  1099   for (int n = 0; n < (int)SECT_LIMIT; n++) {
  1105   for (int n = 0; n < (int)SECT_LIMIT; n++) {
  1100     // dump contents of each section
  1106     // dump contents of each section
  1101     CodeSection* cs = code_section(n);
  1107     CodeSection* cs = code_section(n);
  1102     tty->print_cr("! %s:", code_section_name(n));
  1108     tty->print_cr("! %s:", code_section_name(n));
  1103     if (cs != consts())
  1109     if (cs != consts())