changeset 54991:d52887bc636f

8218733: SA: CollectedHeap provides broken implementation for used() and capacity() Reviewed-by: shade, jgeorge, eosterlund
author stefank
date Tue, 19 Feb 2019 10:02:00 +0100
parents 26a2eded80d9
children 935d31867930
files src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZCollectedHeap.java
diffstat 4 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java	Tue Feb 19 10:01:50 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java	Tue Feb 19 10:02:00 2019 +0100
@@ -66,6 +66,16 @@
     return CollectedHeapName.EPSILON;
   }
 
+  @Override
+  public long capacity() {
+    return space.capacity();
+  }
+
+  @Override
+  public long used() {
+    return space.used();
+  }
+
   public ContiguousSpace space() {
     return space;
   }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java	Tue Feb 19 10:01:50 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java	Tue Feb 19 10:02:00 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, 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
@@ -58,8 +58,8 @@
     return reservedRegion().start();
   }
 
-  public long capacity() { return 0; }
-  public long used()     { return 0; }
+  public abstract long capacity();
+  public abstract long used();
 
   public MemRegion reservedRegion() {
     return new MemRegion(addr.addOffsetTo(reservedFieldOffset));
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java	Tue Feb 19 10:01:50 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java	Tue Feb 19 10:02:00 2019 +0100
@@ -64,6 +64,11 @@
     }
 
     @Override
+    public long capacity() {
+        return numOfRegions() * ShenandoahHeapRegion.regionSizeBytes();
+    }
+
+    @Override
     public long used() {
         return used.getValue(addr);
     }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZCollectedHeap.java	Tue Feb 19 10:01:50 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZCollectedHeap.java	Tue Feb 19 10:02:00 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -70,6 +70,16 @@
         super(addr);
     }
 
+    @Override
+    public long capacity() {
+        return heap().capacity();
+    }
+
+    @Override
+    public long used() {
+        return heap().used();
+    }
+
     public OopHandle oop_load_at(OopHandle handle, long offset) {
         assert(!VM.getVM().isCompressedOopsEnabled());