This commit is contained in:
Keith McGuigan 2008-03-20 09:17:30 -05:00
commit c2c3f0fe72
21 changed files with 106 additions and 210 deletions

View file

@ -1261,19 +1261,13 @@ jlong os::elapsed_frequency() {
return (1000 * 1000);
}
jlong os::timeofday() {
jlong os::javaTimeMillis() {
timeval time;
int status = gettimeofday(&time, NULL);
assert(status != -1, "linux error");
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
}
// Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
// _use_global_time is only set if CacheTimeMillis is true
jlong os::javaTimeMillis() {
return (_use_global_time ? read_global_time() : timeofday());
}
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC (1)
#endif

View file

@ -1691,19 +1691,14 @@ jlong getTimeMillis() {
return (jlong)(nanotime / NANOSECS_PER_MILLISECS);
}
jlong os::timeofday() {
// Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
jlong os::javaTimeMillis() {
timeval t;
if (gettimeofday( &t, NULL) == -1)
fatal1("timeofday: gettimeofday (%s)", strerror(errno));
fatal1("os::javaTimeMillis: gettimeofday (%s)", strerror(errno));
return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
}
// Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
// _use_global_time is only set if CacheTimeMillis is true
jlong os::javaTimeMillis() {
return (_use_global_time ? read_global_time() : timeofday());
}
jlong os::javaTimeNanos() {
return (jlong)getTimeNanos();
}
@ -2785,16 +2780,15 @@ char* os::Solaris::mmap_chunk(char *addr, size_t size, int flags, int prot) {
return b;
}
char*
os::reserve_memory(size_t bytes, char* requested_addr, size_t alignment_hint) {
char* addr = NULL;
int flags;
char* os::Solaris::anon_mmap(char* requested_addr, size_t bytes, size_t alignment_hint, bool fixed) {
char* addr = requested_addr;
int flags = MAP_PRIVATE | MAP_NORESERVE;
flags = MAP_PRIVATE | MAP_NORESERVE;
if (requested_addr != NULL) {
flags |= MAP_FIXED;
addr = requested_addr;
} else if (has_map_align && alignment_hint > (size_t) vm_page_size()) {
assert(!(fixed && (alignment_hint > 0)), "alignment hint meaningless with fixed mmap");
if (fixed) {
flags |= MAP_FIXED;
} else if (has_map_align && (alignment_hint > (size_t) vm_page_size())) {
flags |= MAP_ALIGN;
addr = (char*) alignment_hint;
}
@ -2802,11 +2796,14 @@ os::reserve_memory(size_t bytes, char* requested_addr, size_t alignment_hint) {
// Map uncommitted pages PROT_NONE so we fail early if we touch an
// uncommitted page. Otherwise, the read/write might succeed if we
// have enough swap space to back the physical page.
addr = Solaris::mmap_chunk(addr, bytes, flags, PROT_NONE);
return mmap_chunk(addr, bytes, flags, PROT_NONE);
}
char* os::reserve_memory(size_t bytes, char* requested_addr, size_t alignment_hint) {
char* addr = Solaris::anon_mmap(requested_addr, bytes, alignment_hint, (requested_addr != NULL));
guarantee(requested_addr == NULL || requested_addr == addr,
"OS failed to return requested mmap address.");
return addr;
}
@ -2832,6 +2829,31 @@ char* os::attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
// in one of the methods further up the call chain. See bug 5044738.
assert(bytes % os::vm_page_size() == 0, "reserving unexpected size block");
// Since snv_84, Solaris attempts to honor the address hint - see 5003415.
// Give it a try, if the kernel honors the hint we can return immediately.
char* addr = Solaris::anon_mmap(requested_addr, bytes, 0, false);
volatile int err = errno;
if (addr == requested_addr) {
return addr;
} else if (addr != NULL) {
unmap_memory(addr, bytes);
}
if (PrintMiscellaneous && Verbose) {
char buf[256];
buf[0] = '\0';
if (addr == NULL) {
jio_snprintf(buf, sizeof(buf), ": %s", strerror(err));
}
warning("attempt_reserve_memory_at: couldn't reserve %d bytes at "
PTR_FORMAT ": reserve_memory_helper returned " PTR_FORMAT
"%s", bytes, requested_addr, addr, buf);
}
// Address hint method didn't work. Fall back to the old method.
// In theory, once SNV becomes our oldest supported platform, this
// code will no longer be needed.
//
// Repeatedly allocate blocks until the block is allocated at the
// right spot. Give up after max_tries.
int i;

View file

@ -156,6 +156,7 @@ class Solaris {
static int get_dev_zero_fd() { return _dev_zero_fd; }
static void set_dev_zero_fd(int fd) { _dev_zero_fd = fd; }
static char* mmap_chunk(char *addr, size_t size, int flags, int prot);
static char* anon_mmap(char* requested_addr, size_t bytes, size_t alignment_hint, bool fixed);
static bool mpss_sanity_check(bool warn, size_t * page_size);
static bool ism_sanity_check (bool warn, size_t * page_size);

View file

@ -737,20 +737,13 @@ FILETIME java_to_windows_time(jlong l) {
return result;
}
jlong os::timeofday() {
FILETIME wt;
GetSystemTimeAsFileTime(&wt);
return windows_to_java_time(wt);
}
// Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
// _use_global_time is only set if CacheTimeMillis is true
jlong os::javaTimeMillis() {
if (UseFakeTimers) {
return fake_time++;
} else {
return (_use_global_time ? read_global_time() : timeofday());
FILETIME wt;
GetSystemTimeAsFileTime(&wt);
return windows_to_java_time(wt);
}
}