changeset 3263:23d2d46c6d08

6859911: G1: assert(Heap_lock->owner() = NULL, "Should be owned on this thread's behalf") Summary: The used() method assumes that the heap lock is held when it is called. However, when used() is called from print_on(), this is not the case. Reviewed-by: ysr, jmasa
author tonyp
date Wed, 15 Jul 2009 12:22:59 -0400
parents 30d1c247fc25
children 5d4c990fce1c
files hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue Jul 14 15:40:39 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jul 15 12:22:59 2009 -0400
@@ -1666,6 +1666,11 @@
   return result;
 }
 
+size_t G1CollectedHeap::used_unlocked() const {
+  size_t result = _summary_bytes_used;
+  return result;
+}
+
 class SumUsedClosure: public HeapRegionClosure {
   size_t _used;
 public:
@@ -2349,7 +2354,7 @@
 void G1CollectedHeap::print_on(outputStream* st, bool extended) const {
   st->print(" %-20s", "garbage-first heap");
   st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
-            capacity()/K, used()/K);
+            capacity()/K, used_unlocked()/K);
   st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
             _g1_storage.low_boundary(),
             _g1_storage.high(),
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Tue Jul 14 15:40:39 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jul 15 12:22:59 2009 -0400
@@ -700,6 +700,9 @@
   size_t g1_reserved_obj_bytes() { return _g1_reserved.byte_size(); }
   virtual size_t capacity() const;
   virtual size_t used() const;
+  // This should be called when we're not holding the heap lock. The
+  // result might be a bit inaccurate.
+  size_t used_unlocked() const;
   size_t recalculate_used() const;
 #ifndef PRODUCT
   size_t recalculate_used_regions() const;