comparison src/share/vm/utilities/ostream.cpp @ 20375:6e0cb14ce59b

8046070: Class Data Sharing clean up and refactoring Summary: Cleaned up CDS to be more configurable, maintainable and extensible Reviewed-by: dholmes, coleenp, acorn, mchung
author iklam
date Thu, 21 Aug 2014 13:57:51 -0700
parents 0982ec23da03
children c2844108a708
comparison
equal deleted inserted replaced
20374:999824269b71 20375:6e0cb14ce59b
363 stringStream::~stringStream() {} 363 stringStream::~stringStream() {}
364 364
365 xmlStream* xtty; 365 xmlStream* xtty;
366 outputStream* tty; 366 outputStream* tty;
367 outputStream* gclog_or_tty; 367 outputStream* gclog_or_tty;
368 CDS_ONLY(fileStream* classlist_file;) // Only dump the classes that can be stored into the CDS archive
368 extern Mutex* tty_lock; 369 extern Mutex* tty_lock;
369 370
370 #define EXTRACHARLEN 32 371 #define EXTRACHARLEN 32
371 #define CURRENTAPPX ".current" 372 #define CURRENTAPPX ".current"
372 #define FILENAMEBUFLEN 1024 373 #define FILENAMEBUFLEN 1024
474 } 475 }
475 strcat(buf, tail); // append rest of name, or all of name 476 strcat(buf, tail); // append rest of name, or all of name
476 return buf; 477 return buf;
477 } 478 }
478 479
479 // log_name comes from -XX:LogFile=log_name or -Xloggc:log_name 480 // log_name comes from -XX:LogFile=log_name, -Xloggc:log_name or
481 // -XX:DumpLoadedClassList=<file_name>
480 // in log_name, %p => pid1234 and 482 // in log_name, %p => pid1234 and
481 // %t => YYYY-MM-DD_HH-MM-SS 483 // %t => YYYY-MM-DD_HH-MM-SS
482 static const char* make_log_name(const char* log_name, const char* force_directory) { 484 static const char* make_log_name(const char* log_name, const char* force_directory) {
483 char timestr[32]; 485 char timestr[32];
484 get_datetime_string(timestr, sizeof(timestr)); 486 get_datetime_string(timestr, sizeof(timestr));
1114 gclog->time_stamp().update_to(tty->time_stamp().ticks()); 1116 gclog->time_stamp().update_to(tty->time_stamp().ticks());
1115 } 1117 }
1116 gclog_or_tty = gclog; 1118 gclog_or_tty = gclog;
1117 } 1119 }
1118 1120
1121 #if INCLUDE_CDS
1122 // For -XX:DumpLoadedClassList=<file> option
1123 if (DumpLoadedClassList != NULL) {
1124 const char* list_name = make_log_name(DumpLoadedClassList, NULL);
1125 classlist_file = new(ResourceObj::C_HEAP, mtInternal)
1126 fileStream(list_name);
1127 FREE_C_HEAP_ARRAY(char, list_name, mtInternal);
1128 }
1129 #endif
1130
1119 // If we haven't lazily initialized the logfile yet, do it now, 1131 // If we haven't lazily initialized the logfile yet, do it now,
1120 // to avoid the possibility of lazy initialization during a VM 1132 // to avoid the possibility of lazy initialization during a VM
1121 // crash, which can affect the stability of the fatal error handler. 1133 // crash, which can affect the stability of the fatal error handler.
1122 defaultStream::instance->has_log_file(); 1134 defaultStream::instance->has_log_file();
1123 } 1135 }
1126 // output and free resource. 1138 // output and free resource.
1127 void ostream_exit() { 1139 void ostream_exit() {
1128 static bool ostream_exit_called = false; 1140 static bool ostream_exit_called = false;
1129 if (ostream_exit_called) return; 1141 if (ostream_exit_called) return;
1130 ostream_exit_called = true; 1142 ostream_exit_called = true;
1143 #if INCLUDE_CDS
1144 if (classlist_file != NULL) {
1145 delete classlist_file;
1146 }
1147 #endif
1131 if (gclog_or_tty != tty) { 1148 if (gclog_or_tty != tty) {
1132 delete gclog_or_tty; 1149 delete gclog_or_tty;
1133 } 1150 }
1134 { 1151 {
1135 // we temporaly disable PrintMallocFree here 1152 // we temporaly disable PrintMallocFree here