src/hotspot/share/asm/codeBuffer.cpp
changeset 54960 e46fe26d7f77
parent 54783 3331dad9cb30
child 57834 e686b661fa05
child 58678 9cf78a70fa4f
equal deleted inserted replaced
54959:00425a850a2f 54960:e46fe26d7f77
    84 typedef CodeBuffer::csize_t csize_t;  // file-local definition
    84 typedef CodeBuffer::csize_t csize_t;  // file-local definition
    85 
    85 
    86 // External buffer, in a predefined CodeBlob.
    86 // External buffer, in a predefined CodeBlob.
    87 // Important: The code_start must be taken exactly, and not realigned.
    87 // Important: The code_start must be taken exactly, and not realigned.
    88 CodeBuffer::CodeBuffer(CodeBlob* blob) {
    88 CodeBuffer::CodeBuffer(CodeBlob* blob) {
    89   initialize_misc("static buffer");
    89   // Provide code buffer with meaningful name
       
    90   initialize_misc(blob->name());
    90   initialize(blob->content_begin(), blob->content_size());
    91   initialize(blob->content_begin(), blob->content_size());
    91   verify_section_allocation();
    92   verify_section_allocation();
    92 }
    93 }
    93 
    94 
    94 void CodeBuffer::initialize(csize_t code_size, csize_t locs_size) {
    95 void CodeBuffer::initialize(csize_t code_size, csize_t locs_size) {
  1033 void CodeSection::decode() {
  1034 void CodeSection::decode() {
  1034   Disassembler::decode(start(), end());
  1035   Disassembler::decode(start(), end());
  1035 }
  1036 }
  1036 
  1037 
  1037 void CodeBuffer::block_comment(intptr_t offset, const char * comment) {
  1038 void CodeBuffer::block_comment(intptr_t offset, const char * comment) {
  1038   _code_strings.add_comment(offset, comment);
  1039   if (_collect_comments) {
       
  1040     _code_strings.add_comment(offset, comment);
       
  1041   }
  1039 }
  1042 }
  1040 
  1043 
  1041 const char* CodeBuffer::code_string(const char* str) {
  1044 const char* CodeBuffer::code_string(const char* str) {
  1042   return _code_strings.add_string(str);
  1045   return _code_strings.add_string(str);
  1043 }
  1046 }
  1146   }
  1149   }
  1147 }
  1150 }
  1148 
  1151 
  1149 const char* CodeStrings::_prefix = " ;; ";  // default: can be changed via set_prefix
  1152 const char* CodeStrings::_prefix = " ;; ";  // default: can be changed via set_prefix
  1150 
  1153 
       
  1154 // Check if any block comments are pending for the given offset.
       
  1155 bool CodeStrings::has_block_comment(intptr_t offset) const {
       
  1156   if (_strings == NULL) return false;
       
  1157   CodeString* c = find(offset);
       
  1158   return c != NULL;
       
  1159 }
       
  1160 
  1151 void CodeStrings::print_block_comment(outputStream* stream, intptr_t offset) const {
  1161 void CodeStrings::print_block_comment(outputStream* stream, intptr_t offset) const {
  1152     check_valid();
  1162   check_valid();
  1153     if (_strings != NULL) {
  1163   if (_strings != NULL) {
  1154     CodeString* c = find(offset);
  1164     CodeString* c = find(offset);
  1155     while (c && c->offset() == offset) {
  1165     while (c && c->offset() == offset) {
  1156       stream->bol();
  1166       stream->bol();
  1157       stream->print("%s", _prefix);
  1167       stream->print("%s", _prefix);
  1158       // Don't interpret as format strings since it could contain %
  1168       // Don't interpret as format strings since it could contain %
  1159       stream->print_raw_cr(c->string());
  1169       stream->print_raw(c->string());
       
  1170       stream->bol(); // advance to next line only if string didn't contain a cr() at the end.
  1160       c = c->next_comment();
  1171       c = c->next_comment();
  1161     }
  1172     }
  1162   }
  1173   }
  1163 }
  1174 }
  1164 
  1175 
  1184   return s->string();
  1195   return s->string();
  1185 }
  1196 }
  1186 
  1197 
  1187 void CodeBuffer::decode() {
  1198 void CodeBuffer::decode() {
  1188   ttyLocker ttyl;
  1199   ttyLocker ttyl;
  1189   Disassembler::decode(decode_begin(), insts_end());
  1200   Disassembler::decode(decode_begin(), insts_end(), tty);
  1190   _decode_begin = insts_end();
  1201   _decode_begin = insts_end();
  1191 }
  1202 }
  1192 
  1203 
  1193 void CodeSection::print(const char* name) {
  1204 void CodeSection::print(const char* name) {
  1194   csize_t locs_size = locs_end() - locs_start();
  1205   csize_t locs_size = locs_end() - locs_start();
  1215     CodeSection* cs = code_section(n);
  1226     CodeSection* cs = code_section(n);
  1216     cs->print(code_section_name(n));
  1227     cs->print(code_section_name(n));
  1217   }
  1228   }
  1218 }
  1229 }
  1219 
  1230 
       
  1231 // Directly disassemble code buffer.
       
  1232 void CodeBuffer::decode(address start, address end) {
       
  1233   ttyLocker ttyl;
       
  1234   Disassembler::decode(this, start, end, tty);
       
  1235 }
       
  1236 
  1220 #endif // PRODUCT
  1237 #endif // PRODUCT