Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public UnsignedWord getMaximumYoungGenerationSize() {
public UnsignedWord getCurrentHeapCapacity() {
assert VMOperation.isGCInProgress() : "use only during GC";
guaranteeSizeParametersInitialized();
return edenSize.add(survivorSize.multiply(2)).add(oldSize);
return edenSize.add(survivorSize).add(oldSize);
}

@Override
Expand All @@ -229,6 +229,19 @@ public UnsignedWord getSurvivorSpacesCapacity() {
return survivorSize;
}

@Override
@Uninterruptible(reason = "Ensure reading a consistent value.")
public UnsignedWord getYoungGenerationCapacity() {
guaranteeSizeParametersInitialized();
return edenSize.add(survivorSize);
}

@Override
public UnsignedWord getOldGenerationCapacity() {
guaranteeSizeParametersInitialized();
return oldSize;
}

@Override
public UnsignedWord getMaximumFreeAlignedChunksSize() {
assert VMOperation.isGCInProgress() : "use only during GC";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ public UnsignedWord getSurvivorSpacesCapacity() {
return WordFactory.zero();
}

@Override
public UnsignedWord getYoungGenerationCapacity() {
return getMaximumYoungGenerationSize();
}

@Override
public UnsignedWord getOldGenerationCapacity() {
UnsignedWord heapCapacity = getCurrentHeapCapacity();
UnsignedWord youngCapacity = getYoungGenerationCapacity();
if (youngCapacity.aboveThan(heapCapacity)) {
return WordFactory.zero(); // should never happen unless options change in between
}
return heapCapacity.subtract(youngCapacity);
}

@Override
public final UnsignedWord getMaximumFreeAlignedChunksSize() {
return getMaximumYoungGenerationSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
*/
UnsignedWord getSurvivorSpacesCapacity();

/** The capacity of the young generation, comprising the eden and survivor spaces. */
UnsignedWord getYoungGenerationCapacity();

/** The capacity of the old generation. */
UnsignedWord getOldGenerationCapacity();

/**
* The maximum number of bytes that should be kept readily available for allocation or copying
* during collections.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.genscavenge.CollectionPolicy;
import com.oracle.svm.core.genscavenge.GCAccounting;
import com.oracle.svm.core.genscavenge.GCImpl;
import com.oracle.svm.core.genscavenge.HeapAccounting;
Expand Down Expand Up @@ -94,24 +95,26 @@ public void allocate() {
public void update() {
GCAccounting accounting = GCImpl.getGCImpl().getAccounting();
HeapAccounting heapAccounting = HeapImpl.getHeapImpl().getAccounting();
CollectionPolicy policy = GCImpl.getPolicy();
policy.ensureSizeParametersInitialized();

long maxNewSize = GCImpl.getPolicy().getMaximumYoungGenerationSize().rawValue();
long maxNewSize = policy.getMaximumYoungGenerationSize().rawValue();
youngCollector.invocations.setValue(accounting.getIncrementalCollectionCount());
youngCollector.time.setValue(accounting.getIncrementalCollectionTotalNanos());

youngGen.capacity.setValue(heapAccounting.getYoungUsedBytes().rawValue());
youngGen.capacity.setValue(policy.getYoungGenerationCapacity().rawValue());
youngGen.maxCapacity.setValue(maxNewSize);

youngGen.spaces[0].used.setValue(heapAccounting.getEdenUsedBytes().rawValue());
for (int i = 1; i < youngGen.spaces.length; i++) {
youngGen.spaces[i].used.setValue(heapAccounting.getSurvivorSpaceAfterChunkBytes(i - 1).rawValue());
}

long maxOldSize = GCImpl.getPolicy().getMaximumHeapSize().rawValue() - maxNewSize;
long maxOldSize = policy.getMaximumHeapSize().rawValue() - maxNewSize;
oldCollector.invocations.setValue(accounting.getCompleteCollectionCount());
oldCollector.time.setValue(accounting.getCompleteCollectionTotalNanos());

oldGen.capacity.setValue(accounting.getOldGenerationAfterChunkBytes().rawValue());
oldGen.capacity.setValue(policy.getOldGenerationCapacity().rawValue());
oldGen.maxCapacity.setValue(maxOldSize);

oldGen.spaces[0].used.setValue(accounting.getOldGenerationAfterChunkBytes().rawValue());
Expand Down