6667833: Remove CacheTimeMillis
Summary: Remove -XX:+CacheTimeMillis option and associated functionality
Reviewed-by: acorn, never
--- a/hotspot/src/os/linux/vm/os_linux.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -1247,19 +1247,13 @@
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
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -1691,19 +1691,14 @@
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();
}
--- a/hotspot/src/os/windows/vm/os_windows.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -732,20 +732,13 @@
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);
}
}
--- a/hotspot/src/share/vm/runtime/arguments.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -1255,12 +1255,10 @@
// Aggressive optimization flags -XX:+AggressiveOpts
void Arguments::set_aggressive_opts_flags() {
if (AggressiveOpts) {
-NOT_WINDOWS(
- // No measured benefit on Windows
- if (FLAG_IS_DEFAULT(CacheTimeMillis)) {
- FLAG_SET_DEFAULT(CacheTimeMillis, true);
- }
-)
+// Sample flag setting code
+// if (FLAG_IS_DEFAULT(EliminateZeroing)) {
+// FLAG_SET_DEFAULT(EliminateZeroing, true);
+// }
}
}
--- a/hotspot/src/share/vm/runtime/globals.hpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/globals.hpp Wed Mar 19 09:58:01 2008 -0400
@@ -344,12 +344,6 @@
product(bool, ForceTimeHighResolution, false, \
"Using high time resolution(For Win32 only)") \
\
- product(bool, CacheTimeMillis, false, \
- "Cache os::javaTimeMillis with CacheTimeMillisGranularity") \
- \
- diagnostic(uintx, CacheTimeMillisGranularity, 50, \
- "Granularity for CacheTimeMillis") \
- \
develop(bool, TraceItables, false, \
"Trace initialization and use of itables") \
\
--- a/hotspot/src/share/vm/runtime/java.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/java.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -390,11 +390,6 @@
StatSampler::disengage();
StatSampler::destroy();
- // shut down the TimeMillisUpdateTask
- if (CacheTimeMillis) {
- TimeMillisUpdateTask::disengage();
- }
-
#ifndef SERIALGC
// stop CMS threads
if (UseConcMarkSweepGC) {
--- a/hotspot/src/share/vm/runtime/os.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/os.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -33,9 +33,6 @@
uintptr_t os::_serialize_page_mask = 0;
long os::_rand_seed = 1;
int os::_processor_count = 0;
-volatile jlong os::_global_time = 0;
-volatile int os::_global_time_lock = 0;
-bool os::_use_global_time = false;
size_t os::_page_sizes[os::page_sizes_max];
#ifndef PRODUCT
@@ -44,74 +41,6 @@
int os::num_frees = 0; // # of calls to free
#endif
-// Atomic read of a jlong is assured by a seqlock; see update_global_time()
-jlong os::read_global_time() {
-#ifdef _LP64
- return _global_time;
-#else
- volatile int lock;
- volatile jlong current_time;
- int ctr = 0;
-
- for (;;) {
- lock = _global_time_lock;
-
- // spin while locked
- while ((lock & 0x1) != 0) {
- ++ctr;
- if ((ctr & 0xFFF) == 0) {
- // Guarantee writer progress. Can't use yield; yield is advisory
- // and has almost no effect on some platforms. Don't need a state
- // transition - the park call will return promptly.
- assert(Thread::current() != NULL, "TLS not initialized");
- assert(Thread::current()->_ParkEvent != NULL, "sync not initialized");
- Thread::current()->_ParkEvent->park(1);
- }
- lock = _global_time_lock;
- }
-
- OrderAccess::loadload();
- current_time = _global_time;
- OrderAccess::loadload();
-
- // ratify seqlock value
- if (lock == _global_time_lock) {
- return current_time;
- }
- }
-#endif
-}
-
-//
-// NOTE - Assumes only one writer thread!
-//
-// We use a seqlock to guarantee that jlong _global_time is updated
-// atomically on 32-bit platforms. A locked value is indicated by
-// the lock variable LSB == 1. Readers will initially read the lock
-// value, spinning until the LSB == 0. They then speculatively read
-// the global time value, then re-read the lock value to ensure that
-// it hasn't changed. If the lock value has changed, the entire read
-// sequence is retried.
-//
-// Writers simply set the LSB = 1 (i.e. increment the variable),
-// update the global time, then release the lock and bump the version
-// number (i.e. increment the variable again.) In this case we don't
-// even need a CAS since we ensure there's only one writer.
-//
-void os::update_global_time() {
-#ifdef _LP64
- _global_time = timeofday();
-#else
- assert((_global_time_lock & 0x1) == 0, "multiple writers?");
- jlong current_time = timeofday();
- _global_time_lock++; // lock
- OrderAccess::storestore();
- _global_time = current_time;
- OrderAccess::storestore();
- _global_time_lock++; // unlock
-#endif
-}
-
// Fill in buffer with current local time as an ISO-8601 string.
// E.g., yyyy-mm-ddThh:mm:ss-zzzz.
// Returns buffer, or NULL if it failed.
@@ -138,7 +67,7 @@
return NULL;
}
// Get the current time
- jlong milliseconds_since_19700101 = timeofday();
+ jlong milliseconds_since_19700101 = javaTimeMillis();
const int milliseconds_per_microsecond = 1000;
const time_t seconds_since_19700101 =
milliseconds_since_19700101 / milliseconds_per_microsecond;
--- a/hotspot/src/share/vm/runtime/os.hpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/os.hpp Wed Mar 19 09:58:01 2008 -0400
@@ -66,9 +66,6 @@
static address _polling_page;
static volatile int32_t * _mem_serialize_page;
static uintptr_t _serialize_page_mask;
- static volatile jlong _global_time;
- static volatile int _global_time_lock;
- static bool _use_global_time;
static size_t _page_sizes[page_sizes_max];
static void init_page_sizes(size_t default_page_size) {
@@ -88,11 +85,6 @@
static bool getenv(const char* name, char* buffer, int len);
static bool have_special_privileges();
- static jlong timeofday();
- static void enable_global_time() { _use_global_time = true; }
- static void disable_global_time() { _use_global_time = false; }
- static jlong read_global_time();
- static void update_global_time();
static jlong javaTimeMillis();
static jlong javaTimeNanos();
static void javaTimeNanos_info(jvmtiTimerInfo *info_ptr);
--- a/hotspot/src/share/vm/runtime/task.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/task.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -107,25 +107,3 @@
_tasks[index] = _tasks[index+1];
}
}
-
-TimeMillisUpdateTask* TimeMillisUpdateTask::_task = NULL;
-
-void TimeMillisUpdateTask::task() {
- os::update_global_time();
-}
-
-void TimeMillisUpdateTask::engage() {
- assert(_task == NULL, "init twice?");
- os::update_global_time(); // initial update
- os::enable_global_time();
- _task = new TimeMillisUpdateTask(CacheTimeMillisGranularity);
- _task->enroll();
-}
-
-void TimeMillisUpdateTask::disengage() {
- assert(_task != NULL, "uninit twice?");
- os::disable_global_time();
- _task->disenroll();
- delete _task;
- _task = NULL;
-}
--- a/hotspot/src/share/vm/runtime/task.hpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/task.hpp Wed Mar 19 09:58:01 2008 -0400
@@ -113,13 +113,3 @@
// The task to perform at each period
virtual void task() = 0;
};
-
-class TimeMillisUpdateTask : public PeriodicTask {
- private:
- static TimeMillisUpdateTask* _task;
- public:
- TimeMillisUpdateTask(int interval) : PeriodicTask(interval) {}
- void task();
- static void engage();
- static void disengage();
-};
--- a/hotspot/src/share/vm/runtime/thread.cpp Fri Mar 14 10:43:02 2008 -0400
+++ b/hotspot/src/share/vm/runtime/thread.cpp Wed Mar 19 09:58:01 2008 -0400
@@ -3066,7 +3066,6 @@
if (MemProfiling) MemProfiler::engage();
StatSampler::engage();
if (CheckJNICalls) JniPeriodicChecker::engage();
- if (CacheTimeMillis) TimeMillisUpdateTask::engage();
BiasedLocking::init();