Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4ac1d2e
Introduce new compacting GC
Mar 9, 2023
624af25
Merge remote-tracking branch 'origin/master' into ca/compacting-gc
peter-hofer Apr 17, 2024
5419cea
Mend uninterruptible stack reference fixup.
peter-hofer Apr 15, 2024
68e7fa1
Move UseRememberedSet to SerialGCOptions.
peter-hofer Apr 15, 2024
ca79665
Abstract OldGeneration, reintroduce CopyingOldGeneration, reduce diff…
peter-hofer Apr 15, 2024
5468dd9
Refactor marking.
peter-hofer Apr 19, 2024
71d61a9
Refactor heap space classification.
peter-hofer Apr 22, 2024
e43052c
Use stack for depth-first marking in GC.
peter-hofer Mar 1, 2024
ab5ea70
Rename compacting old gen package.
peter-hofer Apr 24, 2024
f83ca9b
Revisit newly added files.
peter-hofer Apr 24, 2024
e145910
Avoid a second pass over pinned chunks to prepare sweeping.
peter-hofer Apr 26, 2024
43660c0
Iterate objects for updating references more efficiently.
peter-hofer Apr 29, 2024
89f71cd
Revisit how CompactingVisitor updates chunk top pointers.
peter-hofer Apr 29, 2024
c5c68c4
Store size of object sequences rather than preceding gaps.
peter-hofer Apr 30, 2024
9991e95
Revert GC policy changes (other than collecting the young gen separat…
peter-hofer Apr 30, 2024
0d692b0
Disable sweeping due to low fragmentation.
peter-hofer May 2, 2024
34f2556
Fix Epsilon GC when CompactingOldGen defaults to true.
peter-hofer May 3, 2024
4cb51af
Improvements and minor fixes.
peter-hofer May 7, 2024
8fe991b
Add changelog entry and default to -H:-CompactingOldGen.
peter-hofer May 15, 2024
42cd023
Merge remote-tracking branch 'origin/master' into ca/compacting-gc
peter-hofer May 23, 2024
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
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-43837) `--report-unsupported-elements-at-runtime` is now enabled by default and the option is deprecated.
* (GR-53359) Provide the `.debug_gdb_scripts` section that triggers auto-loading of `svmhelpers.py` in GDB. Remove single and double quotes from `ClassLoader.nameAndId` in the debuginfo.
* (GR-47365) Include dynamic proxy metadata in the reflection metadata with the syntax `"type": { "proxy": [<interface list>] }`. This allows members of proxy classes to be accessed reflectively. `proxy-config.json` is now deprecated but will still be honored.
* (GR-18214) In-place compacting garbage collection for the Serial GC old generation with `-H:+CompactingOldGen`.

