From 7091139d3622472457eb5fa8ce9399183be441ad Mon Sep 17 00:00:00 2001 From: sbohne Date: Wed, 19 Mar 2008 09:58:01 -0400 Subject: [PATCH] 6667833: Remove CacheTimeMillis Summary: Remove -XX:+CacheTimeMillis option and associated functionality Reviewed-by: acorn, never --- src/os/linux/vm/os_linux.cpp | 8 +--- src/os/solaris/vm/os_solaris.cpp | 11 ++--- src/os/windows/vm/os_windows.cpp | 13 ++---- src/share/vm/runtime/arguments.cpp | 10 ++-- src/share/vm/runtime/globals.hpp | 6 --- src/share/vm/runtime/java.cpp | 5 -- src/share/vm/runtime/os.cpp | 73 +----------------------------- src/share/vm/runtime/os.hpp | 8 ---- src/share/vm/runtime/task.cpp | 22 --------- src/share/vm/runtime/task.hpp | 10 ---- src/share/vm/runtime/thread.cpp | 1 - 11 files changed, 12 insertions(+), 155 deletions(-) diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp index a327fd915..86e1c4557 100644 --- a/src/os/linux/vm/os_linux.cpp +++ b/src/os/linux/vm/os_linux.cpp @@ -1247,19 +1247,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 diff --git a/src/os/solaris/vm/os_solaris.cpp b/src/os/solaris/vm/os_solaris.cpp index 8d0861c70..f44626692 100644 --- a/src/os/solaris/vm/os_solaris.cpp +++ b/src/os/solaris/vm/os_solaris.cpp @@ -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(); } diff --git a/src/os/windows/vm/os_windows.cpp b/src/os/windows/vm/os_windows.cpp index 7f2293385..2f02a9562 100644 --- a/src/os/windows/vm/os_windows.cpp +++ b/src/os/windows/vm/os_windows.cpp @@ -732,20 +732,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); } } diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp index 5d0329ad0..53f3dc646 100644 --- a/src/share/vm/runtime/arguments.cpp +++ b/src/share/vm/runtime/arguments.cpp @@ -1255,12 +1255,10 @@ void Arguments::set_bytecode_flags() { // 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); +// } } } diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp index c1e8fefeb..664b806d6 100644 --- a/src/share/vm/runtime/globals.hpp +++ b/src/share/vm/runtime/globals.hpp @@ -344,12 +344,6 @@ class CommandLineFlags { 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") \ \ diff --git a/src/share/vm/runtime/java.cpp b/src/share/vm/runtime/java.cpp index f7ed8939e..a9f6fc7db 100644 --- a/src/share/vm/runtime/java.cpp +++ b/src/share/vm/runtime/java.cpp @@ -390,11 +390,6 @@ void before_exit(JavaThread * thread) { StatSampler::disengage(); StatSampler::destroy(); - // shut down the TimeMillisUpdateTask - if (CacheTimeMillis) { - TimeMillisUpdateTask::disengage(); - } - #ifndef SERIALGC // stop CMS threads if (UseConcMarkSweepGC) { diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp index 980c11793..164ba95a1 100644 --- a/src/share/vm/runtime/os.cpp +++ b/src/share/vm/runtime/os.cpp @@ -33,9 +33,6 @@ volatile int32_t* os::_mem_serialize_page = NULL; 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 @@ size_t os::alloc_bytes = 0; // # of bytes allocated 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 @@ char* os::iso8601_time(char* buffer, size_t buffer_length) { 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; diff --git a/src/share/vm/runtime/os.hpp b/src/share/vm/runtime/os.hpp index 4762efc51..9cd4eb476 100644 --- a/src/share/vm/runtime/os.hpp +++ b/src/share/vm/runtime/os.hpp @@ -66,9 +66,6 @@ class os: AllStatic { 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 @@ class os: AllStatic { 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); diff --git a/src/share/vm/runtime/task.cpp b/src/share/vm/runtime/task.cpp index 0fd1bed8a..68959a120 100644 --- a/src/share/vm/runtime/task.cpp +++ b/src/share/vm/runtime/task.cpp @@ -107,25 +107,3 @@ void PeriodicTask::disenroll() { _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; -} diff --git a/src/share/vm/runtime/task.hpp b/src/share/vm/runtime/task.hpp index 924562cf0..83e595cf3 100644 --- a/src/share/vm/runtime/task.hpp +++ b/src/share/vm/runtime/task.hpp @@ -113,13 +113,3 @@ class PeriodicTask: public CHeapObj { // 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(); -}; diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp index 607772a02..af9804435 100644 --- a/src/share/vm/runtime/thread.cpp +++ b/src/share/vm/runtime/thread.cpp @@ -3066,7 +3066,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { if (MemProfiling) MemProfiler::engage(); StatSampler::engage(); if (CheckJNICalls) JniPeriodicChecker::engage(); - if (CacheTimeMillis) TimeMillisUpdateTask::engage(); BiasedLocking::init(); -- GitLab