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 @@ -179,7 +179,7 @@ interface LINUX extends InternalPlatform.PLATFORM_JNI, InternalPlatform.NATIVE_O
* @since 21.0
*/
default String getOS() {
return LINUX.class.getSimpleName().toLowerCase();
return "linux";
}
}

Expand All @@ -196,7 +196,7 @@ interface ANDROID extends LINUX {
* @since 21.0
*/
default String getOS() {
return ANDROID.class.getSimpleName().toLowerCase();
return "android";
}
}

Expand All @@ -221,7 +221,7 @@ interface IOS extends DARWIN {
* @since 21.0
*/
default String getOS() {
return IOS.class.getSimpleName().toLowerCase();
return "ios";
}
}

Expand Down Expand Up @@ -255,7 +255,7 @@ interface WINDOWS extends InternalPlatform.PLATFORM_JNI, InternalPlatform.NATIVE
* @since 21.0
*/
default String getOS() {
return WINDOWS.class.getSimpleName().toLowerCase();
return "windows";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.graalvm.nativeimage.c.function.CEntryPoint.Publish;
import org.graalvm.nativeimage.c.function.CEntryPointLiteral;
import org.graalvm.nativeimage.c.struct.SizeOf;
import org.graalvm.nativeimage.c.type.VoidPointer;
import org.graalvm.word.PointerBase;
import org.graalvm.word.WordFactory;

Expand Down Expand Up @@ -77,7 +78,10 @@ protected void printSignalInfo(Log log, PointerBase signalInfo) {
if (sigInfo.si_errno() != 0) {
log.string(", si_errno: ").signed(sigInfo.si_errno());
}
log.string(", si_addr: ").zhex(sigInfo.si_addr());

VoidPointer addr = sigInfo.si_addr();
log.string(", si_addr: ");
printSegfaultAddressInfo(log, addr.rawValue());
log.newline();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ protected void printSignalInfo(Log log, PointerBase signalInfo) {
} else {
log.string(", ExceptionInformation=").zhex(operation);
}
log.string(" ").zhex(exInfo.addressOf(1).read());
log.string(" ");
printSegfaultAddressInfo(log, exInfo.addressOf(1).read());
} else {
if (numParameters > 0) {
log.string(", ExceptionInformation=");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@

import java.util.EnumSet;

import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.nativeimage.ImageSingletons;

import jdk.vm.ci.code.Architecture;

public interface CPUFeatureAccess {
@Fold
static CPUFeatureAccess singleton() {
return ImageSingletons.lookup(CPUFeatureAccess.class);
}

int verifyHostSupportsArchitectureEarly();

void verifyHostSupportsArchitectureEarlyOrExit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import com.oracle.svm.core.thread.PlatformThreads;
import com.oracle.svm.core.thread.ThreadListenerSupport;
import com.oracle.svm.core.thread.VMThreads;
import com.oracle.svm.core.util.Counter;
import com.oracle.svm.core.util.CounterSupport;
import com.oracle.svm.core.util.VMError;

@InternalVMMethod
Expand Down Expand Up @@ -206,7 +206,7 @@ private static void runShutdown0() {
*/
RuntimeSupport.getRuntimeSupport().shutdown();

Counter.logValues(Log.log());
CounterSupport.singleton().logValues(Log.log());
}

@Uninterruptible(reason = "Thread state not set up yet.")
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,9 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
}
};

@Option(help = "Specifies the number of entries that diagnostic buffers have.", type = OptionType.Debug)//
public static final HostedOptionKey<Integer> DiagnosticBufferSize = new HostedOptionKey<>(30);

@SuppressWarnings("unused")//
@APIOption(name = "configure-reflection-metadata")//
@Option(help = "Enable runtime instantiation of reflection objects for non-invoked methods.", type = OptionType.Expert, deprecated = true)//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ private static void dumpInterruptibly(PointerBase signalInfo, RegisterDumper.Con
logHandler.fatalError();
}

protected static void printSegfaultAddressInfo(Log log, long addr) {
log.zhex(addr);
if (addr != 0) {
long delta = addr - CurrentIsolate.getIsolate().rawValue();
String sign = (delta >= 0 ? "+" : "-");
log.string("(heapBase ").string(sign).signed(delta).string(")");
}
}

static class SingleIsolateSegfaultSetup implements IsolateListener {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public static void setEncodings(CodeInfo info, NonmovableObjectArray<Object> obj
}

public static Log log(CodeInfo info, Log log) {
return info.isNull() ? log.string("null") : log.string(CodeInfo.class.getName()).string("@").hex(info);
return info.isNull() ? log.string("null") : log.string("CodeInfo@").hex(info);
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ static CodeInfoDecoderCounters counters() {
/**
* This class can be used to iterate the Java-level stack trace information for a given
* instruction pointer (IP). A single physical stack frame may correspond to multiple Java-level
* stack frames.
* stack frames. Iteration starts in the deepest inlined method and ends at the compilation
* root.
*/
public static class FrameInfoCursor {
private final ReusableTypeReader frameInfoReader = new ReusableTypeReader();
Expand Down Expand Up @@ -550,6 +551,12 @@ public boolean advance() {
return result != null;
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public boolean hasCaller() {
assert result != null;
return !state.isDone;
}

/**
* Returns the information for the current frame.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,11 @@ private static FrameInfoQueryResult decodeUncompressedFrameInfo(boolean isDeoptE
FrameInfoQueryResult prev = null;
ValueInfo[][] virtualObjects = null;

while (true) {
while (!state.isDone) {
long start = readBuffer.getByteIndex();
int encodedBci = readBuffer.getSVInt();
if (encodedBci == NO_CALLER_BCI) {
state.isDone = true;
return result;
}

Expand Down Expand Up @@ -460,6 +461,8 @@ private static FrameInfoQueryResult decodeUncompressedFrameInfo(boolean isDeoptE

state.isFirstFrame = false;
}

return result;
}

@Uninterruptible(reason = "Some allocators are interruptible.", calleeMustBe = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,23 @@
*/
package com.oracle.svm.core.code;

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.code.CodeInfoAccess.HasInstalledCode;
import com.oracle.svm.core.deopt.SubstrateInstalledCode;
import com.oracle.svm.core.thread.Safepoint;
import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.nativeimage.c.function.CodePointer;
import org.graalvm.word.UnsignedWord;

import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.code.CodeInfoAccess.HasInstalledCode;
import com.oracle.svm.core.collections.RingBuffer;
import com.oracle.svm.core.deopt.SubstrateInstalledCode;
import com.oracle.svm.core.heap.Heap;
import com.oracle.svm.core.log.Log;
import com.oracle.svm.core.thread.Safepoint;
import com.oracle.svm.core.thread.VMOperation;
import com.oracle.svm.core.thread.VMThreads;
import com.oracle.svm.core.util.RingBuffer;
import org.graalvm.word.UnsignedWord;

public class RuntimeCodeInfoHistory {
private static final RingBuffer.Consumer<CodeCacheLogEntry> PRINT_WITH_JAVA_HEAP_DATA = RuntimeCodeInfoHistory::printEntryWithJavaHeapData;
Expand All @@ -49,7 +50,7 @@ public class RuntimeCodeInfoHistory {

@Platforms(Platform.HOSTED_ONLY.class)
RuntimeCodeInfoHistory() {
recentOperations = new RingBuffer<>(20, CodeCacheLogEntry::new);
recentOperations = new RingBuffer<>(SubstrateOptions.DiagnosticBufferSize.getValue(), CodeCacheLogEntry::new);
}

@Fold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.util;
package com.oracle.svm.core.collections;

import java.util.function.Supplier;

import com.oracle.svm.core.Uninterruptible;

/**
* Keeps the last-n entries and allows to read the out on demand..
*/
/** Keeps the last-n entries. */
public final class RingBuffer<T> {
private static final int DEFAULT_BUFFER_SIZE = 30;

private final T[] entries;
private int pos;
private boolean wrapped;
Expand All @@ -42,10 +38,6 @@ public interface Consumer<T> {
void accept(Object context, T t);
}

public RingBuffer() {
this(DEFAULT_BUFFER_SIZE);
}

@SuppressWarnings("unchecked")
public RingBuffer(int numEntries) {
this.entries = (T[]) new Object[numEntries];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.oracle.svm.core.code.FrameInfoQueryResult;
import com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo;
import com.oracle.svm.core.code.UntetheredCodeInfo;
import com.oracle.svm.core.collections.RingBuffer;
import com.oracle.svm.core.config.ConfigurationValues;
import com.oracle.svm.core.config.ObjectLayout;
import com.oracle.svm.core.deopt.DeoptimizedFrame.RelockObjectData;
Expand All @@ -82,7 +83,6 @@
import com.oracle.svm.core.thread.JavaVMOperation;
import com.oracle.svm.core.thread.VMOperation;
import com.oracle.svm.core.thread.VMThreads;
import com.oracle.svm.core.util.RingBuffer;
import com.oracle.svm.core.util.VMError;

import jdk.internal.misc.Unsafe;
Expand Down Expand Up @@ -149,7 +149,7 @@
*/
public final class Deoptimizer {
private static final int MAX_DEOPTIMIZATION_EVENT_PRINT_LENGTH = 1000;
private static final RingBuffer<char[]> recentDeoptimizationEvents = new RingBuffer<>();
private static final RingBuffer<char[]> recentDeoptimizationEvents = new RingBuffer<>(SubstrateOptions.DiagnosticBufferSize.getValue());

private static final int actionShift = 0;
private static final int actionBits = Integer.SIZE - Integer.numberOfLeadingZeros(DeoptimizationAction.values().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
import org.graalvm.nativeimage.hosted.RuntimeReflection;

import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.jdk.JNIRegistrationUtil;
import com.oracle.svm.core.jdk.RuntimeSupportFeature;
import com.oracle.svm.core.thread.ThreadListenerSupport;
import com.oracle.svm.core.thread.ThreadListenerSupportFeature;
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.util.ReflectionUtil;

/** See {@link ManagementSupport} for documentation. */
Expand All @@ -67,10 +67,13 @@ public List<Class<? extends Feature>> getRequiredFeatures() {

@Override
public void afterRegistration(AfterRegistrationAccess access) {
SubstrateRuntimeMXBean runtimeMXBean = new SubstrateRuntimeMXBean();
ImageSingletons.add(SubstrateRuntimeMXBean.class, runtimeMXBean);

SubstrateThreadMXBean threadMXBean = new SubstrateThreadMXBean();
ImageSingletons.add(SubstrateThreadMXBean.class, threadMXBean);

ManagementSupport managementSupport = new ManagementSupport(threadMXBean);
ManagementSupport managementSupport = new ManagementSupport(runtimeMXBean, threadMXBean);
ImageSingletons.add(ManagementSupport.class, managementSupport);
ThreadListenerSupport.get().register(managementSupport);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import javax.management.StandardEmitterMBean;
import javax.management.StandardMBean;

import jdk.management.jfr.FlightRecorderMXBean;
import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.IsolateThread;
Expand All @@ -54,15 +53,17 @@
import org.graalvm.nativeimage.impl.InternalPlatform;

import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jfr.HasJfrSupport;
import com.oracle.svm.core.thread.ThreadListener;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.core.jfr.HasJfrSupport;
import com.sun.jmx.mbeanserver.MXBeanLookup;

import jdk.management.jfr.FlightRecorderMXBean;

/**
* This class provides the SVM support implementation for the MXBean that provide VM introspection,
* which is accessible in the JDK via {@link ManagementFactory}. There are two mostly independent
Expand Down Expand Up @@ -118,7 +119,6 @@ public final class ManagementSupport implements ThreadListener {

private final SubstrateClassLoadingMXBean classLoadingMXBean;
private final SubstrateCompilationMXBean compilationMXBean;
private final SubstrateRuntimeMXBean runtimeMXBean;
private final SubstrateThreadMXBean threadMXBean;

/* Initialized lazily at run time. */
Expand All @@ -129,13 +129,12 @@ public final class ManagementSupport implements ThreadListener {
MBeanServer platformMBeanServer;

@Platforms(Platform.HOSTED_ONLY.class)
ManagementSupport(SubstrateThreadMXBean threadMXBean) {
ManagementSupport(SubstrateRuntimeMXBean runtimeMXBean, SubstrateThreadMXBean threadMXBean) {
platformManagedObjectsMap = new HashMap<>();
platformManagedObjectsSet = Collections.newSetFromMap(new IdentityHashMap<>());

classLoadingMXBean = new SubstrateClassLoadingMXBean();
compilationMXBean = new SubstrateCompilationMXBean();
runtimeMXBean = new SubstrateRuntimeMXBean();
this.threadMXBean = threadMXBean;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

import sun.management.Util;

final class SubstrateRuntimeMXBean implements RuntimeMXBean {
public final class SubstrateRuntimeMXBean implements RuntimeMXBean {

private final String managementSpecVersion;
private long startMillis;
Expand Down Expand Up @@ -153,7 +153,7 @@ public String getBootClassPath() {

@Override
public long getUptime() {
return System.currentTimeMillis() - startMillis;
return Math.max(0, System.currentTimeMillis() - startMillis);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLev
}

if (support == null || support.getMutexes() == null) {
log.string("No mutex information is available.");
log.string("No mutex information is available.").newline();
} else {
VMMutex[] mutexes = support.getMutexes();
for (int i = 0; i < mutexes.length; i++) {
Expand Down
Loading