Skip to content

Commit

Permalink
[GR-46717] Reset jdk.vm.ci.hotspot.Cleaner.queue to a new instance in…
Browse files Browse the repository at this point in the history
… libgraal.

PullRequest: graal/14884
  • Loading branch information
dougxc committed Jun 26, 2023
2 parents 9649b63 + d2f5280 commit 739ac10
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public static void check(Object obj, DisallowedObjectReporter reporter) {
// allowed unless the thread is mounted, in which case it references its carrier
// thread and fails
} else if (asThread.getState() != Thread.State.NEW && asThread.getState() != Thread.State.TERMINATED) {
throw reporter.raise("Detected a started Thread in the image heap. " +
"Threads running in the image generator are no longer running at image runtime.",
throw reporter.raise("Detected a started Thread in the image heap. Thread name: " + asThread.getName() +
". Threads running in the image generator are no longer running at image runtime.",
asThread, "Prevent threads from starting during image generation, or a started thread from being included in the image.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package com.oracle.svm.graal.hotspot.libgraal;

import java.lang.ref.ReferenceQueue;
import java.util.Map;

import com.oracle.svm.core.annotate.Alias;
Expand All @@ -40,7 +41,8 @@ public final class LibGraalSubstitutions {
@TargetClass(value = Services.class, onlyWith = LibGraalFeature.IsEnabled.class)
final class Target_jdk_vm_ci_services_Services {
// Checkstyle: stop
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true)//
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true)//
public static boolean IS_IN_NATIVE_IMAGE = true;
// Checkstyle: resume

Expand All @@ -49,13 +51,22 @@ final class Target_jdk_vm_ci_services_Services {
* requires a larger JVMCI change because the annotation is not visible in that project, so we
* use this substitution instead.
*/
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) //
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) //
private static Map<String, String> savedProperties;
}

@TargetClass(className = "jdk.vm.ci.hotspot.Cleaner", onlyWith = LibGraalFeature.IsEnabled.class)
final class Target_jdk_vm_ci_hotspot_Cleaner {
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, isFinal = true, declClass = ReferenceQueue.class)//
private static ReferenceQueue<Object> queue;
}

@TargetClass(className = "jdk.vm.ci.hotspot.HotSpotJDKReflection", onlyWith = LibGraalFeature.IsEnabled.class)
final class Target_jdk_vm_ci_hotspot_HotSpotJDKReflection {

@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.None)//
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.None)//
private long oopSizeOffset;
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public class GraalGraphObjectReplacer implements Function<Object, Object> {
private final Field substrateTypeRawAllInstanceFieldsField;
private final Field substrateMethodImplementationsField;

private final Class<?> jvmciCleanerClass = ReflectionUtil.lookupClass(false, "jdk.vm.ci.hotspot.Cleaner");

/**
* Tracks whether it is legal to create new types.
*/
Expand Down Expand Up @@ -160,7 +162,7 @@ public Object apply(Object source) {
HotSpotBackendFactory factory = (HotSpotBackendFactory) source;
Architecture hostArch = HotSpotJVMCIRuntime.runtime().getHostJVMCIBackend().getTarget().arch;
if (!factory.getArchitecture().equals(hostArch.getClass())) {
throw new UnsupportedFeatureException("Non-host archtecture HotSpotBackendFactory should not appear in the image: " + source);
throw new UnsupportedFeatureException("Non-host architecture HotSpotBackendFactory should not appear in the image: " + source);
}
} else if (source instanceof GraalRuntime) {
dest = sGraalRuntime;
Expand Down Expand Up @@ -201,7 +203,11 @@ public Object apply(Object source) {
}

assert dest != null;
String className = dest.getClass().getName();
Class<?> destClass = dest.getClass();
if (jvmciCleanerClass.isAssignableFrom(destClass)) {
throw new UnsupportedFeatureException(jvmciCleanerClass.getName() + " objects should not appear in the image: " + source);
}
String className = destClass.getName();
assert SubstrateUtil.isBuildingLibgraal() || !className.contains(".hotspot.") || className.contains(".svm.jtt.hotspot.") : "HotSpot object in image " + className;
assert !className.contains(".graal.reachability") : "Analysis meta object in image " + className;
assert !className.contains(".pointsto.meta.") : "Analysis meta object in image " + className;
Expand Down

0 comments on commit 739ac10

Please sign in to comment.