## GraalVM for JDK 22 (Internal Version 24.0.0)
* (GR-48304) Red Hat added support for the JFR event ThreadAllocationStatistics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ public String getName() {
public boolean shouldCollectCompletely(boolean followingIncrementalCollection) { // should_{attempt_scavenge,full_GC}
guaranteeSizeParametersInitialized();

if (!followingIncrementalCollection && shouldCollectYoungGenSeparately(true)) {
if (!followingIncrementalCollection && shouldCollectYoungGenSeparately(!SerialGCOptions.useCompactingOldGen())) {
/*
* Default to always doing an incremental collection first because we expect most of the
* objects in the young generation to be garbage, and we can reuse their leftover chunks
* for copying the live objects in the old generation with fewer allocations.
* With a copying collector, default to always doing an incremental collection first
* because we expect most of the objects in the young generation to be garbage, and we
* can reuse their leftover chunks for copying the live objects in the old generation
* with fewer allocations. With a compacting collector, there is no benefit.
*/
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package com.oracle.svm.core.genscavenge;

import org.graalvm.nativeimage.c.struct.RawField;
import org.graalvm.nativeimage.c.struct.RawStructure;
import org.graalvm.word.Pointer;
import org.graalvm.word.UnsignedWord;
Expand All @@ -33,6 +34,7 @@
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.genscavenge.remset.RememberedSet;
import com.oracle.svm.core.heap.ObjectVisitor;
import com.oracle.svm.core.heap.RestrictHeapAccess;
import com.oracle.svm.core.util.PointerUtils;

import jdk.graal.compiler.api.directives.GraalDirectives;
Expand All @@ -50,17 +52,14 @@
* Most allocation within a AlignedHeapChunk is via fast-path allocation snippets, but a slow-path
* allocation method is available.
* <p>
* Objects in a AlignedHeapChunk have to be promoted by copying from their current HeapChunk to a
* destination HeapChunk.
* <p>
* An AlignedHeapChunk is laid out:
* An AlignedHeapChunk is laid out as follows:
*
* <pre>
* +===============+-------+--------+----------------------+
* | AlignedHeader | Card | First | Object ... |
* | Fields | Table | Object | |
* | | | Table | |
* +===============+-------+--------+----------------------+
* +===============+-------+--------+-----------------+-----------------+
* | AlignedHeader | Card | First | Initial Object | Object ... |
* | Fields | Table | Object | Move Info (only | |
* | | | Table | Compacting GC) | |
* +===============+-------+--------+-----------------+-----------------+
* </pre>
*
* The size of both the CardTable and the FirstObjectTable depends on the used {@link RememberedSet}
Expand All @@ -78,15 +77,22 @@ private AlignedHeapChunk() { // all static
*/
@RawStructure
public interface AlignedHeader extends HeapChunk.Header<AlignedHeader> {
@RawField
boolean getShouldSweepInsteadOfCompact();

@RawField
void setShouldSweepInsteadOfCompact(boolean value);
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static void initialize(AlignedHeader chunk, UnsignedWord chunkSize) {
assert chunkSize.equal(HeapParameters.getAlignedHeapChunkSize()) : "expecting all aligned chunks to be the same size";
HeapChunk.initialize(chunk, AlignedHeapChunk.getObjectsStart(chunk), chunkSize);
chunk.setShouldSweepInsteadOfCompact(false);
}

public static void reset(AlignedHeader chunk) {
HeapChunk.initialize(chunk, AlignedHeapChunk.getObjectsStart(chunk), HeapChunk.getEndOffset(chunk));
initialize(chunk, HeapChunk.getEndOffset(chunk));
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
Expand All @@ -98,6 +104,10 @@ public static Pointer getObjectsEnd(AlignedHeader that) {
return HeapChunk.getEndPointer(that);
}

public static boolean isEmpty(AlignedHeader that) {
return HeapChunk.getTopOffset(that).equal(getObjectsStartOffset());
}

/** Allocate uninitialized memory within this AlignedHeapChunk. */
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
static Pointer allocateMemory(AlignedHeader that, UnsignedWord size) {
Expand Down Expand Up @@ -146,4 +156,20 @@ static boolean walkObjectsFromInline(AlignedHeader that, Pointer start, ObjectVi
public static UnsignedWord getObjectsStartOffset() {
return RememberedSet.get().getHeaderSizeOfAlignedChunk();
}

@Fold
public static UnsignedWord getUsableSizeForObjects() {
return HeapParameters.getAlignedHeapChunkSize().subtract(getObjectsStartOffset());
}

public interface Visitor {
/**
* Visit an {@link AlignedHeapChunk}.
*
* @param chunk The {@link AlignedHeapChunk} to be visited.
* @return {@code true} if visiting should continue, {@code false} if visiting should stop.
*/
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while visiting the heap.")
boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public interface CollectionPolicy {
static String getInitialPolicyName() {
if (SubstrateOptions.UseEpsilonGC.getValue()) {
return "NeverCollect";
} else if (!SubstrateOptions.useRememberedSet()) {
} else if (!SerialGCOptions.useRememberedSet()) {
return "OnlyCompletely";
}
String name = SerialGCOptions.InitialCollectionPolicy.getValue();
Expand Down
Loading