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 @@ -112,8 +112,6 @@ public class AddressRangeCommittedMemoryProvider extends ChunkBasedCommittedMemo
"Consider increasing the address space size (see option -XX:ReservedAddressSpaceSize).");
private static final OutOfMemoryError UNALIGNED_OUT_OF_ADDRESS_SPACE = new OutOfMemoryError("Could not allocate an unaligned heap chunk because the heap address space is exhausted. " +
"Consider increasing the address space size (see option -XX:ReservedAddressSpaceSize).");
private static final OutOfMemoryError ALIGNED_COMMIT_FAILED = new OutOfMemoryError("Could not commit the memory for an aligned heap chunk, OS may be out of memory.");
private static final OutOfMemoryError UNALIGNED_COMMIT_FAILED = new OutOfMemoryError("Could not commit the memory for an unaligned heap chunk, OS may be out of memory.");

/**
* This mutex is used by the GC and the application. The application may hold this mutex only in
Expand Down Expand Up @@ -347,7 +345,7 @@ protected OutOfMemoryError reportAlignedChunkAllocationFailed(int error) {
if (error == OUT_OF_ADDRESS_SPACE) {
throw OutOfMemoryUtil.reportOutOfMemoryError(ALIGNED_OUT_OF_ADDRESS_SPACE);
} else if (error == COMMIT_FAILED) {
throw OutOfMemoryUtil.reportOutOfMemoryError(ALIGNED_COMMIT_FAILED);
throw OutOfMemoryUtil.reportOutOfMemoryError(ALIGNED_CHUNK_COMMIT_FAILED);
} else {
throw VMError.shouldNotReachHereAtRuntime();
}
Expand All @@ -372,7 +370,7 @@ protected OutOfMemoryError reportUnalignedChunkAllocationFailed(int error) {
if (error == OUT_OF_ADDRESS_SPACE) {
throw OutOfMemoryUtil.reportOutOfMemoryError(UNALIGNED_OUT_OF_ADDRESS_SPACE);
} else if (error == COMMIT_FAILED) {
throw OutOfMemoryUtil.reportOutOfMemoryError(UNALIGNED_COMMIT_FAILED);
throw OutOfMemoryUtil.reportOutOfMemoryError(UNALIGNED_CHUNK_COMMIT_FAILED);
} else {
throw VMError.shouldNotReachHereAtRuntime();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.graalvm.nativeimage.c.struct.RawStructure;
import org.graalvm.nativeimage.c.struct.SizeOf;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.impl.ImageSingletonsSupport;
import org.graalvm.word.Pointer;
import org.graalvm.word.PointerBase;
import org.graalvm.word.UnsignedWord;
Expand Down Expand Up @@ -175,7 +176,7 @@ public static void printObjectInfo(Log log, Object obj) {
log.string(obj.getClass().getName());

if (obj instanceof String s) {
log.string(": ").string(s, 60);
log.string(": \"").string(s, 60).string("\"");
} else {
int layoutEncoding = DynamicHub.fromClass(obj.getClass()).getLayoutEncoding();

Expand Down Expand Up @@ -1306,12 +1307,14 @@ public static synchronized DiagnosticThunkRegistry singleton() {

@Platforms(Platform.HOSTED_ONLY.class)
public synchronized void add(DiagnosticThunk thunk) {
assert !BuildPhaseProvider.isAnalysisStarted();
thunks.add(thunk);
resizeInitialInvocationCount();
}

@Platforms(Platform.HOSTED_ONLY.class)
public synchronized void add(int insertPos, DiagnosticThunk... extraThunks) {
assert !BuildPhaseProvider.isAnalysisStarted();
for (int i = 0; i < extraThunks.length; i++) {
thunks.add(insertPos + i, extraThunks[i]);
}
Expand All @@ -1320,6 +1323,7 @@ public synchronized void add(int insertPos, DiagnosticThunk... extraThunks) {

@Platforms(Platform.HOSTED_ONLY.class)
public synchronized void addAfter(DiagnosticThunk thunk, Class<? extends DiagnosticThunk> before) {
assert !BuildPhaseProvider.isAnalysisStarted();
int insertPos = indexOf(before) + 1;
assert insertPos > 0;
thunks.add(insertPos, thunk);
Expand Down Expand Up @@ -1370,13 +1374,13 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o

/*
* Copy the value to a field in the image heap so that it is safe to access. During
* image build, it can happen that the singleton does not exist yet. In that case,
* the value will be copied to the image heap when executing the constructor of the
* singleton. This is a bit cumbersome but necessary because we can't use a static
* field. We also need to mark the option as used at run-time (see feature) as the
* static analysis would otherwise remove the option from the image.
* the image build, it can happen that the singleton does not exist yet. In that
* case, the value will be copied to the image heap when executing the constructor
* of the singleton. This is a bit cumbersome but necessary because we can't use a
* static field. We also need to mark the option as used at run-time (see feature)
* as the static analysis would otherwise remove the option from the image.
*/
if (ImageSingletons.contains(Options.class)) {
if (wasConstructorExecuted()) {
Options.singleton().loopOnFatalError = newValue;
}
}
Expand All @@ -1389,7 +1393,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
super.onValueUpdate(values, oldValue, newValue);

