提交 7091139d 编写于 作者: S sbohne

6667833: Remove CacheTimeMillis

Summary: Remove -XX:+CacheTimeMillis option and associated functionality
Reviewed-by: acorn, never
上级 355eeaa1
...@@ -1247,19 +1247,13 @@ jlong os::elapsed_frequency() { ...@@ -1247,19 +1247,13 @@ jlong os::elapsed_frequency() {
return (1000 * 1000); return (1000 * 1000);
} }
jlong os::timeofday() { jlong os::javaTimeMillis() {
timeval time; timeval time;
int status = gettimeofday(&time, NULL); int status = gettimeofday(&time, NULL);
assert(status != -1, "linux error"); assert(status != -1, "linux error");
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000); 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 #ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC (1) #define CLOCK_MONOTONIC (1)
#endif #endif
......
...@@ -1691,19 +1691,14 @@ jlong getTimeMillis() { ...@@ -1691,19 +1691,14 @@ jlong getTimeMillis() {
return (jlong)(nanotime / NANOSECS_PER_MILLISECS); return (jlong)(nanotime / NANOSECS_PER_MILLISECS);
} }
jlong os::timeofday() { // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
jlong os::javaTimeMillis() {
timeval t; timeval t;
if (gettimeofday( &t, NULL) == -1) 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; 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() { jlong os::javaTimeNanos() {
return (jlong)getTimeNanos(); return (jlong)getTimeNanos();
} }
......
...@@ -732,20 +732,13 @@ FILETIME java_to_windows_time(jlong l) { ...@@ -732,20 +732,13 @@ FILETIME java_to_windows_time(jlong l) {
return result; 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() { jlong os::javaTimeMillis() {
if (UseFakeTimers) { if (UseFakeTimers) {
return fake_time++; return fake_time++;
} else { } else {
return (_use_global_time ? read_global_time() : timeofday()); FILETIME wt;
GetSystemTimeAsFileTime(&wt);
return windows_to_java_time(wt);
} }
} }
......
...@@ -1255,12 +1255,10 @@ void Arguments::set_bytecode_flags() { ...@@ -1255,12 +1255,10 @@ void Arguments::set_bytecode_flags() {
// Aggressive optimization flags -XX:+AggressiveOpts // Aggressive optimization flags -XX:+AggressiveOpts
void Arguments::set_aggressive_opts_flags() { void Arguments::set_aggressive_opts_flags() {
if (AggressiveOpts) { if (AggressiveOpts) {
NOT_WINDOWS( // Sample flag setting code
// No measured benefit on Windows // if (FLAG_IS_DEFAULT(EliminateZeroing)) {
if (FLAG_IS_DEFAULT(CacheTimeMillis)) { // FLAG_SET_DEFAULT(EliminateZeroing, true);
FLAG_SET_DEFAULT(CacheTimeMillis, true); // }
}
)
} }
} }
......
...@@ -344,12 +344,6 @@ class CommandLineFlags { ...@@ -344,12 +344,6 @@ class CommandLineFlags {
product(bool, ForceTimeHighResolution, false, \ product(bool, ForceTimeHighResolution, false, \
"Using high time resolution(For Win32 only)") \ "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, \ develop(bool, TraceItables, false, \
"Trace initialization and use of itables") \ "Trace initialization and use of itables") \
\ \
......
...@@ -390,11 +390,6 @@ void before_exit(JavaThread * thread) { ...@@ -390,11 +390,6 @@ void before_exit(JavaThread * thread) {
StatSampler::disengage(); StatSampler::disengage();
StatSampler::destroy(); StatSampler::destroy();
// shut down the TimeMillisUpdateTask
if (CacheTimeMillis) {
TimeMillisUpdateTask::disengage();
}
#ifndef SERIALGC #ifndef SERIALGC
// stop CMS threads // stop CMS threads
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
......
...@@ -33,9 +33,6 @@ volatile int32_t* os::_mem_serialize_page = NULL; ...@@ -33,9 +33,6 @@ volatile int32_t* os::_mem_serialize_page = NULL;
uintptr_t os::_serialize_page_mask = 0; uintptr_t os::_serialize_page_mask = 0;
long os::_rand_seed = 1; long os::_rand_seed = 1;
int os::_processor_count = 0; 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]; size_t os::_page_sizes[os::page_sizes_max];
#ifndef PRODUCT #ifndef PRODUCT
...@@ -44,74 +41,6 @@ size_t os::alloc_bytes = 0; // # of bytes allocated ...@@ -44,74 +41,6 @@ size_t os::alloc_bytes = 0; // # of bytes allocated
int os::num_frees = 0; // # of calls to free int os::num_frees = 0; // # of calls to free
#endif #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. // Fill in buffer with current local time as an ISO-8601 string.
// E.g., yyyy-mm-ddThh:mm:ss-zzzz. // E.g., yyyy-mm-ddThh:mm:ss-zzzz.
// Returns buffer, or NULL if it failed. // Returns buffer, or NULL if it failed.
...@@ -138,7 +67,7 @@ char* os::iso8601_time(char* buffer, size_t buffer_length) { ...@@ -138,7 +67,7 @@ char* os::iso8601_time(char* buffer, size_t buffer_length) {
return NULL; return NULL;
} }
// Get the current time // Get the current time
jlong milliseconds_since_19700101 = timeofday(); jlong milliseconds_since_19700101 = javaTimeMillis();
const int milliseconds_per_microsecond = 1000; const int milliseconds_per_microsecond = 1000;
const time_t seconds_since_19700101 = const time_t seconds_since_19700101 =
milliseconds_since_19700101 / milliseconds_per_microsecond; milliseconds_since_19700101 / milliseconds_per_microsecond;
......
...@@ -66,9 +66,6 @@ class os: AllStatic { ...@@ -66,9 +66,6 @@ class os: AllStatic {
static address _polling_page; static address _polling_page;
static volatile int32_t * _mem_serialize_page; static volatile int32_t * _mem_serialize_page;
static uintptr_t _serialize_page_mask; 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 size_t _page_sizes[page_sizes_max];
static void init_page_sizes(size_t default_page_size) { static void init_page_sizes(size_t default_page_size) {
...@@ -88,11 +85,6 @@ class os: AllStatic { ...@@ -88,11 +85,6 @@ class os: AllStatic {
static bool getenv(const char* name, char* buffer, int len); static bool getenv(const char* name, char* buffer, int len);
static bool have_special_privileges(); 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 javaTimeMillis();
static jlong javaTimeNanos(); static jlong javaTimeNanos();
static void javaTimeNanos_info(jvmtiTimerInfo *info_ptr); static void javaTimeNanos_info(jvmtiTimerInfo *info_ptr);
......
...@@ -107,25 +107,3 @@ void PeriodicTask::disenroll() { ...@@ -107,25 +107,3 @@ void PeriodicTask::disenroll() {
_tasks[index] = _tasks[index+1]; _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;
}
...@@ -113,13 +113,3 @@ class PeriodicTask: public CHeapObj { ...@@ -113,13 +113,3 @@ class PeriodicTask: public CHeapObj {
// The task to perform at each period // The task to perform at each period
virtual void task() = 0; 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();
};
...@@ -3066,7 +3066,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { ...@@ -3066,7 +3066,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
if (MemProfiling) MemProfiler::engage(); if (MemProfiling) MemProfiler::engage();
StatSampler::engage(); StatSampler::engage();
if (CheckJNICalls) JniPeriodicChecker::engage(); if (CheckJNICalls) JniPeriodicChecker::engage();
if (CacheTimeMillis) TimeMillisUpdateTask::engage();
BiasedLocking::init(); BiasedLocking::init();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册