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
2 changes: 1 addition & 1 deletion substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-36568) Add "Quick build" mode, enabled through option `-Ob`, for quicker native image builds.
* (GR-35898) Improved handling of static synchronized methods: the lock is no longer stored in the secondary monitor map, but in the mutable DynamicHubCompanion object.
* Remove support for JDK8. As a result, `JDK8OrEarlier` and `JDK11OrLater` have been deprecated and will be removed in a future release.
* (GR-26814) (GR-37018) (GR-37038) Red Hat added support for the following JFR events: `SafepointBegin`, `SafepointEnd`, `GarbageCollection`, `GCPhasePause`, and `GCPhasePauseLevel*`. All GC-related JFR events are currently limited to the serial GC.
* (GR-26814) (GR-37018) (GR-37038) (GR-37311) Red Hat added support for the following JFR events: `SafepointBegin`, `SafepointEnd`, `GarbageCollection`, `GCPhasePause`, `GCPhasePauseLevel*`, and `ExecuteVMOperation`. All GC-related JFR events are currently limited to the serial GC.
* (GR-35721) Deprecate `-H:±BuildOutputUseNewStyle` option. The old build output style will be removed in a future release.
* (GR-36905) Allow incomplete classes at build-time is now default. Add --link-at-build-time option and @<prop-values-file> support for native-image.properties. Add --link-at-build-time-paths option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import java.lang.ref.Reference;