/* See comment above. */
if (ImageSingletons.contains(Options.class)) {
if (wasConstructorExecuted()) {
Options.singleton().implicitExceptionWithoutStacktraceIsFatal = newValue;
}
}
Expand Down Expand Up @@ -1417,6 +1421,10 @@ public static boolean shouldLoopOnFatalError() {
public static boolean implicitExceptionWithoutStacktraceIsFatal() {
return singleton().implicitExceptionWithoutStacktraceIsFatal;
}

private static boolean wasConstructorExecuted() {
return (!SubstrateUtil.HOSTED || ImageSingletonsSupport.isInstalled()) && ImageSingletons.contains(Options.class);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public static void updateMaxJavaStackTraceDepth(EconomicMap<OptionKey<?>, Object
}

/* Same option name and specification as the Java HotSpot VM. */
@Option(help = "Maximum total size of NIO direct-buffer allocations")//
@Option(help = "Maximum total size of NIO direct-buffer allocations", type = OptionType.Expert)//
public static final RuntimeOptionKey<Long> MaxDirectMemorySize = new RuntimeOptionKey<>(0L);

@Option(help = "Verify naming conventions during image construction.")//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.oracle.svm.core.jdk.JDKUtils;
import com.oracle.svm.core.log.Log;
import com.oracle.svm.core.stack.StackOverflowCheck;
import com.oracle.svm.core.thread.VMOperation;
import com.oracle.svm.core.util.VMError;

/**
Expand Down Expand Up @@ -62,6 +63,11 @@ public static OutOfMemoryError reportOutOfMemoryError(OutOfMemoryError error) {

@Uninterruptible(reason = "Not uninterruptible but it doesn't matter for the callers.", calleeMustBe = false)
private static void reportOutOfMemoryError0(OutOfMemoryError error) {
if (VMOperation.isGCInProgress()) {
/* If a GC is in progress, then we can't execute the more complex logic below. */
return;
}

if (VMInspectionOptions.hasHeapDumpSupport() && SubstrateOptions.HeapDumpOnOutOfMemoryError.getValue()) {
HeapDumping.singleton().dumpHeapOnOutOfMemoryError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.config.ConfigurationValues;
import com.oracle.svm.core.heap.OutOfMemoryUtil;
import com.oracle.svm.core.heap.RestrictHeapAccess;
import com.oracle.svm.core.nmt.NmtCategory;
import com.oracle.svm.core.thread.VMOperation;
Expand All @@ -41,9 +42,9 @@
import jdk.graal.compiler.word.Word;

public abstract class ChunkBasedCommittedMemoryProvider extends AbstractCommittedMemoryProvider {
private static final OutOfMemoryError ALIGNED_OUT_OF_MEMORY_ERROR = new OutOfMemoryError("Could not allocate an aligned heap chunk. " +
protected static final OutOfMemoryError ALIGNED_CHUNK_COMMIT_FAILED = new OutOfMemoryError("Could not commit an aligned heap chunk. " +
"Either the OS/container is out of memory or another system-level resource limit was reached (such as the number of memory mappings).");
private static final OutOfMemoryError UNALIGNED_OUT_OF_MEMORY_ERROR = new OutOfMemoryError("Could not allocate an unaligned heap chunk. " +
protected static final OutOfMemoryError UNALIGNED_CHUNK_COMMIT_FAILED = new OutOfMemoryError("Could not commit an unaligned heap chunk. " +
"Either the OS/container is out of memory or another system-level resource limit was reached (such as the number of memory mappings).");

@Fold
Expand All @@ -56,7 +57,7 @@ public static ChunkBasedCommittedMemoryProvider get() {
public Pointer allocateAlignedChunk(UnsignedWord nbytes, UnsignedWord alignment) {
Pointer result = allocate(nbytes, alignment, false, NmtCategory.JavaHeap);
if (result.isNull()) {
throw ALIGNED_OUT_OF_MEMORY_ERROR;
throw OutOfMemoryUtil.reportOutOfMemoryError(ALIGNED_CHUNK_COMMIT_FAILED);
}
return result;
}
Expand All @@ -66,7 +67,7 @@ public Pointer allocateAlignedChunk(UnsignedWord nbytes, UnsignedWord alignment)
public Pointer allocateUnalignedChunk(UnsignedWord nbytes) {
Pointer result = allocate(nbytes, getAlignmentForUnalignedChunks(), false, NmtCategory.JavaHeap);
if (result.isNull()) {
throw UNALIGNED_OUT_OF_MEMORY_ERROR;
throw OutOfMemoryUtil.reportOutOfMemoryError(UNALIGNED_CHUNK_COMMIT_FAILED);
}
return result;
}
Expand Down
Loading