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 @@ -128,9 +128,9 @@ public HeapImpl(int pageSize) {
this.gcImpl = new GCImpl();
this.runtimeCodeInfoGcSupport = new RuntimeCodeInfoGCSupportImpl();
HeapParameters.initialize();
DiagnosticThunkRegistry.singleton().register(new DumpHeapSettingsAndStatistics());
DiagnosticThunkRegistry.singleton().register(new DumpHeapUsage());
DiagnosticThunkRegistry.singleton().register(new DumpChunkInformation());
DiagnosticThunkRegistry.singleton().add(new DumpHeapSettingsAndStatistics());
DiagnosticThunkRegistry.singleton().add(new DumpHeapUsage());
DiagnosticThunkRegistry.singleton().add(new DumpChunkInformation());
}

@Fold
Expand Down Expand Up @@ -647,7 +647,7 @@ public boolean printLocationInfo(Log log, UnsignedWord value, boolean allowJavaH
if (printLocationInfo(log, ptr, allowJavaHeapAccess, allowUnsafeOperations)) {
if (allowJavaHeapAccess && objectHeaderImpl.pointsToObjectHeader(ptr)) {
log.indent(true);
SubstrateDiagnostics.printObjectInfo(log, ptr);
SubstrateDiagnostics.printObjectInfo(log, ptr.toObject());
log.redent(false);
}
return true;
Expand Down Expand Up @@ -875,6 +875,8 @@ public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLev
log.string("Heap base: ").zhex(KnownIntrinsics.heapBase()).newline();
}
log.string("Object reference size: ").signed(ConfigurationValues.getObjectLayout().getReferenceSize()).newline();
log.string("Reserved object header bits: 0b").number(Heap.getHeap().getObjectHeader().getReservedBitsMask(), 2, false).newline();

log.string("Aligned chunk size: ").unsigned(HeapParameters.getAlignedHeapChunkSize()).newline();
log.string("Large array threshold: ").unsigned(HeapParameters.getLargeArrayThreshold()).newline();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ public boolean walkObjects(ObjectVisitor visitor) {
}

public void logUsage(Log log, boolean logIfEmpty) {
UnsignedWord chunkBytes = getChunkBytes();
UnsignedWord chunkBytes;
if (isEdenSpace() && !VMOperation.isGCInProgress()) {
chunkBytes = HeapImpl.getAccounting().getEdenUsedBytes();
} else {
chunkBytes = getChunkBytes();
}

if (logIfEmpty || chunkBytes.aboveThan(0)) {
log.string(getName()).string(": ").rational(chunkBytes, GCImpl.M, 2).string("M (")
.rational(accounting.getAlignedChunkBytes(), GCImpl.M, 2).string("M in ").signed(accounting.getAlignedChunkCount()).string(" aligned chunks, ")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core.posix.linux;

import org.graalvm.compiler.core.common.NumUtil;
import org.graalvm.nativeimage.StackValue;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.word.Pointer;
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.SubstrateDiagnostics;
import com.oracle.svm.core.SubstrateDiagnostics.DiagnosticThunkRegistry;
import com.oracle.svm.core.SubstrateDiagnostics.ErrorContext;
import com.oracle.svm.core.c.CGlobalData;
import com.oracle.svm.core.c.CGlobalDataFactory;
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.heap.RestrictHeapAccess;
import com.oracle.svm.core.log.Log;
import com.oracle.svm.core.os.RawFileOperationSupport;

class DumpLinuxOSInfo extends SubstrateDiagnostics.DiagnosticThunk {
private static final CGlobalData<CCharPointer> MAX_THREADS_PATH = CGlobalDataFactory.createCString("/proc/sys/kernel/threads-max");
private static final CGlobalData<CCharPointer> MAX_MAPPINGS_PATH = CGlobalDataFactory.createCString("/proc/sys/vm/max_map_count");
private static final CGlobalData<CCharPointer> MAX_PID_PATH = CGlobalDataFactory.createCString("/proc/sys/kernel/pid_max");

@Override
public int maxInvocationCount() {
return 1;
}

@Override
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while printing diagnostics.")
public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLevel, int invocationCount) {
log.string("OS information:").indent(true);

log.string("Max threads: ");
printFirstLine(log, MAX_THREADS_PATH.get());
log.newline();

log.string("Max memory mappings: ");
printFirstLine(log, MAX_MAPPINGS_PATH.get());
log.newline();

log.string("Max PID: ");
printFirstLine(log, MAX_PID_PATH.get());
log.newline();

log.indent(false);
}

private static void printFirstLine(Log log, CCharPointer filename) {
RawFileOperationSupport fs = RawFileOperationSupport.nativeByteOrder();
RawFileOperationSupport.RawFileDescriptor fd = fs.open(filename, RawFileOperationSupport.FileAccessMode.READ);
if (!fs.isValid(fd)) {
log.string("unknown");
return;
}

try {
int bufferSize = 64;
CCharPointer buffer = StackValue.get(bufferSize);
long readBytes = fs.read(fd, (Pointer) buffer, WordFactory.unsigned(bufferSize));
int length = countLineBytes(buffer, NumUtil.safeToInt(readBytes));
log.string(buffer, length);
} finally {
fs.close(fd);
}
}

private static int countLineBytes(CCharPointer buffer, int len) {
for (int i = 0; i < len; i++) {
if (buffer.read(i) == '\n') {
return i;
}
}
return len;
}
}

@AutomaticallyRegisteredFeature
class DumpLinuxOSInfoFeature implements InternalFeature {
@Override
public void afterRegistration(AfterRegistrationAccess access) {
DiagnosticThunkRegistry.singleton().addAfter(new DumpLinuxOSInfo(), SubstrateDiagnostics.DumpMachineInfo.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public static void printHub(@SuppressWarnings("unused") IsolateThread thread, Po
@CEntryPoint(name = "svm_dbg_print_obj", include = IncludeDebugHelperMethods.class, publishAs = Publish.SymbolOnly)
@CEntryPointOptions(prologue = SetThreadAndHeapBasePrologue.class, epilogue = NoEpilogue.class)
public static void printObject(@SuppressWarnings("unused") IsolateThread thread, Pointer objPtr) {
SubstrateDiagnostics.printObjectInfo(Log.log(), objPtr);
SubstrateDiagnostics.printObjectInfo(Log.log(), objPtr.toObject());
Log.log().newline();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.core;

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

import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
import com.oracle.svm.core.util.VMError;

@AutomaticallyRegisteredImageSingleton
public class Processor {
private int lastQueriedActiveProcessorCount = -1;

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

public int getActiveProcessorCount() {
VMError.guarantee(!SubstrateUtil.HOSTED, "must not be executed during the image build");

int result = getActiveProcessorCount0();
lastQueriedActiveProcessorCount = result;
return result;
}

private static int getActiveProcessorCount0() {
int optionValue = SubstrateOptions.ActiveProcessorCount.getValue();
if (optionValue > 0) {
return optionValue;
}

if (SubstrateOptions.MultiThreaded.getValue()) {
return Containers.activeProcessorCount();
} else {
return 1;
}
}

public int getLastQueriedActiveProcessorCount() {
return lastQueriedActiveProcessorCount;
}
}
Loading