提交 2c4229b2 编写于 作者: J jwilhelm

8008314: Unimplemented() Atomic::load breaks the applications

Summary: jlong atomics isn't fully implemented om all 32-bit platforms so we try to avoid it. In this case the atomic add wasn't needed.
Reviewed-by: dholmes, dlong
上级 36784d6b
...@@ -29,10 +29,17 @@ ...@@ -29,10 +29,17 @@
class Atomic : AllStatic { class Atomic : AllStatic {
public: public:
// Atomic operations on jlong types are not available on all 32-bit
// platforms. If atomic ops on jlongs are defined here they must only
// be used from code that verifies they are available at runtime and
// can provide an alternative action if not - see supports_cx8() for
// a means to test availability.
// Atomically store to a location // Atomically store to a location
inline static void store (jbyte store_value, jbyte* dest); inline static void store (jbyte store_value, jbyte* dest);
inline static void store (jshort store_value, jshort* dest); inline static void store (jshort store_value, jshort* dest);
inline static void store (jint store_value, jint* dest); inline static void store (jint store_value, jint* dest);
// See comment above about using jlong atomics on 32-bit platforms
inline static void store (jlong store_value, jlong* dest); inline static void store (jlong store_value, jlong* dest);
inline static void store_ptr(intptr_t store_value, intptr_t* dest); inline static void store_ptr(intptr_t store_value, intptr_t* dest);
inline static void store_ptr(void* store_value, void* dest); inline static void store_ptr(void* store_value, void* dest);
...@@ -40,17 +47,19 @@ class Atomic : AllStatic { ...@@ -40,17 +47,19 @@ class Atomic : AllStatic {
inline static void store (jbyte store_value, volatile jbyte* dest); inline static void store (jbyte store_value, volatile jbyte* dest);
inline static void store (jshort store_value, volatile jshort* dest); inline static void store (jshort store_value, volatile jshort* dest);
inline static void store (jint store_value, volatile jint* dest); inline static void store (jint store_value, volatile jint* dest);
// See comment above about using jlong atomics on 32-bit platforms
inline static void store (jlong store_value, volatile jlong* dest); inline static void store (jlong store_value, volatile jlong* dest);
inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest); inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest);
inline static void store_ptr(void* store_value, volatile void* dest); inline static void store_ptr(void* store_value, volatile void* dest);
// See comment above about using jlong atomics on 32-bit platforms
inline static jlong load(volatile jlong* src); inline static jlong load(volatile jlong* src);
// Atomically add to a location, return updated value // Atomically add to a location, return updated value
inline static jint add (jint add_value, volatile jint* dest); inline static jint add (jint add_value, volatile jint* dest);
inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest); inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
inline static void* add_ptr(intptr_t add_value, volatile void* dest); inline static void* add_ptr(intptr_t add_value, volatile void* dest);
// See comment above about using jlong atomics on 32-bit platforms
static jlong add (jlong add_value, volatile jlong* dest); static jlong add (jlong add_value, volatile jlong* dest);
// Atomically increment location // Atomically increment location
...@@ -75,6 +84,7 @@ class Atomic : AllStatic { ...@@ -75,6 +84,7 @@ class Atomic : AllStatic {
// barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'. // barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'.
static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value); static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value);
inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value); inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value);
// See comment above about using jlong atomics on 32-bit platforms
inline static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value); inline static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value);
static unsigned int cmpxchg(unsigned int exchange_value, static unsigned int cmpxchg(unsigned int exchange_value,
......
...@@ -431,7 +431,7 @@ rotatingFileStream::~rotatingFileStream() { ...@@ -431,7 +431,7 @@ rotatingFileStream::~rotatingFileStream() {
rotatingFileStream::rotatingFileStream(const char* file_name) { rotatingFileStream::rotatingFileStream(const char* file_name) {
_cur_file_num = 0; _cur_file_num = 0;
_bytes_writen = 0L; _bytes_written = 0L;
_file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal); _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
_file = fopen(_file_name, "w"); _file = fopen(_file_name, "w");
...@@ -440,7 +440,7 @@ rotatingFileStream::rotatingFileStream(const char* file_name) { ...@@ -440,7 +440,7 @@ rotatingFileStream::rotatingFileStream(const char* file_name) {
rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) { rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) {
_cur_file_num = 0; _cur_file_num = 0;
_bytes_writen = 0L; _bytes_written = 0L;
_file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal); _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num); jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
_file = fopen(_file_name, opentype); _file = fopen(_file_name, opentype);
...@@ -448,10 +448,9 @@ rotatingFileStream::rotatingFileStream(const char* file_name, const char* openty ...@@ -448,10 +448,9 @@ rotatingFileStream::rotatingFileStream(const char* file_name, const char* openty
} }
void rotatingFileStream::write(const char* s, size_t len) { void rotatingFileStream::write(const char* s, size_t len) {
if (_file != NULL) { if (_file != NULL) {
// Make an unused local variable to avoid warning from gcc 4.x compiler.
size_t count = fwrite(s, 1, len, _file); size_t count = fwrite(s, 1, len, _file);
Atomic::add((jlong)count, &_bytes_writen); _bytes_written += count;
} }
update_position(s, len); update_position(s, len);
} }
...@@ -465,7 +464,10 @@ void rotatingFileStream::write(const char* s, size_t len) { ...@@ -465,7 +464,10 @@ void rotatingFileStream::write(const char* s, size_t len) {
// concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log // concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log
// must be synchronized. // must be synchronized.
void rotatingFileStream::rotate_log() { void rotatingFileStream::rotate_log() {
if (_bytes_writen < (jlong)GCLogFileSize) return; if (_bytes_written < (jlong)GCLogFileSize) {
return;
}
#ifdef ASSERT #ifdef ASSERT
Thread *thread = Thread::current(); Thread *thread = Thread::current();
assert(thread == NULL || assert(thread == NULL ||
...@@ -475,7 +477,7 @@ void rotatingFileStream::rotate_log() { ...@@ -475,7 +477,7 @@ void rotatingFileStream::rotate_log() {
if (NumberOfGCLogFiles == 1) { if (NumberOfGCLogFiles == 1) {
// rotate in same file // rotate in same file
rewind(); rewind();
_bytes_writen = 0L; _bytes_written = 0L;
return; return;
} }
...@@ -491,7 +493,7 @@ void rotatingFileStream::rotate_log() { ...@@ -491,7 +493,7 @@ void rotatingFileStream::rotate_log() {
} }
_file = fopen(_file_name, "w"); _file = fopen(_file_name, "w");
if (_file != NULL) { if (_file != NULL) {
_bytes_writen = 0L; _bytes_written = 0L;
_need_close = true; _need_close = true;
} else { } else {
tty->print_cr("failed to open rotation log file %s due to %s\n", tty->print_cr("failed to open rotation log file %s due to %s\n",
......
...@@ -231,7 +231,7 @@ class fdStream : public outputStream { ...@@ -231,7 +231,7 @@ class fdStream : public outputStream {
class rotatingFileStream : public fileStream { class rotatingFileStream : public fileStream {
protected: protected:
char* _file_name; char* _file_name;
jlong _bytes_writen; jlong _bytes_written;
uintx _cur_file_num; // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1 uintx _cur_file_num; // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1
public: public:
rotatingFileStream(const char* file_name); rotatingFileStream(const char* file_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册