Skip to content

Commit

Permalink
[GR-52941] GC-related cleanups.
Browse files Browse the repository at this point in the history
PullRequest: graal/17377
  • Loading branch information
christianhaeubl committed Mar 27, 2024
2 parents 5e43646 + 9d5c3bf commit e9daa58
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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.os.CommittedMemoryProvider;
import com.oracle.svm.core.util.PointerUtils;

import jdk.graal.compiler.api.directives.GraalDirectives;
Expand Down Expand Up @@ -121,7 +120,7 @@ public static AlignedHeader getEnclosingChunk(Object obj) {
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static AlignedHeader getEnclosingChunkFromObjectPointer(Pointer ptr) {
if (!GraalDirectives.inIntrinsic()) {
assert !HeapImpl.getHeapImpl().isInImageHeap(ptr) || CommittedMemoryProvider.get().guaranteesHeapPreferredAddressSpaceAlignment() : "can't be used because the image heap is unaligned";
assert HeapImpl.isImageHeapAligned() || !HeapImpl.getHeapImpl().isInImageHeap(ptr) : "can't be used because the image heap is unaligned";
}
return (AlignedHeader) PointerUtils.roundDown(ptr, HeapParameters.getAlignedHeapChunkAlignment());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import com.oracle.svm.core.nodes.CFunctionEpilogueNode;
import com.oracle.svm.core.nodes.CFunctionPrologueNode;
import com.oracle.svm.core.option.RuntimeOptionKey;
import com.oracle.svm.core.os.CommittedMemoryProvider;
import com.oracle.svm.core.snippets.KnownIntrinsics;
import com.oracle.svm.core.thread.PlatformThreads;
import com.oracle.svm.core.thread.ThreadStatus;
Expand Down Expand Up @@ -407,9 +406,9 @@ public static boolean usesImageHeapCardMarking() {
if (enabled == Boolean.FALSE || enabled == null && !SubstrateOptions.useRememberedSet()) {
return false;
} else if (enabled == null) {
return CommittedMemoryProvider.get().guaranteesHeapPreferredAddressSpaceAlignment();
return isImageHeapAligned();
}
UserError.guarantee(CommittedMemoryProvider.get().guaranteesHeapPreferredAddressSpaceAlignment(),
UserError.guarantee(isImageHeapAligned(),
"Enabling option %s requires a custom image heap alignment at runtime, which cannot be ensured with the current configuration (option %s might be disabled)",
SerialGCOptions.ImageHeapCardMarking, SubstrateOptions.SpawnIsolates);
return true;
Expand All @@ -424,7 +423,7 @@ public int getPreferredAddressSpaceAlignment() {
@Fold
@Override
public int getImageHeapOffsetInAddressSpace() {
if (SubstrateOptions.SpawnIsolates.getValue() && SubstrateOptions.UseNullRegion.getValue() && CommittedMemoryProvider.get().guaranteesHeapPreferredAddressSpaceAlignment()) {
if (SubstrateOptions.SpawnIsolates.getValue() && SubstrateOptions.UseNullRegion.getValue()) {
/*
* The image heap will be mapped in a way that there is a memory protected gap between
* the heap base and the start of the image heap. The gap won't need any memory in the
Expand All @@ -435,6 +434,11 @@ public int getImageHeapOffsetInAddressSpace() {
return 0;
}

@Fold
public static boolean isImageHeapAligned() {
return SubstrateOptions.SpawnIsolates.getValue();
}

@Override
public boolean walkImageHeapObjects(ObjectVisitor visitor) {
VMOperation.guaranteeInProgressAtSafepoint("Must only be called at a safepoint");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.oracle.svm.core.hub.DynamicHub;
import com.oracle.svm.core.hub.InteriorObjRefWalker;
import com.oracle.svm.core.log.Log;
import com.oracle.svm.core.os.CommittedMemoryProvider;
import com.oracle.svm.core.snippets.KnownIntrinsics;

import jdk.graal.compiler.word.Word;
Expand Down Expand Up @@ -265,7 +264,7 @@ private static boolean verifyObject(Object obj, AlignedHeader aChunk, UnalignedH

assert aChunk.isNonNull() ^ uChunk.isNonNull();
HeapChunk.Header<?> chunk = aChunk.isNonNull() ? aChunk : uChunk;
if (CommittedMemoryProvider.get().guaranteesHeapPreferredAddressSpaceAlignment()) {
if (HeapImpl.isImageHeapAligned() || !HeapImpl.getHeapImpl().isInImageHeap(obj)) {
HeapChunk.Header<?> enclosingHeapChunk = HeapChunk.getEnclosingHeapChunk(obj);
if (chunk.notEqual(enclosingHeapChunk)) {
Log.log().string("Object ").zhex(ptr).string(" should have ").zhex(chunk).string(" as its enclosing chunk but getEnclosingHeapChunk returned ").zhex(enclosingHeapChunk).newline();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.oracle.svm.core.config.ConfigurationValues;
import com.oracle.svm.core.genscavenge.remset.RememberedSet;
import com.oracle.svm.core.heap.ObjectVisitor;
import com.oracle.svm.core.os.CommittedMemoryProvider;
import com.oracle.svm.core.util.UnsignedUtils;

import jdk.graal.compiler.api.directives.GraalDirectives;
Expand Down Expand Up @@ -131,7 +130,7 @@ public static UnalignedHeader getEnclosingChunk(Object obj) {
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
static UnalignedHeader getEnclosingChunkFromObjectPointer(Pointer ptr) {
if (!GraalDirectives.inIntrinsic()) {
assert !HeapImpl.getHeapImpl().isInImageHeap(ptr) || CommittedMemoryProvider.get().guaranteesHeapPreferredAddressSpaceAlignment() : "can't be used because the image heap is unaligned";
assert HeapImpl.isImageHeapAligned() || !HeapImpl.getHeapImpl().isInImageHeap(ptr) : "can't be used for the image heap because the image heap is not aligned to the chunk size";
}
Pointer chunkPointer = ptr.subtract(getObjectStartOffset());
return (UnalignedHeader) chunkPointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public class LinuxImageHeapProvider extends AbstractImageHeapProvider {

private static final int MAX_PATHLEN = 4096;

@Override
public boolean guaranteesHeapPreferredAddressSpaceAlignment() {
return true;
}

@Override
@Uninterruptible(reason = "Called during isolate initialization.")
public int initialize(Pointer reservedAddressSpace, UnsignedWord reservedSize, WordPointer basePointer, WordPointer endPointer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.oracle.svm.core.identityhashcode.IdentityHashCodeSupport;
import com.oracle.svm.core.log.Log;
import com.oracle.svm.core.option.RuntimeOptionKey;
import com.oracle.svm.core.os.CommittedMemoryProvider;

import jdk.graal.compiler.api.replacements.Fold;

Expand Down Expand Up @@ -137,11 +136,7 @@ public void visitLoadedClasses(Consumer<Class<?>> visitor) {
/** Reset the heap to the normal execution state. */
public abstract void endSafepoint();

/**
* Returns a multiple to which the heap address space should be aligned to at runtime.
*
* @see CommittedMemoryProvider#guaranteesHeapPreferredAddressSpaceAlignment()
*/
/** Returns a multiple to which the heap address space should be aligned to at runtime. */
@Fold
public abstract int getPreferredAddressSpaceAlignment();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@
import jdk.graal.compiler.api.replacements.Fold;

public abstract class AbstractCommittedMemoryProvider implements CommittedMemoryProvider {
@Fold
@Override
public boolean guaranteesHeapPreferredAddressSpaceAlignment() {
return SubstrateOptions.SpawnIsolates.getValue() && ImageHeapProvider.get().guaranteesHeapPreferredAddressSpaceAlignment();
}

@Uninterruptible(reason = "Still being initialized.")
protected static int protectSingleIsolateImageHeap() {
assert !SubstrateOptions.SpawnIsolates.getValue() : "Must be handled by ImageHeapProvider when SpawnIsolates is enabled";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
import com.oracle.svm.core.util.UnsignedUtils;

public abstract class AbstractCopyingImageHeapProvider extends AbstractImageHeapProvider {
@Override
public boolean guaranteesHeapPreferredAddressSpaceAlignment() {
return true;
}

@Override
@Uninterruptible(reason = "Called during isolate initialization.")
public int initialize(Pointer reservedAddressSpace, UnsignedWord reservedSize, WordPointer basePointer, WordPointer endPointer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.c.function.CEntryPointCreateIsolateParameters;
import com.oracle.svm.core.heap.Heap;

import jdk.graal.compiler.api.replacements.Fold;

Expand All @@ -46,14 +45,6 @@ static CommittedMemoryProvider get() {
return ImageSingletons.lookup(CommittedMemoryProvider.class);
}

/**
* Returns whether this provider will always guarantee a heap address space alignment of
* {@link Heap#getPreferredAddressSpaceAlignment()} at image runtime, which may also depend on
* {@link ImageHeapProvider#guaranteesHeapPreferredAddressSpaceAlignment()}.
*/
@Fold
boolean guaranteesHeapPreferredAddressSpaceAlignment();

/**
* Performs initializations <em>for the current isolate</em>, before any other methods of this
* interface may be called.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ static ImageHeapProvider get() {
return ImageSingletons.lookup(ImageHeapProvider.class);
}

/**
* Returns whether this provider, when not already supplied a reserved address space by
* {@link CommittedMemoryProvider}, will always ensure a heap address space alignment of
* {@link Heap#getPreferredAddressSpaceAlignment()} at image runtime.
*/
@Fold
boolean guaranteesHeapPreferredAddressSpaceAlignment();

/**
* Creates a new instance of the image heap.
*
Expand Down

0 comments on commit e9daa58

Please sign in to comment.