changeset 4504:ee712d4e3af6

Merge
author jwilhelm
date Fri, 01 Mar 2013 03:54:26 +0100
parents 90e4826656f8 4ddaaf331af4
children f33d68f8b40e
files
diffstat 3 files changed, 23 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/atomic.hpp	Thu Feb 28 11:15:56 2013 -0800
+++ b/src/share/vm/runtime/atomic.hpp	Fri Mar 01 03:54:26 2013 +0100
@@ -29,10 +29,17 @@
 
 class Atomic : AllStatic {
  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
   static void store    (jbyte    store_value, jbyte*    dest);
   static void store    (jshort   store_value, jshort*   dest);
   static void store    (jint     store_value, jint*     dest);
+  // See comment above about using jlong atomics on 32-bit platforms
   static void store    (jlong    store_value, jlong*    dest);
   static void store_ptr(intptr_t store_value, intptr_t* dest);
   static void store_ptr(void*    store_value, void*     dest);
@@ -40,17 +47,19 @@
   static void store    (jbyte    store_value, volatile jbyte*    dest);
   static void store    (jshort   store_value, volatile jshort*   dest);
   static void store    (jint     store_value, volatile jint*     dest);
+  // See comment above about using jlong atomics on 32-bit platforms
   static void store    (jlong    store_value, volatile jlong*    dest);
   static void store_ptr(intptr_t store_value, volatile intptr_t* dest);
   static void store_ptr(void*    store_value, volatile void*     dest);
 
+  // See comment above about using jlong atomics on 32-bit platforms
   static jlong load(volatile jlong* src);
 
   // Atomically add to a location, return updated value
   static jint     add    (jint     add_value, volatile jint*     dest);
   static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
   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);
 
   // Atomically increment location
@@ -76,6 +85,7 @@
   // 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 jint     cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value);
+  // See comment above about using jlong atomics on 32-bit platforms
   static jlong    cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value);
 
   static unsigned int cmpxchg(unsigned int exchange_value,
--- a/src/share/vm/utilities/ostream.cpp	Thu Feb 28 11:15:56 2013 -0800
+++ b/src/share/vm/utilities/ostream.cpp	Fri Mar 01 03:54:26 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -433,7 +433,7 @@
 
 rotatingFileStream::rotatingFileStream(const char* file_name) {
   _cur_file_num = 0;
-  _bytes_writen = 0L;
+  _bytes_written = 0L;
   _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);
   _file = fopen(_file_name, "w");
@@ -442,7 +442,7 @@
 
 rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) {
   _cur_file_num = 0;
-  _bytes_writen = 0L;
+  _bytes_written = 0L;
   _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);
   _file = fopen(_file_name, opentype);
@@ -450,10 +450,9 @@
 }
 
 void rotatingFileStream::write(const char* s, size_t len) {
-  if (_file != NULL)  {
-    // Make an unused local variable to avoid warning from gcc 4.x compiler.
+  if (_file != NULL) {
     size_t count = fwrite(s, 1, len, _file);
-    Atomic::add((jlong)count, &_bytes_writen);
+    _bytes_written += count;
   }
   update_position(s, len);
 }
@@ -467,7 +466,10 @@
 // concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log
 // must be synchronized.
 void rotatingFileStream::rotate_log() {
-  if (_bytes_writen < (jlong)GCLogFileSize) return;
+  if (_bytes_written < (jlong)GCLogFileSize) {
+    return;
+  }
+
 #ifdef ASSERT
   Thread *thread = Thread::current();
   assert(thread == NULL ||
@@ -477,7 +479,7 @@
   if (NumberOfGCLogFiles == 1) {
     // rotate in same file
     rewind();
-    _bytes_writen = 0L;
+    _bytes_written = 0L;
     return;
   }
 
@@ -493,7 +495,7 @@
   }
   _file = fopen(_file_name, "w");
   if (_file != NULL) {
-    _bytes_writen = 0L;
+    _bytes_written = 0L;
     _need_close = true;
   } else {
     tty->print_cr("failed to open rotation log file %s due to %s\n",
--- a/src/share/vm/utilities/ostream.hpp	Thu Feb 28 11:15:56 2013 -0800
+++ b/src/share/vm/utilities/ostream.hpp	Fri Mar 01 03:54:26 2013 +0100
@@ -231,7 +231,7 @@
 class rotatingFileStream : public fileStream {
  protected:
   char*  _file_name;
-  jlong  _bytes_writen;
+  jlong  _bytes_written;
   uintx  _cur_file_num;             // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1
  public:
   rotatingFileStream(const char* file_name);