6667833: Remove CacheTimeMillis

Remove -XX:+CacheTimeMillis option and associated functionality

Reviewed-by: acorn, never
This commit is contained in:
Steve Bohne 2008-03-19 09:58:01 -04:00
parent 387f42921b
commit bf559c6dce
11 changed files with 12 additions and 155 deletions

View File

@ -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

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();
}

View File

@ -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);
}
}

View File

@ -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);
// }
}
}

View File

@ -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") \
\

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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();
};

View File

@ -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();