Skip to content

Commit f4e32cd

Browse files
Cleanups.
1 parent 19e0880 commit f4e32cd

File tree

6 files changed

+32
-48
lines changed

6 files changed

+32
-48
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import org.graalvm.compiler.api.replacements.Fold;
3030
import org.graalvm.compiler.core.common.NumUtil;
31-
import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess;
3231
import org.graalvm.nativeimage.CurrentIsolate;
3332
import org.graalvm.nativeimage.ImageSingletons;
3433
import org.graalvm.nativeimage.IsolateThread;
@@ -142,8 +141,9 @@ private static void printDiagnosticsForCurrentState() {
142141

143142
Log log = state.log;
144143
if (state.diagnosticThunkIndex > 0) {
145-
log.newline();
146-
log.string("An error occurred while printing diagnostics. The remaining part of this section will be skipped.").resetIndentation().newline();
144+
// An error must have happened earlier as the code for printing diagnostics was invoked
145+
// recursively.
146+
log.resetIndentation();
147147
}
148148

149149
// Print the various sections of the diagnostics and skip all sections that were already
@@ -154,9 +154,7 @@ private static void printDiagnosticsForCurrentState() {
154154
while (++state.invocationCount <= thunk.maxInvocations()) {
155155
try {
156156
thunk.printDiagnostics(log, state.invocationCount);
157-
// TEMP (chaeubl): check the max retries
158-
log.signed(GraalUnsafeAccess.getUnsafe().getInt(27L));
159-
continue;
157+
break;
160158
} catch (Throwable e) {
161159
dumpException(log, thunk, e);
162160
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoAccess.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,4 +374,24 @@ private static CodeInfoImpl cast(UntetheredCodeInfo info) {
374374
assert isValid(info);
375375
return (CodeInfoImpl) info;
376376
}
377+
378+
public static void printCodeInfo(Log log, CodeInfo info, boolean allowJavaHeapAccess) {
379+
String name = allowJavaHeapAccess ? CodeInfoAccess.getName(info) : null;
380+
printCodeInfo(log, info, CodeInfoAccess.getState(info), name, CodeInfoAccess.getCodeStart(info), CodeInfoAccess.getCodeEnd(info));
381+
}
382+
383+
public static void printCodeInfo(Log log, UntetheredCodeInfo codeInfo, int state, String name, CodePointer codeStart, CodePointer codeEnd) {
384+
log.string("CodeInfo (").zhex(codeInfo).string(" - ").zhex(((UnsignedWord) codeInfo).add(RuntimeCodeInfoAccess.getSizeOfCodeInfo()).subtract(1)).string("), ")
385+
.string(CodeInfoAccess.stateToString(state));
386+
if (name != null) {
387+
log.string(" - ").string(name);
388+
}
389+
log.string(", ip: (").zhex(codeStart).string(" - ").zhex(codeEnd).string(")");
390+
log.newline();
391+
/*
392+
* Note that we are not trying to output the InstalledCode object. It is not a pinned
393+
* object, so when log printing (for, e.g., a fatal error) occurs during a GC, then the VM
394+
* could segfault.
395+
*/
396+
}
377397
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoHistory.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.graalvm.nativeimage.Platform;
3030
import org.graalvm.nativeimage.Platforms;
3131
import org.graalvm.nativeimage.c.function.CodePointer;
32-
import org.graalvm.word.UnsignedWord;
3332

3433
import com.oracle.svm.core.heap.Heap;
3534
import com.oracle.svm.core.log.Log;
@@ -82,31 +81,10 @@ public void logFree(CodeInfo info) {
8281
private static void traceCodeCache(String kind, CodeInfo info, boolean allowJavaHeapAccess) {
8382
if (RuntimeCodeCache.Options.TraceCodeCache.getValue()) {
8483
Log.log().string(kind).string(" method: ");
85-
printCodeInfo(Log.log(), info, allowJavaHeapAccess);
84+
CodeInfoAccess.printCodeInfo(Log.log(), info, allowJavaHeapAccess);
8685
}
8786
}
8887

89-
private static void printCodeInfo(Log log, CodeInfo info, boolean allowJavaHeapAccess) {
90-
String name = allowJavaHeapAccess ? CodeInfoAccess.getName(info) : null;
91-
printCodeInfo(log, info, CodeInfoAccess.getState(info), name, CodeInfoAccess.getCodeStart(info), CodeInfoAccess.getCodeEnd(info));
92-
}
93-
94-
// TEMP (chaeubl): move this somewhere else...
95-
static void printCodeInfo(Log log, UntetheredCodeInfo codeInfo, int state, String name, CodePointer codeStart, CodePointer codeEnd) {
96-
log.string("CodeInfo (").zhex(codeInfo).string(" - ").zhex(((UnsignedWord) codeInfo).add(RuntimeCodeInfoAccess.getSizeOfCodeInfo()).subtract(1)).string("), ")
97-
.string(CodeInfoAccess.stateToString(state));
98-
if (name != null) {
99-
log.string(" - ").string(name);
100-
}
101-
log.string(", ip: (").zhex(codeStart).string(" - ").zhex(codeEnd).string(")");
102-
log.newline();
103-
/*
104-
* Note that we are not trying to output the InstalledCode object. It is not a pinned
105-
* object, so when log printing (for, e.g., a fatal error) occurs during a GC, then the VM
106-
* could segfault.
107-
*/
108-
}
109-
11088
public void printRecentOperations(Log log, boolean allowJavaHeapAccess) {
11189
log.string("The ").signed(recentOperations.size()).string(" most recent RuntimeCodeInfo operations (oldest first): ").indent(true);
11290
recentOperations.foreach(log, allowJavaHeapAccess ? PRINT_WITH_JAVA_HEAP_DATA : PRINT_WITHOUT_JAVA_HEAP_DATA);
@@ -154,7 +132,7 @@ public void print(Log log, boolean allowJavaHeapAccess) {
154132
if (kind != null) {
155133
log.unsigned(timestamp).string(" - ").string(kind).spaces(1);
156134
String name = allowJavaHeapAccess ? codeName : null;
157-
printCodeInfo(log, codeInfo, codeInfoState, name, codeStart, codeEnd);
135+
CodeInfoAccess.printCodeInfo(log, codeInfo, codeInfoState, name, codeStart, codeEnd);
158136
}
159137
}
160138
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoMemory.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.concurrent.locks.ReentrantLock;
2828

2929
import org.graalvm.compiler.api.replacements.Fold;
30-
import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess;
3130
import org.graalvm.nativeimage.ImageSingletons;
3231
import org.graalvm.nativeimage.Platform;
3332
import org.graalvm.nativeimage.Platforms;
@@ -43,7 +42,6 @@
4342
import com.oracle.svm.core.code.RuntimeCodeCache.CodeInfoVisitor;
4443
import com.oracle.svm.core.heap.Heap;
4544
import com.oracle.svm.core.log.Log;
46-
import com.oracle.svm.core.thread.JavaVMOperation;
4745
import com.oracle.svm.core.thread.VMOperation;
4846
import com.oracle.svm.core.util.VMError;
4947

@@ -85,13 +83,6 @@ public void add(CodeInfo info) {
8583
lock.lock();
8684
try {
8785
add0(info);
88-
89-
// TEMP (chaeubl):
90-
if (count > 5) {
91-
JavaVMOperation.enqueueBlockingSafepoint("Temp", () -> {
92-
System.out.println(GraalUnsafeAccess.getUnsafe().getInt((long) (Math.random() * 100)));
93-
});
94-
}
9586
} finally {
9687
lock.unlock();
9788
}
@@ -284,7 +275,7 @@ private void printCodeInfo(Log log, int i, boolean allowJavaHeapAccess) {
284275

285276
@Uninterruptible(reason = "CodeInfo no longer needs to be protected from the GC.", calleeMustBe = false)
286277
private static void printCodeInfo0(Log log, UntetheredCodeInfo codeInfo, int state, String name, CodePointer codeStart, CodePointer codeEnd) {
287-
RuntimeCodeInfoHistory.printCodeInfo(log, codeInfo, state, name, codeStart, codeEnd);
278+
CodeInfoAccess.printCodeInfo(log, codeInfo, state, name, codeStart, codeEnd);
288279
}
289280

290281
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Heap.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ public List<Class<?>> getLoadedClasses() {
169169
public abstract boolean isInImageHeap(Object object);
170170

171171
/**
172-
* Returns true if the object at the given address is located in the image heap. This method
173-
* only works reliably for pointers that point to the start of an object.
172+
* Returns true if the object at the given address is located in the image heap. Depending on
173+
* the used GC, this method may only work reliably for pointers that point to the start of an
174+
* object.
174175
*/
175176
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
176177
public abstract boolean isInImageHeap(Pointer objectPtr);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/VMLockSupport.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@
3232
import com.oracle.svm.core.log.Log;
3333

3434
public abstract class VMLockSupport {
35-
public VMMutex[] getMutexes() {
36-
return null;
37-
}
35+
public abstract VMMutex[] getMutexes();
3836

39-
public VMCondition[] getConditions() {
40-
return null;
41-
}
37+
public abstract VMCondition[] getConditions();
4238

4339
public static class DumpVMMutexes extends DiagnosticThunk {
4440
@Override

0 commit comments

Comments
 (0)