import com.oracle.svm.core.heap.VMOperationInfos;
import com.oracle.svm.core.jfr.JfrTicks;
import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.nativeimage.CurrentIsolate;
Expand Down Expand Up @@ -1228,7 +1229,7 @@ private CollectionInProgressError() {

private static class CollectionVMOperation extends NativeVMOperation {
CollectionVMOperation() {
super("Garbage collection", SystemEffect.SAFEPOINT);
super(VMOperationInfos.get(CollectionVMOperation.class, "Garbage collection", SystemEffect.SAFEPOINT));
}

@Override
Expand Down Expand Up @@ -1369,7 +1370,9 @@ private void printGCSummary() {
log.string(prefix).string("MaximumHeapSize: ").unsigned(getPolicy().getMaximumHeapSize()).newline();
log.string(prefix).string("AlignedChunkSize: ").unsigned(HeapParameters.getAlignedHeapChunkSize()).newline();

JavaVMOperation.enqueueBlockingSafepoint("PrintGCSummaryShutdownHook", ThreadLocalAllocation::disableAndFlushForAllThreads);
FlushTLABsOperation vmOp = new FlushTLABsOperation();
vmOp.enqueue();

HeapImpl heap = HeapImpl.getHeapImpl();
Space edenSpace = heap.getYoungGeneration().getEden();
UnsignedWord youngChunkBytes = edenSpace.getChunkBytes();
Expand Down Expand Up @@ -1398,4 +1401,15 @@ private void printGCSummary() {
log.string(prefix).string("TotalNanos: ").signed(totalNanos).newline();
log.string(prefix).string("GCLoadPercent: ").signed(roundedGCLoad).newline();
}

private static class FlushTLABsOperation extends JavaVMOperation {
protected FlushTLABsOperation() {
super(VMOperationInfos.get(FlushTLABsOperation.class, "Flush TLABs", SystemEffect.SAFEPOINT));
}

@Override
protected void operate() {
ThreadLocalAllocation.disableAndFlushForAllThreads();
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.util.ArrayList;

import com.oracle.svm.core.heap.VMOperationInfos;
import org.graalvm.compiler.word.Word;
import org.graalvm.nativeimage.CurrentIsolate;
import org.graalvm.nativeimage.IsolateThread;
Expand Down Expand Up @@ -529,7 +530,7 @@ private static final class FindPathToObjectOperation extends JavaVMOperation {
private final PathEdge result;

FindPathToObjectOperation(PathExhibitor exhibitor, Object object, PathEdge result) {
super("FindPathToObjectOperation", SystemEffect.SAFEPOINT);
super(VMOperationInfos.get(FindPathToObjectOperation.class, "Find path to object", SystemEffect.SAFEPOINT));
this.exhibitor = exhibitor;
this.object = object;
this.result = result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package com.oracle.svm.core;

import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.word.PointerBase;
import org.graalvm.word.UnsignedWord;

Expand All @@ -33,19 +32,7 @@
import com.oracle.svm.core.heap.ObjectVisitor;

/** A walker over different kinds of allocated memory. */
public abstract class MemoryWalker {

/** Get the implementation of the MemoryWalker. */
public static MemoryWalker getMemoryWalker() {
return ImageSingletons.lookup(MemoryWalker.class);
}

/**
* Walk memory applying the visitor. Returns true if all visits returned true, else false when
* any visit returns false.
*/
public abstract boolean visitMemory(Visitor visitor);

public final class MemoryWalker {
public interface ImageHeapRegionVisitor {
/** Visit a region from the native image heap. */
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while visiting memory.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.deopt.DeoptimizationSupport;
import com.oracle.svm.core.heap.VMOperationInfos;
import com.oracle.svm.core.jdk.RuntimeSupport;
import com.oracle.svm.core.log.Log;
import com.oracle.svm.core.stack.JavaStackWalker;
Expand Down Expand Up @@ -103,7 +104,17 @@ static void install() {

@Override
public void handle(Signal arg0) {
JavaVMOperation.enqueueBlockingSafepoint("DumpAllStacks", () -> {
DumpAllStacksOperation vmOp = new DumpAllStacksOperation();
vmOp.enqueue();
}

private static class DumpAllStacksOperation extends JavaVMOperation {
DumpAllStacksOperation() {
super(VMOperationInfos.get(DumpAllStacksOperation.class, "Dump all stacks", SystemEffect.SAFEPOINT));
}

@Override
protected void operate() {
Log log = Log.log();
log.string("Full thread dump:").newline().newline();
for (IsolateThread vmThread = VMThreads.firstThread(); vmThread.isNonNull(); vmThread = VMThreads.nextThread(vmThread)) {
Expand All @@ -119,29 +130,29 @@ public void handle(Signal arg0) {
}
}
log.flush();
});
}
}

private static void dumpStack(Log log, IsolateThread vmThread) {
Thread javaThread = PlatformThreads.fromVMThread(vmThread);
if (javaThread != null) {
log.character('"').string(javaThread.getName()).character('"');
log.string(" #").signed(javaThread.getId());
if (javaThread.isDaemon()) {
log.string(" daemon");
private static void dumpStack(Log log, IsolateThread vmThread) {
Thread javaThread = PlatformThreads.fromVMThread(vmThread);
if (javaThread != null) {
log.character('"').string(javaThread.getName()).character('"');
log.string(" #").signed(javaThread.getId());
if (javaThread.isDaemon()) {
log.string(" daemon");
}
} else {
log.string("(no Java thread)");
}
} else {
log.string("(no Java thread)");
}
log.string(" tid=0x").zhex(vmThread.rawValue());
if (javaThread != null) {
log.string(" state=").string(javaThread.getState().name());
}
log.newline();
log.string(" tid=0x").zhex(vmThread.rawValue());
if (javaThread != null) {
log.string(" state=").string(javaThread.getState().name());
}
log.newline();

log.indent(true);
JavaStackWalker.walkThread(vmThread, StackFramePrintVisitor.SINGLETON, log);
log.indent(false);
log.indent(true);
JavaStackWalker.walkThread(vmThread, StackFramePrintVisitor.SINGLETON, log);
log.indent(false);
}
}
}

Expand Down Expand Up @@ -172,10 +183,20 @@ static void install() {

@Override
public void handle(Signal arg0) {
JavaVMOperation.enqueueBlockingSafepoint("DumpRuntimeCompilation", () -> {
DumpRuntimeCompiledMethodsOperation vmOp = new DumpRuntimeCompiledMethodsOperation();
vmOp.enqueue();
}

private static class DumpRuntimeCompiledMethodsOperation extends JavaVMOperation {
DumpRuntimeCompiledMethodsOperation() {
super(VMOperationInfos.get(DumpRuntimeCompiledMethodsOperation.class, "Dump runtime compiled methods", SystemEffect.SAFEPOINT));
}

@Override
protected void operate() {
Log log = Log.log();
SubstrateDiagnostics.dumpRuntimeCompilation(log);
log.flush();
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.deopt.SubstrateInstalledCode;
import com.oracle.svm.core.heap.VMOperationInfos;
import com.oracle.svm.core.meta.SharedMethod;
import com.oracle.svm.core.thread.JavaVMOperation;

Expand Down Expand Up @@ -62,21 +63,10 @@ protected static void doInstallPrepared(SharedMethod method, CodeInfo codeInfo,
}

protected static void doInstallPreparedAndTethered(SharedMethod method, CodeInfo codeInfo, SubstrateInstalledCode installedCode) {
Throwable[] errorBox = {null};
JavaVMOperation.enqueueBlockingSafepoint("Install code", () -> {
try {
assert !installedCode.isValid() && !installedCode.isAlive();
CodePointer codeStart = CodeInfoAccess.getCodeStart(codeInfo);
installedCode.setAddress(codeStart.rawValue(), method);

CodeInfoTable.getRuntimeCodeCache().addMethod(codeInfo);
platformHelper().performCodeSynchronization(codeInfo);
} catch (Throwable e) {
errorBox[0] = e;
}
});
if (errorBox[0] != null) {
throw rethrow(errorBox[0]);
InstallCodeOperation vmOp = new InstallCodeOperation(method, codeInfo, installedCode);
vmOp.enqueue();
if (vmOp.error != null) {
throw rethrow(vmOp.error);
}
}

Expand All @@ -89,6 +79,34 @@ protected static RuntimeCodeInstallerPlatformHelper platformHelper() {
return ImageSingletons.lookup(RuntimeCodeInstallerPlatformHelper.class);
}

private static class InstallCodeOperation extends JavaVMOperation {
private final SharedMethod method;
private final CodeInfo codeInfo;
private final SubstrateInstalledCode installedCode;
private Throwable error;

InstallCodeOperation(SharedMethod method, CodeInfo codeInfo, SubstrateInstalledCode installedCode) {
super(VMOperationInfos.get(InstallCodeOperation.class, "Install code", SystemEffect.SAFEPOINT));
this.method = method;
this.codeInfo = codeInfo;
this.installedCode = installedCode;
}

@Override
protected void operate() {
try {
assert !installedCode.isValid() && !installedCode.isAlive();
CodePointer codeStart = CodeInfoAccess.getCodeStart(codeInfo);
installedCode.setAddress(codeStart.rawValue(), method);

CodeInfoTable.getRuntimeCodeCache().addMethod(codeInfo);
platformHelper().performCodeSynchronization(codeInfo);
} catch (Throwable e) {
error = e;
}
}
}

/** Methods which are platform specific. */
public interface RuntimeCodeInstallerPlatformHelper {

Expand Down
Loading