8218733: SA: CollectedHeap provides broken implementation for used() and capacity()

Reviewed-by: shade, jgeorge, eosterlund
This commit is contained in:
Stefan Karlsson 2019-02-19 10:02:00 +01:00
parent ec54717960
commit 797122c227
4 changed files with 29 additions and 4 deletions

View File

@ -66,6 +66,16 @@ public class EpsilonHeap extends CollectedHeap {
return CollectedHeapName.EPSILON;
}
@Override
public long capacity() {
return space.capacity();
}
@Override
public long used() {
return space.used();
}
public ContiguousSpace space() {
return space;
}

View File

@ -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 @@ public abstract class CollectedHeap extends VMObject {
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));

View File

@ -63,6 +63,11 @@ public class ShenandoahHeap extends CollectedHeap {
return numRegions.getValue(addr);
}
@Override
public long capacity() {
return numOfRegions() * ShenandoahHeapRegion.regionSizeBytes();
}
@Override
public long used() {
return used.getValue(addr);

View File

@ -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 @@ public class ZCollectedHeap extends CollectedHeap {
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());