Mercurial > hg > graal-jvmci-8
comparison src/share/vm/utilities/ostream.cpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | 3d91d5d7b166 d2a62e0f25eb |
children | c38f13903fdf |
comparison
equal
deleted
inserted
replaced
5891:fd8832ae511d | 6275:957c266d8bc5 |
---|---|
383 | 383 |
384 rotatingFileStream::~rotatingFileStream() { | 384 rotatingFileStream::~rotatingFileStream() { |
385 if (_file != NULL) { | 385 if (_file != NULL) { |
386 if (_need_close) fclose(_file); | 386 if (_need_close) fclose(_file); |
387 _file = NULL; | 387 _file = NULL; |
388 FREE_C_HEAP_ARRAY(char, _file_name); | 388 FREE_C_HEAP_ARRAY(char, _file_name, mtInternal); |
389 _file_name = NULL; | 389 _file_name = NULL; |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
393 rotatingFileStream::rotatingFileStream(const char* file_name) { | 393 rotatingFileStream::rotatingFileStream(const char* file_name) { |
394 _cur_file_num = 0; | 394 _cur_file_num = 0; |
395 _bytes_writen = 0L; | 395 _bytes_writen = 0L; |
396 _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10); | 396 _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal); |
397 jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); | 397 jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); |
398 _file = fopen(_file_name, "w"); | 398 _file = fopen(_file_name, "w"); |
399 _need_close = true; | 399 _need_close = true; |
400 } | 400 } |
401 | 401 |
402 rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) { | 402 rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) { |
403 _cur_file_num = 0; | 403 _cur_file_num = 0; |
404 _bytes_writen = 0L; | 404 _bytes_writen = 0L; |
405 _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10); | 405 _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal); |
406 jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); | 406 jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); |
407 _file = fopen(_file_name, opentype); | 407 _file = fopen(_file_name, opentype); |
408 _need_close = true; | 408 _need_close = true; |
409 } | 409 } |
410 | 410 |
523 jio_snprintf(pid, sizeof(pid), "%u", os::current_process_id()); | 523 jio_snprintf(pid, sizeof(pid), "%u", os::current_process_id()); |
524 buffer_length += strlen(pid); | 524 buffer_length += strlen(pid); |
525 } | 525 } |
526 | 526 |
527 // Create big enough buffer. | 527 // Create big enough buffer. |
528 char *buf = NEW_C_HEAP_ARRAY(char, buffer_length); | 528 char *buf = NEW_C_HEAP_ARRAY(char, buffer_length, mtInternal); |
529 | 529 |
530 strcpy(buf, ""); | 530 strcpy(buf, ""); |
531 if (force_directory != NULL) { | 531 if (force_directory != NULL) { |
532 strcat(buf, force_directory); | 532 strcat(buf, force_directory); |
533 strcat(buf, os::file_separator()); | 533 strcat(buf, os::file_separator()); |
548 | 548 |
549 void defaultStream::init_log() { | 549 void defaultStream::init_log() { |
550 // %%% Need a MutexLocker? | 550 // %%% Need a MutexLocker? |
551 const char* log_name = LogFile != NULL ? LogFile : "hotspot.log"; | 551 const char* log_name = LogFile != NULL ? LogFile : "hotspot.log"; |
552 const char* try_name = make_log_name(log_name, NULL); | 552 const char* try_name = make_log_name(log_name, NULL); |
553 fileStream* file = new(ResourceObj::C_HEAP) fileStream(try_name); | 553 fileStream* file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name); |
554 if (!file->is_open()) { | 554 if (!file->is_open()) { |
555 // Try again to open the file. | 555 // Try again to open the file. |
556 char warnbuf[O_BUFLEN*2]; | 556 char warnbuf[O_BUFLEN*2]; |
557 jio_snprintf(warnbuf, sizeof(warnbuf), | 557 jio_snprintf(warnbuf, sizeof(warnbuf), |
558 "Warning: Cannot open log file: %s\n", try_name); | 558 "Warning: Cannot open log file: %s\n", try_name); |
559 // Note: This feature is for maintainer use only. No need for L10N. | 559 // Note: This feature is for maintainer use only. No need for L10N. |
560 jio_print(warnbuf); | 560 jio_print(warnbuf); |
561 FREE_C_HEAP_ARRAY(char, try_name); | 561 FREE_C_HEAP_ARRAY(char, try_name, mtInternal); |
562 try_name = make_log_name("hs_pid%p.log", os::get_temp_directory()); | 562 try_name = make_log_name("hs_pid%p.log", os::get_temp_directory()); |
563 jio_snprintf(warnbuf, sizeof(warnbuf), | 563 jio_snprintf(warnbuf, sizeof(warnbuf), |
564 "Warning: Forcing option -XX:LogFile=%s\n", try_name); | 564 "Warning: Forcing option -XX:LogFile=%s\n", try_name); |
565 jio_print(warnbuf); | 565 jio_print(warnbuf); |
566 delete file; | 566 delete file; |
567 file = new(ResourceObj::C_HEAP) fileStream(try_name); | 567 file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name); |
568 FREE_C_HEAP_ARRAY(char, try_name); | 568 FREE_C_HEAP_ARRAY(char, try_name, mtInternal); |
569 } | 569 } |
570 if (file->is_open()) { | 570 if (file->is_open()) { |
571 _log_file = file; | 571 _log_file = file; |
572 xmlStream* xs = new(ResourceObj::C_HEAP) xmlStream(file); | 572 xmlStream* xs = new(ResourceObj::C_HEAP, mtInternal) xmlStream(file); |
573 _outer_xmlStream = xs; | 573 _outer_xmlStream = xs; |
574 if (this == tty) xtty = xs; | 574 if (this == tty) xtty = xs; |
575 // Write XML header. | 575 // Write XML header. |
576 xs->print_cr("<?xml version='1.0' encoding='UTF-8'?>"); | 576 xs->print_cr("<?xml version='1.0' encoding='UTF-8'?>"); |
577 // (For now, don't bother to issue a DTD for this private format.) | 577 // (For now, don't bother to issue a DTD for this private format.) |
816 // (else there was no lock to break) | 816 // (else there was no lock to break) |
817 } | 817 } |
818 | 818 |
819 void ostream_init() { | 819 void ostream_init() { |
820 if (defaultStream::instance == NULL) { | 820 if (defaultStream::instance == NULL) { |
821 defaultStream::instance = new(ResourceObj::C_HEAP) defaultStream(); | 821 defaultStream::instance = new(ResourceObj::C_HEAP, mtInternal) defaultStream(); |
822 tty = defaultStream::instance; | 822 tty = defaultStream::instance; |
823 | 823 |
824 // We want to ensure that time stamps in GC logs consider time 0 | 824 // We want to ensure that time stamps in GC logs consider time 0 |
825 // the time when the JVM is initialized, not the first time we ask | 825 // the time when the JVM is initialized, not the first time we ask |
826 // for a time stamp. So, here, we explicitly update the time stamp | 826 // for a time stamp. So, here, we explicitly update the time stamp |
834 // Note : this must be called AFTER ostream_init() | 834 // Note : this must be called AFTER ostream_init() |
835 | 835 |
836 gclog_or_tty = tty; // default to tty | 836 gclog_or_tty = tty; // default to tty |
837 if (Arguments::gc_log_filename() != NULL) { | 837 if (Arguments::gc_log_filename() != NULL) { |
838 fileStream * gclog = UseGCLogFileRotation ? | 838 fileStream * gclog = UseGCLogFileRotation ? |
839 new(ResourceObj::C_HEAP) | 839 new(ResourceObj::C_HEAP, mtInternal) |
840 rotatingFileStream(Arguments::gc_log_filename()) : | 840 rotatingFileStream(Arguments::gc_log_filename()) : |
841 new(ResourceObj::C_HEAP) | 841 new(ResourceObj::C_HEAP, mtInternal) |
842 fileStream(Arguments::gc_log_filename()); | 842 fileStream(Arguments::gc_log_filename()); |
843 if (gclog->is_open()) { | 843 if (gclog->is_open()) { |
844 // now we update the time stamp of the GC log to be synced up | 844 // now we update the time stamp of the GC log to be synced up |
845 // with tty. | 845 // with tty. |
846 gclog->time_stamp().update_to(tty->time_stamp().ticks()); | 846 gclog->time_stamp().update_to(tty->time_stamp().ticks()); |
941 write(str, len); | 941 write(str, len); |
942 } | 942 } |
943 | 943 |
944 bufferedStream::bufferedStream(size_t initial_size, size_t bufmax) : outputStream() { | 944 bufferedStream::bufferedStream(size_t initial_size, size_t bufmax) : outputStream() { |
945 buffer_length = initial_size; | 945 buffer_length = initial_size; |
946 buffer = NEW_C_HEAP_ARRAY(char, buffer_length); | 946 buffer = NEW_C_HEAP_ARRAY(char, buffer_length, mtInternal); |
947 buffer_pos = 0; | 947 buffer_pos = 0; |
948 buffer_fixed = false; | 948 buffer_fixed = false; |
949 buffer_max = bufmax; | 949 buffer_max = bufmax; |
950 } | 950 } |
951 | 951 |
972 // For small overruns, double the buffer. For larger ones, | 972 // For small overruns, double the buffer. For larger ones, |
973 // increase to the requested size. | 973 // increase to the requested size. |
974 if (end < buffer_length * 2) { | 974 if (end < buffer_length * 2) { |
975 end = buffer_length * 2; | 975 end = buffer_length * 2; |
976 } | 976 } |
977 buffer = REALLOC_C_HEAP_ARRAY(char, buffer, end); | 977 buffer = REALLOC_C_HEAP_ARRAY(char, buffer, end, mtInternal); |
978 buffer_length = end; | 978 buffer_length = end; |
979 } | 979 } |
980 } | 980 } |
981 memcpy(buffer + buffer_pos, s, len); | 981 memcpy(buffer + buffer_pos, s, len); |
982 buffer_pos += len; | 982 buffer_pos += len; |
990 return copy; | 990 return copy; |
991 } | 991 } |
992 | 992 |
993 bufferedStream::~bufferedStream() { | 993 bufferedStream::~bufferedStream() { |
994 if (!buffer_fixed) { | 994 if (!buffer_fixed) { |
995 FREE_C_HEAP_ARRAY(char, buffer); | 995 FREE_C_HEAP_ARRAY(char, buffer, mtInternal); |
996 } | 996 } |
997 } | 997 } |
998 | 998 |
999 #ifndef PRODUCT | 999 #ifndef PRODUCT |
1000 | 1000 |