Skip to content

[Backport] [GR-60550] Fixed BuildPhaseProvider methods and VM diagnostics registration. #94

@bulasevich

Description

@bulasevich

What would you like to backport?

Need to backport:

Merge issues:

  • minor merge conflict: additonal if on master [1]
  • change to sources [2] added on master only
  • usage of ImageHeapList API [3] added on master only. Replacement with ArrayList gives graal build fail [4]
[1]
commit 5fc41633e35c45edbcb0d083fcd37b1c43b948b2
Author: Christian Haeubl <[email protected]>
Date:   Fri Jan 19 19:00:46 2024 +0100
    Simplify thread detach and isolate teardown.
    Execute teardown hooks during shutdown.
    Fix another thread handle leak on Windows.
b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java
-            thunks.add(new DumpCounters());
+            if (CounterSupport.isEnabled()) {
+                thunks.add(new DumpCounters());
+            }

[2]
commit b26c9d237b984efe51327981a41bb0cfd78883be
Author: Christian Haeubl <[email protected]>
Date:   Mon Oct 2 15:41:40 2023 +0200
    Improve crash log output.
-        public synchronized void register(DiagnosticThunk diagnosticThunk) {
+        public synchronized void add(DiagnosticThunk thunk) {

+        @Platforms(Platform.HOSTED_ONLY.class)
+        public synchronized void addAfter(DiagnosticThunk thunk, Class<? extends DiagnosticThunk> before) {
+            int insertPos = indexOf(before) + 1;
+
+            DiagnosticThunk[] newThunks = new DiagnosticThunk[diagnosticThunks.length + 1];
+            System.arraycopy(diagnosticThunks, 0, newThunks, 0, insertPos);
+            newThunks[insertPos] = thunk;
+            System.arraycopy(diagnosticThunks, insertPos, newThunks, insertPos + 1, diagnosticThunks.length - insertPos);
+            diagnosticThunks = newThunks;
+
+            initialInvocationCount = Arrays.copyOf(initialInvocationCount, initialInvocationCount.length + 1);
+            initialInvocationCount[initialInvocationCount.length - 1] = 1;
+        }
+
+        @Platforms(Platform.HOSTED_ONLY.class)
+        private int indexOf(Class<? extends DiagnosticThunk> clazz) {
+            for (int i = 0; i < diagnosticThunks.length; i++) {
+                if (diagnosticThunks[i].getClass() == clazz) {
+                    return i;
+                }
+            }
+            throw VMError.shouldNotReachHere("Could not find diagnostic thunk " + clazz);
+        }
+

[3]
commit 3994e9b5d323e3cf908ba5f8cc1564d508c2591f
Author: Christian Wimmer <[email protected]>
Date:   Mon Jan 8 16:23:13 2024 -0800
    Introduce ImageHeapList
	

[4]
Error: @RestrictHeapAccess warning: Restricted method: 'VMErrorSubstitutions.shutdown(CodePointer, String, Throwable)' calls 'Preconditions.outOfBoundsCheckIndex(BiFunction, int, int)' that violates restriction NO_ALLOCATION.
  [Path:
    com.oracle.svm.core.jdk.VMErrorSubstitutions.shutdown(VMErrorSubstitutions.java:148)
    com.oracle.svm.core.jdk.VMErrorSubstitutions.doShutdown(VMErrorSubstitutions.java:171)
    com.oracle.svm.core.SubstrateDiagnostics.printFatalError(SubstrateDiagnostics.java:297)
    com.oracle.svm.core.SubstrateDiagnostics.printFatalErrorForCurrentState(SubstrateDiagnostics.java:321)
    com.oracle.svm.core.SubstrateDiagnostics$DiagnosticThunkRegistry.getThunk(SubstrateDiagnostics.java:1296)
    java.util.ArrayList.get(ArrayList.java:427)
    jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
    jdk.internal.util.Preconditions.outOfBoundsCheckIndex(BiFunction, int, int)]

Describe the motivation for the backport.

This is a part of

Metadata

Metadata

Assignees

No one assigned

    Labels

    backportBackport or backport requestoracle-graalvm-23.1.7Backported to Oracle GraalVM for JDK 21.0.7 (23.1.7)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions