changeset 2971:18b6e9eaf3e8

Backport of 7197906 (bundled HotSpot only) and addition of a simpler fix for the 7017193 memory leak. 2013-03-18 Andrew John Hughes <gnu.andrew@redhat.com> * Makefile.am: (ICEDTEA_PATCHES): Add new patches to appropriate HotSpot builds. * patches/hotspot/hs23/revert-7017193.patch: Backport from 2.x series. Revert the upstream fix for 7017193 and add a much simpler fix using free which doesn't suffer from performance issues. https://bugzilla.redhat.com/show_bug.cgi?id=902004 For HotSpot 23 only. * patches/hotspot/original/7197906-handle_32_bit_shifts.patch: Backport from OpenJDK 7 for bundled HotSpot only. * patches/hotspot/original/fix_get_stack_bounds_leak.patch: Same fix for 7017193 as in patch above, but for bundled HotSpot, which doesn't have the upstream fix. * NEWS: Updated.
author Andrew John Hughes <gnu.andrew@redhat.com>
date Mon, 18 Mar 2013 21:34:40 +0000
parents 0bca9bac254b
children 02a65b9914d5 6415ddeeeb09
files ChangeLog Makefile.am NEWS patches/hotspot/hs23/revert-7017193.patch patches/hotspot/original/7197906-handle_32_bit_shifts.patch patches/hotspot/original/fix_get_stack_bounds_leak.patch
diffstat 6 files changed, 209 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 18 17:45:37 2013 +0000
+++ b/ChangeLog	Mon Mar 18 21:34:40 2013 +0000
@@ -1,3 +1,21 @@
+2013-03-18  Andrew John Hughes  <gnu.andrew@redhat.com>
+
+	* Makefile.am:
+	(ICEDTEA_PATCHES): Add new patches to appropriate
+	HotSpot builds.
+	* patches/hotspot/hs23/revert-7017193.patch:
+	Backport from 2.x series.  Revert the upstream
+	fix for 7017193 and add a much simpler fix using
+	free which doesn't suffer from performance issues.
+	https://bugzilla.redhat.com/show_bug.cgi?id=902004
+	For HotSpot 23 only.
+	* patches/hotspot/original/7197906-handle_32_bit_shifts.patch:
+	Backport from OpenJDK 7 for bundled HotSpot only.
+	* patches/hotspot/original/fix_get_stack_bounds_leak.patch:
+	Same fix for 7017193 as in patch above, but for bundled HotSpot,
+	which doesn't have the upstream fix.
+	* NEWS: Updated.
+
 2013-03-18  Andrew John Hughes  <gnu.andrew@redhat.com>
 
 	* hotspot.map: Sync with IcedTea7 2.3 tree
--- a/Makefile.am	Mon Mar 18 17:45:37 2013 +0000
+++ b/Makefile.am	Mon Mar 18 21:34:40 2013 +0000
@@ -482,7 +482,8 @@
 
 if WITH_ALT_HSBUILD
 ICEDTEA_PATCHES += \
-	patches/hotspot/hs23/remove_jsr292_tests.patch
+	patches/hotspot/hs23/remove_jsr292_tests.patch \
+	patches/hotspot/hs23/revert-7017193.patch
 else
 # stdc-limit-macros is part of 7032458
 # pr690-shark-jit-hs20.patch is part of 7032458
@@ -524,7 +525,9 @@
 	patches/pr690-shark-jit-hs20.patch \
 	patches/pr696-zero-fast_aldc-hs20.patch \
 	patches/arm-debug.patch \
-	patches/openjdk/7010849-modernise_sa.patch
+	patches/openjdk/7010849-modernise_sa.patch \
+	patches/hotspot/original/7197906-handle_32_bit_shifts.patch \
+	patches/hotspot/original/fix_get_stack_bounds_leak.patch
 endif
 
 if WITH_RHINO
--- a/NEWS	Mon Mar 18 17:45:37 2013 +0000
+++ b/NEWS	Mon Mar 18 21:34:40 2013 +0000
@@ -16,8 +16,11 @@
   - PR1317: Provide an option to build with a more up-to-date HotSpot
 * Backports
   - S8009641: OpenJDK 6 build broken via 8007675 fix
