Skip to content

Commit

Permalink
Print just the numberic compilation id or "n/a"; make the compilation…
Browse files Browse the repository at this point in the history
… id logging work for libgraal and isolated truffle compiler on SVM; add the compilation id also to the truffle compilation JFR logs.
  • Loading branch information
jchalou committed Jan 23, 2025
1 parent 2e5bc96 commit 29e3996
Show file tree
Hide file tree
Showing 26 changed files with 372 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public HotSpotGraalRuntimeProvider getGraalRuntime() {
* Implemented by
* {@code com.oracle.svm.graal.hotspot.libgraal.LibGraalEntryPoints#compileMethod}.
*/
public static native long compileMethodInLibgraal(long isolateThread,
public static native long compileMethodInLibgraal(long isolateThreadAddress,
long methodHandle,
boolean useProfilingInfo,
boolean installAsDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
package jdk.graal.compiler.hotspot.test;

import jdk.graal.compiler.hotspot.HotSpotGraalServices;
import org.junit.Assume;
import org.junit.Test;

import com.oracle.truffle.runtime.hotspot.libgraal.LibGraal;
import com.oracle.truffle.runtime.hotspot.libgraal.LibGraalScope;

import jdk.graal.compiler.hotspot.HotSpotGraalServices;
import jdk.vm.ci.meta.ResolvedJavaType;

/**
Expand Down Expand Up @@ -62,7 +62,7 @@ public class LibGraalCompilerTest extends HotSpotGraalCompilerTest {
* Implemented by
* {@code com.oracle.svm.graal.hotspot.libgraal.LibGraalEntryPoints#hashConstantOopFields}.
*
* @param isolateThread
* @param isolateThreadAddress
* @param typeHandle the type whose constant object fields are to be hashed
* @param useScope should a {@linkplain HotSpotGraalServices#openLocalCompilationContext(Object)
* scope} be used for each iteration. If true, then
Expand All @@ -71,7 +71,7 @@ public class LibGraalCompilerTest extends HotSpotGraalCompilerTest {
* @param iterations number of times to run the hashing loop
* @param oopsPerIteration number of oops to process per hashing loop
*/
public static native long hashConstantOopFields(long isolateThread,
public static native long hashConstantOopFields(long isolateThreadAddress,
long typeHandle,
boolean useScope,
int iterations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
import java.util.logging.LogRecord;
import java.util.regex.Pattern;

import com.oracle.truffle.api.test.SubprocessTestUtils;
import com.oracle.truffle.runtime.OptimizedCallTarget;

import jdk.graal.compiler.truffle.test.nodes.AbstractTestNode;
import jdk.graal.compiler.truffle.test.nodes.RootTestNode;
import jdk.graal.compiler.serviceprovider.GraalServices;
import org.graalvm.polyglot.Context;
import org.junit.Assert;
import org.junit.Test;
Expand All @@ -55,6 +49,12 @@
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.test.SubprocessTestUtils;
import com.oracle.truffle.runtime.OptimizedCallTarget;

import jdk.graal.compiler.serviceprovider.GraalServices;
import jdk.graal.compiler.truffle.test.nodes.AbstractTestNode;
import jdk.graal.compiler.truffle.test.nodes.RootTestNode;

public class TraceCompilationTest extends TestWithPolyglotOptions {

Expand Down Expand Up @@ -109,6 +109,14 @@ public void testCompilationFailureTracingDetails() throws Exception {
Arrays.asList("opt done"));
}

@Test
public void testCompilationId() throws Exception {
testHelper(() -> RootNode.createConstantNode(true),
Collections.singletonMap("engine.TraceCompilation", "true"),
Arrays.asList("CompId "),
Arrays.asList("CompId n/a"));
}

@Test
public void testExceptionFromPublish() throws Exception {
testHelper(
Expand Down Expand Up @@ -252,7 +260,7 @@ public synchronized void publish(LogRecord lr) {
Pattern p = it.next();
if (p.matcher(lr.getMessage()).matches()) {
it.remove();
return;
break;
}
}
for (Pattern p : unexpected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
*/
package jdk.graal.compiler.hotspot.libgraal.truffle;

import java.util.function.Supplier;

import com.oracle.truffle.compiler.TruffleCompilable;
import com.oracle.truffle.compiler.TruffleCompilerListener.CompilationResultInfo;
import com.oracle.truffle.compiler.TruffleCompilerListener.GraphInfo;
import com.oracle.truffle.compiler.TruffleCompilerOptionDescriptor;

import jdk.graal.compiler.hotspot.CompilationContext;
import jdk.graal.compiler.hotspot.HotSpotGraalServices;
import jdk.graal.compiler.truffle.TruffleCompilerOptions;
Expand All @@ -37,8 +40,6 @@
import jdk.vm.ci.hotspot.HotSpotVMConfigAccess;
import jdk.vm.ci.meta.ResolvedJavaMethod;

import java.util.function.Supplier;

/**
* Guest Graal entry points for Truffle to libgraal calls.
*/
Expand Down Expand Up @@ -126,6 +127,10 @@ public static String[] getNodeTypes(Object graphInfo, boolean simpleNames) {
return ((GraphInfo) graphInfo).getNodeTypes(simpleNames);
}

public static long getCompilationId(Object compilationResultInfo) {
return ((CompilationResultInfo) compilationResultInfo).getCompilationId();
}

public static int getTargetCodeSize(Object compilationResultInfo) {
return ((CompilationResultInfo) compilationResultInfo).getTargetCodeSize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@
*/
package jdk.graal.compiler.truffle;

import jdk.graal.compiler.core.common.CompilationIdentifier;

import com.oracle.truffle.compiler.TruffleCompilable;
import com.oracle.truffle.compiler.TruffleCompilationTask;

import jdk.graal.compiler.core.common.CompilationIdentifier;

public interface TruffleCompilationIdentifier extends CompilationIdentifier {

TruffleCompilationTask getTask();

TruffleCompilable getCompilable();

default long getTruffleCompilationId() {
return -1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ static class CompilationResultInfoImpl implements TruffleCompilerListener.Compil
}

@Override
public String getCompilationId() {
return compResult.getCompilationId().toString(CompilationIdentifier.Verbosity.ID);
public long getCompilationId() {
return ((TruffleCompilationIdentifier) compResult.getCompilationId()).getTruffleCompilationId();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
*/
package jdk.graal.compiler.truffle.hotspot;

import jdk.graal.compiler.hotspot.HotSpotCompilationIdentifier;
import jdk.graal.compiler.truffle.TruffleCompilationIdentifier;

import com.oracle.truffle.compiler.TruffleCompilable;
import com.oracle.truffle.compiler.TruffleCompilationTask;

import jdk.graal.compiler.hotspot.HotSpotCompilationIdentifier;
import jdk.graal.compiler.truffle.TruffleCompilationIdentifier;
import jdk.vm.ci.hotspot.HotSpotCompilationRequest;

/**
Expand Down Expand Up @@ -71,4 +70,8 @@ protected StringBuilder buildID(StringBuilder sb) {
return super.buildID(sb.append("Truffle"));
}

@Override
public long getTruffleCompilationId() {
return getRequest().getId();
}
}
1 change: 1 addition & 0 deletions sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
* The short description returned by `PolyglotException#toString` now starts with the qualified name of the metaobject of the guest exception, if the exception represents a guest exception that has a metaobject. Otherwise, it starts with the qualified name of the `PolyglotException` class.
* `PolyglotException#printStackTrace` now always starts with the string returned by `PolyglotException#toString()` like for regular Java Throwable objects.
* GR-54673 Added the option `engine.MaximumCompilations` to protect against too many repeated compilations of the same call target. The default value is `100`.
* GR-61448 Compilation id (`CompId`) was added to the `opt done` truffle compilation logs. This id matches the compilation id in the output of deoptimization, compilation and code cache logs on HotSpot and SubstrateVM.

## Version 24.2.0
* GR-54905 When using Truffle NFI with the Panama backend, native access must now be granted to the Truffle module instead of the NFI Panama module. Use the `--enable-native-access=org.graalvm.truffle` Java command line option to enable the native access for the NFI Panama backend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@

import jdk.graal.compiler.core.common.CompilationIdentifier;
import jdk.graal.compiler.debug.GraalError;

import jdk.vm.ci.meta.ResolvedJavaMethod;

public class SubstrateCompilationIdentifier implements CompilationIdentifier {

private static final AtomicLong uniqueIds = new AtomicLong();

private final long id;
protected final long id;
private final ResolvedJavaMethod method;

public SubstrateCompilationIdentifier(ResolvedJavaMethod method) {
Expand Down
Loading

0 comments on commit 29e3996

Please sign in to comment.