Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/os.cpp @ 61:5a76ab815e34
6667833: Remove CacheTimeMillis
Summary: Remove -XX:+CacheTimeMillis option and associated functionality
Reviewed-by: acorn, never
author | sbohne |
---|---|
date | Wed, 19 Mar 2008 09:58:01 -0400 |
parents | 2a8eb116ebbe |
children | d1605aabd0a1 |
comparison
equal
deleted
inserted
replaced
60:8d84e28e68ba | 61:5a76ab815e34 |
---|---|
31 address os::_polling_page = NULL; | 31 address os::_polling_page = NULL; |
32 volatile int32_t* os::_mem_serialize_page = NULL; | 32 volatile int32_t* os::_mem_serialize_page = NULL; |
33 uintptr_t os::_serialize_page_mask = 0; | 33 uintptr_t os::_serialize_page_mask = 0; |
34 long os::_rand_seed = 1; | 34 long os::_rand_seed = 1; |
35 int os::_processor_count = 0; | 35 int os::_processor_count = 0; |
36 volatile jlong os::_global_time = 0; | |
37 volatile int os::_global_time_lock = 0; | |
38 bool os::_use_global_time = false; | |
39 size_t os::_page_sizes[os::page_sizes_max]; | 36 size_t os::_page_sizes[os::page_sizes_max]; |
40 | 37 |
41 #ifndef PRODUCT | 38 #ifndef PRODUCT |
42 int os::num_mallocs = 0; // # of calls to malloc/realloc | 39 int os::num_mallocs = 0; // # of calls to malloc/realloc |
43 size_t os::alloc_bytes = 0; // # of bytes allocated | 40 size_t os::alloc_bytes = 0; // # of bytes allocated |
44 int os::num_frees = 0; // # of calls to free | 41 int os::num_frees = 0; // # of calls to free |
45 #endif | 42 #endif |
46 | |
47 // Atomic read of a jlong is assured by a seqlock; see update_global_time() | |
48 jlong os::read_global_time() { | |
49 #ifdef _LP64 | |
50 return _global_time; | |
51 #else | |
52 volatile int lock; | |
53 volatile jlong current_time; | |
54 int ctr = 0; | |
55 | |
56 for (;;) { | |
57 lock = _global_time_lock; | |
58 | |
59 // spin while locked | |
60 while ((lock & 0x1) != 0) { | |
61 ++ctr; | |
62 if ((ctr & 0xFFF) == 0) { | |
63 // Guarantee writer progress. Can't use yield; yield is advisory | |
64 // and has almost no effect on some platforms. Don't need a state | |
65 // transition - the park call will return promptly. | |
66 assert(Thread::current() != NULL, "TLS not initialized"); | |
67 assert(Thread::current()->_ParkEvent != NULL, "sync not initialized"); | |
68 Thread::current()->_ParkEvent->park(1); | |
69 } | |
70 lock = _global_time_lock; | |
71 } | |
72 | |
73 OrderAccess::loadload(); | |
74 current_time = _global_time; | |
75 OrderAccess::loadload(); | |
76 | |
77 // ratify seqlock value | |
78 if (lock == _global_time_lock) { | |
79 return current_time; | |
80 } | |
81 } | |
82 #endif | |
83 } | |
84 | |
85 // | |
86 // NOTE - Assumes only one writer thread! | |
87 // | |
88 // We use a seqlock to guarantee that jlong _global_time is updated | |
89 // atomically on 32-bit platforms. A locked value is indicated by | |
90 // the lock variable LSB == 1. Readers will initially read the lock | |
91 // value, spinning until the LSB == 0. They then speculatively read | |
92 // the global time value, then re-read the lock value to ensure that | |
93 // it hasn't changed. If the lock value has changed, the entire read | |
94 // sequence is retried. | |
95 // | |
96 // Writers simply set the LSB = 1 (i.e. increment the variable), | |
97 // update the global time, then release the lock and bump the version | |
98 // number (i.e. increment the variable again.) In this case we don't | |
99 // even need a CAS since we ensure there's only one writer. | |
100 // | |
101 void os::update_global_time() { | |
102 #ifdef _LP64 | |
103 _global_time = timeofday(); | |
104 #else | |
105 assert((_global_time_lock & 0x1) == 0, "multiple writers?"); | |
106 jlong current_time = timeofday(); | |
107 _global_time_lock++; // lock | |
108 OrderAccess::storestore(); | |
109 _global_time = current_time; | |
110 OrderAccess::storestore(); | |
111 _global_time_lock++; // unlock | |
112 #endif | |
113 } | |
114 | 43 |
115 // Fill in buffer with current local time as an ISO-8601 string. | 44 // Fill in buffer with current local time as an ISO-8601 string. |
116 // E.g., yyyy-mm-ddThh:mm:ss-zzzz. | 45 // E.g., yyyy-mm-ddThh:mm:ss-zzzz. |
117 // Returns buffer, or NULL if it failed. | 46 // Returns buffer, or NULL if it failed. |
118 // This would mostly be a call to | 47 // This would mostly be a call to |
136 if (buffer_length < needed_buffer) { | 65 if (buffer_length < needed_buffer) { |
137 assert(false, "buffer_length too small"); | 66 assert(false, "buffer_length too small"); |
138 return NULL; | 67 return NULL; |
139 } | 68 } |
140 // Get the current time | 69 // Get the current time |
141 jlong milliseconds_since_19700101 = timeofday(); | 70 jlong milliseconds_since_19700101 = javaTimeMillis(); |
142 const int milliseconds_per_microsecond = 1000; | 71 const int milliseconds_per_microsecond = 1000; |
143 const time_t seconds_since_19700101 = | 72 const time_t seconds_since_19700101 = |
144 milliseconds_since_19700101 / milliseconds_per_microsecond; | 73 milliseconds_since_19700101 / milliseconds_per_microsecond; |
145 const int milliseconds_after_second = | 74 const int milliseconds_after_second = |
146 milliseconds_since_19700101 % milliseconds_per_microsecond; | 75 milliseconds_since_19700101 % milliseconds_per_microsecond; |