+  - S7197906: BlockOffsetArray::power_to_cards_back() needs to handle > 32 bit shifts (bundled HotSpot only)
 * Bug fixes
   - PR1318: Fix automatic enabling of the Zero build on non-JIT architectures which don't use CACAO or JamVM.
+  - RH902004: very bad performance with E-Porto Add-In für OpenOffice Writer installed (hs23 only)
+  - Fix get_stack_bounds memory leak (alternate fix for S7197906, bundled HotSpot only)
 
 New in release 1.12.4 (2013-03-04):
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/hotspot/hs23/revert-7017193.patch	Mon Mar 18 21:34:40 2013 +0000
@@ -0,0 +1,138 @@
+diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
+--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp
++++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
+@@ -2763,39 +2763,47 @@
+ // writing thread stacks don't use growable mappings (i.e. those
+ // creeated with MAP_GROWSDOWN), and aren't marked "[stack]", so this
+ // only applies to the main thread.
+-
+-static
+-bool get_stack_bounds(uintptr_t *bottom, uintptr_t *top) {
+-
+-  char buf[128];
+-  int fd, sz;
+-
+-  if ((fd = ::open("/proc/self/maps", O_RDONLY)) < 0) {
++static bool
++get_stack_bounds(uintptr_t *bottom, uintptr_t *top)
++{
++  FILE *f = fopen("/proc/self/maps", "r");
++  if (f == NULL)
+     return false;
+-  }
+-
+-  const char kw[] = "[stack]";
+-  const int kwlen = sizeof(kw)-1;
+-
+-  // Address part of /proc/self/maps couldn't be more than 128 bytes
+-  while ((sz = os::get_line_chars(fd, buf, sizeof(buf))) > 0) {
+-     if (sz > kwlen && ::memcmp(buf+sz-kwlen, kw, kwlen) == 0) {
+-        // Extract addresses
+-        if (sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, bottom, top) == 2) {
+-           uintptr_t sp = (uintptr_t) __builtin_frame_address(0);
+-           if (sp >= *bottom && sp <= *top) {
+-              ::close(fd);
+-              return true;
+-           }
++
++  while (!feof(f)) {
++    size_t dummy;
++    char *str = NULL;
++    ssize_t len = getline(&str, &dummy, f);
++    if (len == -1) {
++      fclose(f);
++      if (str != NULL)
++	free(str);
++      return false;
++    }
++
++    if (len > 0 && str[len-1] == '\n') {
++      str[len-1] = 0;
++      len--;
++    }
++
++    static const char *stack_str = "[stack]";
++    if (len > (ssize_t)strlen(stack_str)
++       && (strcmp(str + len - strlen(stack_str), stack_str) == 0)) {
++      if (sscanf(str, "%" SCNxPTR "-%" SCNxPTR, bottom, top) == 2) {
++        uintptr_t sp = (uintptr_t)__builtin_frame_address(0);
++        if (sp >= *bottom && sp <= *top) {
++          free(str);
++          fclose(f);
++          return true;
+         }
+-     }
+-  }
+-
+- ::close(fd);
++      }
++    }
++    free(str);
++  }
++  fclose(f);
+   return false;
+ }
+ 
+-
+ // If the (growable) stack mapping already extends beyond the point
+ // where we're going to put our guard pages, truncate the mapping at
+ // that point by munmap()ping it.  This ensures that when we later
+diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp
+--- openjdk/hotspot/src/share/vm/runtime/os.cpp
++++ openjdk/hotspot/src/share/vm/runtime/os.cpp
+@@ -1331,41 +1331,3 @@
+   }
+   return result;
+ }
+-
+-// Read file line by line, if line is longer than bsize,
+-// skip rest of line.
+-int os::get_line_chars(int fd, char* buf, const size_t bsize){
+-  size_t sz, i = 0;
+-
+-  // read until EOF, EOL or buf is full
+-  while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') {
+-     ++i;
+-  }
+-
+-  if (buf[i] == '\n') {
+-    // EOL reached so ignore EOL character and return
+-
+-    buf[i] = 0;
+-    return (int) i;
+-  }
+-
+-  buf[i+1] = 0;
+-
+-  if (sz != 1) {
+-    // EOF reached. if we read chars before EOF return them and
+-    // return EOF on next call otherwise return EOF
+-
+-    return (i == 0) ? -1 : (int) i;
+-  }
+-
+-  // line is longer than size of buf, skip to EOL
+-  char ch;
+-  while (read(fd, &ch, 1) == 1 && ch != '\n') {
+-    // Do nothing
+-  }
+-
+-  // return initial part of line that fits in buf.
+-  // If we reached EOF, it will be returned on next call.
+-
+-  return (int) i;
+-}
+diff --git a/src/share/vm/runtime/os.hpp b/src/share/vm/runtime/os.hpp
+--- openjdk/hotspot/src/share/vm/runtime/os.hpp
++++ openjdk/hotspot/src/share/vm/runtime/os.hpp
+@@ -672,10 +672,6 @@
+   // Hook for os specific jvm options that we don't want to abort on seeing
+   static bool obsolete_option(const JavaVMOption *option);
+ 
+-  // Read file line by line. If line is longer than bsize,
+-  // rest of line is skipped. Returns number of bytes read or -1 on EOF
+-  static int get_line_chars(int fd, char *buf, const size_t bsize);
+-
+   // Extensions
+ #include "runtime/os_ext.hpp"
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/hotspot/original/7197906-handle_32_bit_shifts.patch	Mon Mar 18 21:34:40 2013 +0000
@@ -0,0 +1,33 @@
+--- openjdk/hotspot/src/share/vm/memory/blockOffsetTable.hpp	2012-09-13 21:22:37.897456500 +0200
++++ openjdk/hotspot/src/share/vm/memory/blockOffsetTable.hpp	2012-09-13 21:22:34.345253300 +0200
+@@ -285,7 +285,7 @@
+   };
+ 
+   static size_t power_to_cards_back(uint i) {
+-    return (size_t)(1 << (LogBase * i));
++    return (size_t)1 << (LogBase * i);
+   }
+   static size_t power_to_words_back(uint i) {
+     return power_to_cards_back(i) * N_words;
+--- openjdk/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	2012-09-13 21:22:37.901456800 +0200
++++ openjdk/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	2012-09-13 21:22:34.354253900 +0200
+@@ -110,7 +110,7 @@
+ #ifndef PRODUCT
+ bool CMBitMapRO::covers(ReservedSpace rs) const {
+   // assert(_bm.map() == _virtual_space.low(), "map inconsistency");
+-  assert(((size_t)_bm.size() * (size_t)(1 << _shifter)) == _bmWordSize,
++  assert(((size_t)_bm.size() * ((size_t)1 << _shifter)) == _bmWordSize,
+          "size inconsistency");
+   return _bmStartWord == (HeapWord*)(rs.base()) &&
+          _bmWordSize  == rs.size()>>LogHeapWordSize;
+--- openjdk/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	2012-09-13 21:22:37.898456600 +0200
++++ openjdk/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	2012-09-13 21:22:34.346253400 +0200
+@@ -273,7 +273,7 @@
+   if (_max_fine_entries == 0) {
+     assert(_mod_max_fine_entries_mask == 0, "Both or none.");
+     size_t max_entries_log = (size_t)log2_long((jlong)G1RSetRegionEntries);
+-    _max_fine_entries = (size_t)(1 << max_entries_log);
++    _max_fine_entries = (size_t)1 << max_entries_log;
+     _mod_max_fine_entries_mask = _max_fine_entries - 1;
+ 
+     assert(_fine_eviction_sample_size == 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/hotspot/original/fix_get_stack_bounds_leak.patch	Mon Mar 18 21:34:40 2013 +0000
@@ -0,0 +1,12 @@
+diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
+--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp
++++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
+@@ -2650,6 +2650,8 @@
+     ssize_t len = getline(&str, &dummy, f);
+     if (len == -1) {
+       fclose(f);
++      if (str != NULL)
++	free(str);
+       return false;
+     }
+