comparison src/share/vm/runtime/os.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 89152779163c 78bbf4d43a14
children 7848fc12602b
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
62 #ifdef TARGET_OS_FAMILY_bsd 62 #ifdef TARGET_OS_FAMILY_bsd
63 # include "os_bsd.inline.hpp" 63 # include "os_bsd.inline.hpp"
64 #endif 64 #endif
65 65
66 # include <signal.h> 66 # include <signal.h>
67
68 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
67 69
68 OSThread* os::_starting_thread = NULL; 70 OSThread* os::_starting_thread = NULL;
69 address os::_polling_page = NULL; 71 address os::_polling_page = NULL;
70 volatile int32_t* os::_mem_serialize_page = NULL; 72 volatile int32_t* os::_mem_serialize_page = NULL;
71 uintptr_t os::_serialize_page_mask = 0; 73 uintptr_t os::_serialize_page_mask = 0;
907 if (env_list) { 909 if (env_list) {
908 st->print_cr("Environment Variables:"); 910 st->print_cr("Environment Variables:");
909 911
910 for (int i = 0; env_list[i] != NULL; i++) { 912 for (int i = 0; env_list[i] != NULL; i++) {
911 if (getenv(env_list[i], buffer, len)) { 913 if (getenv(env_list[i], buffer, len)) {
912 st->print(env_list[i]); 914 st->print("%s", env_list[i]);
913 st->print("="); 915 st->print("=");
914 st->print_cr(buffer); 916 st->print_cr("%s", buffer);
915 } 917 }
916 } 918 }
917 } 919 }
918 } 920 }
919 921
927 st->cr(); 929 st->cr();
928 pd_print_cpu_info(st); 930 pd_print_cpu_info(st);
929 } 931 }
930 932
931 void os::print_date_and_time(outputStream *st) { 933 void os::print_date_and_time(outputStream *st) {
934 const int secs_per_day = 86400;
935 const int secs_per_hour = 3600;
936 const int secs_per_min = 60;
937
932 time_t tloc; 938 time_t tloc;
933 (void)time(&tloc); 939 (void)time(&tloc);
934 st->print("time: %s", ctime(&tloc)); // ctime adds newline. 940 st->print("time: %s", ctime(&tloc)); // ctime adds newline.
935 941
936 double t = os::elapsedTime(); 942 double t = os::elapsedTime();
937 // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in 943 // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
938 // Linux. Must be a bug in glibc ? Workaround is to round "t" to int 944 // Linux. Must be a bug in glibc ? Workaround is to round "t" to int
939 // before printf. We lost some precision, but who cares? 945 // before printf. We lost some precision, but who cares?
940 st->print_cr("elapsed time: %d seconds", (int)t); 946 int eltime = (int)t; // elapsed time in seconds
947
948 // print elapsed time in a human-readable format:
949 int eldays = eltime / secs_per_day;
950 int day_secs = eldays * secs_per_day;
951 int elhours = (eltime - day_secs) / secs_per_hour;
952 int hour_secs = elhours * secs_per_hour;
953 int elmins = (eltime - day_secs - hour_secs) / secs_per_min;
954 int minute_secs = elmins * secs_per_min;
955 int elsecs = (eltime - day_secs - hour_secs - minute_secs);
956 st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
941 } 957 }
942 958
943 // moved from debug.cpp (used to be find()) but still called from there 959 // moved from debug.cpp (used to be find()) but still called from there
944 // The verbose parameter is only set by the debug code in one case 960 // The verbose parameter is only set by the debug code in one case
945 void os::print_location(outputStream* st, intptr_t x, bool verbose) { 961 void os::print_location(outputStream* st, intptr_t x, bool verbose) {
1079 return; 1095 return;
1080 } 1096 }
1081 1097
1082 } 1098 }
1083 1099
1084 #ifndef PRODUCT 1100 // Check if in metaspace and print types that have vptrs (only method now)
1085 // Check if in metaspace. 1101 if (Metaspace::contains(addr)) {
1086 if (ClassLoaderDataGraph::contains((address)addr)) { 1102 if (Method::has_method_vptr((const void*)addr)) {
1087 // Use addr->print() from the debugger instead (not here) 1103 ((Method*)addr)->print_value_on(st);
1088 st->print_cr(INTPTR_FORMAT 1104 st->cr();
1089 " is pointing into metadata", addr); 1105 } else {
1106 // Use addr->print() from the debugger instead (not here)
1107 st->print_cr(INTPTR_FORMAT " is pointing into metadata", addr);
1108 }
1090 return; 1109 return;
1091 } 1110 }
1092 #endif
1093 1111
1094 // Try an OS specific find 1112 // Try an OS specific find
1095 if (os::find(addr, st)) { 1113 if (os::find(addr, st)) {
1096 return; 1114 return;
1097 } 1115 }
1101 1119
1102 // Looks like all platforms except IA64 can use the same function to check 1120 // Looks like all platforms except IA64 can use the same function to check
1103 // if C stack is walkable beyond current frame. The check for fp() is not 1121 // if C stack is walkable beyond current frame. The check for fp() is not
1104 // necessary on Sparc, but it's harmless. 1122 // necessary on Sparc, but it's harmless.
1105 bool os::is_first_C_frame(frame* fr) { 1123 bool os::is_first_C_frame(frame* fr) {
1106 #if defined(IA64) && !defined(_WIN32) 1124 #if (defined(IA64) && !defined(AIX)) && !defined(_WIN32)
1107 // On IA64 we have to check if the callers bsp is still valid 1125 // On IA64 we have to check if the callers bsp is still valid
1108 // (i.e. within the register stack bounds). 1126 // (i.e. within the register stack bounds).
1109 // Notice: this only works for threads created by the VM and only if 1127 // Notice: this only works for threads created by the VM and only if
1110 // we walk the current stack!!! If we want to be able to walk 1128 // we walk the current stack!!! If we want to be able to walk
1111 // arbitrary other threads, we'll have to somehow store the thread 1129 // arbitrary other threads, we'll have to somehow store the thread