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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
PRIMARY: "substratevm"
- env:
JDK_VERSION: "latest"
GATE_TAGS: "build,helloworld,native_unittests"
GATE_TAGS: "build,helloworld,native_unittests,standalone_pointsto_unittests"
PRIMARY: "substratevm"
PIP_PACKAGES: "jsonschema==4.6.1"
- os: ubuntu-24.04
Expand Down
2 changes: 1 addition & 1 deletion substratevm/ci/ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"style-fullbuild": mxgate("fullbuild,style,nativeimagehelp,check_libcontainer_annotations,check_libcontainer_namespace") + eclipse + jdt + spotbugs + maven + mx_build_exploded + gdb("14.2") + platform_spec(no_jobs) + platform_spec({
"linux:amd64:jdk-latest": tier1 + t("30:00"),
}),
"basics": mxgate("build,helloworld,native_unittests,truffle_unittests,debuginfotest,hellomodule,java_agent,condconfig") + maven + jsonschema + platform_spec(no_jobs) + platform_spec({
"basics": mxgate("build,helloworld,native_unittests,standalone_pointsto_unittests,truffle_unittests,debuginfotest,hellomodule,java_agent,condconfig") + maven + jsonschema + platform_spec(no_jobs) + platform_spec({
"linux:amd64:jdk-latest": tier2 + partial(2) + gdb("14.2") + t("40:00"),
"windows:amd64:jdk-latest": tier3 + t("1:30:00"),
}) + variants({
Expand Down
33 changes: 33 additions & 0 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def __getattr__(self, name):
GraalTags = Tags([
'helloworld',
'debuginfotest',
'standalone_pointsto_unittests',
'native_unittests',
'build',
'benchmarktest',
Expand Down Expand Up @@ -440,6 +441,16 @@ def svm_gate_body(args, tasks):
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
gdbdebughelperstest(['--output-path', svmbuild_dir()] + args.extra_image_builder_arguments)

with Task('standalone pointsto unittests', tasks, tags=[GraalTags.standalone_pointsto_unittests]) as t:
if t:
if '--static' in args.extra_image_builder_arguments:
mx.warn('Skipping standalone pointsto unittests if --static.')
elif mx.is_windows():
mx.warn('Skipping standalone pointsto unittests on Windows.')
else:
jvm_unittest(['--record-results', '--print-failed', 'failed.txt',
'--use-graalvm'] + args.extra_image_builder_arguments + ['com.oracle.graal.pointsto.standalone.test'])

with Task('native unittests', tasks, tags=[GraalTags.native_unittests]) as t:
if t:
with native_image_context(IMAGE_ASSERTION_FLAGS) as native_image:
Expand Down Expand Up @@ -2726,3 +2737,25 @@ def capnp_compile(args):
shaded = line.replace("org.capnproto", "com.oracle.svm.shaded.org.capnproto")
f.write(shaded)
f.write('}\n')

class StandalonePointstoUnittestsConfig(mx_unittest.MxUnittestConfig):

def __init__(self):
super(StandalonePointstoUnittestsConfig, self).__init__('standalone-pointsto-unittest')

def apply(self, config):
vmArgs, mainClass, mainClassArgs = config

vmArgs.extend(['--add-exports=jdk.graal.compiler/jdk.graal.compiler.options=ALL-UNNAMED'])

# JVMCI is dynamically exported to Graal when JVMCI is initialized. This is too late
# for the junit harness which uses reflection to find @Test methods. In addition, the
# tests widely use JVMCI classes so JVMCI needs to also export all its packages to
# ALL-UNNAMED.
mainClassArgs.extend(['-JUnitOpenPackages', 'jdk.internal.vm.ci/*=jdk.graal.compiler,ALL-UNNAMED'])
mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.nativeimage/*=ALL-UNNAMED'])

return (vmArgs, mainClass, mainClassArgs)


mx_unittest.register_unittest_config(StandalonePointstoUnittestsConfig())
1 change: 1 addition & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,7 @@
"dependencies" : [
"com.oracle.graal.pointsto.standalone.test",
],
"unittestConfig" : "standalone-pointsto-unittest",
"distDependencies": [
"mx:JUNIT_TOOL",
"sdk:NATIVEIMAGE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,5 @@ public static void main(String[] args) {

public void run() {
STATUS.compareAndSet(this, status, 1);
doSomething();
}

private void doSomething() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,95 +28,14 @@

import org.junit.Test;

/**
* This test shall fail because it makes the analysis code itself reachable if the classes are not
* separated by classloaders.
*
* The exception stack is:
*
* <pre>
* Exception:com.oracle.graal.pointsto.util.ParallelExecutionException
* at com.oracle.graal.pointsto.util.CompletionExecutor.complete(CompletionExecutor.java:261)
* at com.oracle.graal.pointsto.PointsToAnalysis.doTypeflow(PointsToAnalysis.java:528)
* at com.oracle.graal.pointsto.PointsToAnalysis.finish(PointsToAnalysis.java:516)
* at com.oracle.graal.pointsto.AbstractAnalysisEngine.runAnalysis(AbstractAnalysisEngine.java:161)
* at com.oracle.graal.pointsto.standalone.PointsToAnalyzer.run(PointsToAnalyzer.java:278)
* at com.oracle.graal.pointsto.standalone.test.PointstoAnalyzerTester.runAnalysisAndAssert(PointstoAnalyzerTester.java:159)
* at com.oracle.graal.pointsto.standalone.test.PointstoAnalyzerTester.runAnalysisAndAssert(PointstoAnalyzerTester.java:145)
* at com.oracle.graal.pointsto.standalone.test.StandaloneConstantScanDynamicTest.test(StandaloneConstantScanDynamicTest.java:43)
* at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
* at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
* at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
* at java.base/java.lang.reflect.Method.invoke(Method.java:568)
* at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
* at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
* at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
* at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
* at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
* at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
* at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
* at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
* at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
* at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
* at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
* at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
* at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
* at org.junit.runners.Suite.runChild(Suite.java:128)
* at org.junit.runners.Suite.runChild(Suite.java:27)
* at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
* at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
* at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
* at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
* at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
* at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
* at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
* at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
* at com.oracle.mxtool.junit.MxJUnitWrapper.runRequest(MxJUnitWrapper.java:375)
* at com.oracle.mxtool.junit.MxJUnitWrapper.main(MxJUnitWrapper.java:230)
* cause 0jdk.graal.compiler.debug.GraalError: jdk.graal.compiler.debug.GraalError: jdk.graal.compiler.debug.GraalError:
* should not reach here: Double wrapping of constant. Most likely, the reachability analysis code itself is seen as reachable. java.lang.Object[]
* at com.oracle.graal.pointsto.util.AnalysisFuture.setException(AnalysisFuture.java:49)
* at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:269)
* at com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
* at com.oracle.graal.pointsto.heap.ImageHeapObjectArray.readElementValue(ImageHeapObjectArray.java:84)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.onObjectReachable(ImageHeapScanner.java:463)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$markReachable$5(ImageHeapScanner.java:451)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$postTask$14(ImageHeapScanner.java:690)
* at com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
* at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
* at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
* at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
* at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
* at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
* at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
* at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
* Caused by: jdk.graal.compiler.debug.GraalError: jdk.graal.compiler.debug.GraalError: should not reach here: Double wrapping of constant. Most likely, the reachability analysis code itself is seen as reachable. java.lang.Object[]
* at com.oracle.graal.pointsto.util.AnalysisFuture.setException(AnalysisFuture.java:49)
* at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:269)
* at com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.getOrCreateImageHeapConstant(ImageHeapScanner.java:212)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.createImageHeapConstant(ImageHeapScanner.java:186)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$createImageHeapObjectArray$3(ImageHeapScanner.java:270)
* at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
* ... 13 more
* Caused by: jdk.graal.compiler.debug.GraalError: should not reach here: Double wrapping of constant. Most likely, the reachability analysis code itself is seen as reachable. java.lang.Object[]
* at jdk.graal.compiler/jdk.graal.compiler.debug.GraalError.shouldNotReachHere(GraalError.java:57)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.maybeReplace(ImageHeapScanner.java:307)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.createImageHeapObject(ImageHeapScanner.java:225)
* at com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$getOrCreateImageHeapConstant$2(ImageHeapScanner.java:205)
* at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
* ... 18 more
* </pre>
*/
public class StandaloneConstantScanDynamicTest {

@Test
public void test() throws NoSuchMethodException {
PointstoAnalyzerTester tester = new PointstoAnalyzerTester(StandaloneConstantScanDynamicCase.class);
tester.setAnalysisArguments(tester.getTestClassName(),
"-H:AnalysisTargetAppCP=" + tester.getTestClassJar());
tester.setExpectedReachableMethods(tester.getTestClass().getDeclaredMethod("run"),
tester.getTestClass().getDeclaredMethod("doSomething"));
tester.setExpectedReachableMethods(tester.getTestClass().getDeclaredMethod("run"));
tester.runAnalysisAndAssert();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

package com.oracle.graal.pointsto.standalone;

import static jdk.graal.compiler.replacements.StandardGraphBuilderPlugins.registerInvocationPlugins;

import java.io.File;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -56,6 +54,7 @@
import com.oracle.graal.pointsto.meta.HostedProviders;
import com.oracle.graal.pointsto.meta.PointsToAnalysisFactory;
import com.oracle.graal.pointsto.phases.NoClassInitializationPlugin;
import com.oracle.graal.pointsto.plugins.PointstoGraphBuilderPlugins;
import com.oracle.graal.pointsto.reports.AnalysisReporter;
import com.oracle.graal.pointsto.standalone.features.StandaloneAnalysisFeatureImpl;
import com.oracle.graal.pointsto.standalone.features.StandaloneAnalysisFeatureManager;
Expand Down Expand Up @@ -97,7 +96,6 @@ public final class PointsToAnalyzer {
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.text.spi");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.reflect.annotation");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.security.jca");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "jdk.jdeps", "com.sun.tools.classfile");
}

private final OptionValues options;
Expand Down Expand Up @@ -212,7 +210,9 @@ private PointsToAnalyzer(String mainEntryClass, OptionValues options) {
NoClassInitializationPlugin classInitializationPlugin = new NoClassInitializationPlugin();
plugins.setClassInitializationPlugin(classInitializationPlugin);
aProviders.setGraphBuilderPlugins(plugins);
registerInvocationPlugins(originalProviders.getSnippetReflection(), plugins.getInvocationPlugins(), false, true, false);
PointstoGraphBuilderPlugins.registerArrayPlugins(plugins.getInvocationPlugins());
PointstoGraphBuilderPlugins.registerSystemPlugins(plugins.getInvocationPlugins());
PointstoGraphBuilderPlugins.registerObjectPlugins(plugins.getInvocationPlugins());
}
}

Expand Down Expand Up @@ -286,6 +286,7 @@ public int run() {
try (Timer t = new Timer("analysis", analysisName)) {
StandaloneAnalysisFeatureImpl.DuringAnalysisAccessImpl config = new StandaloneAnalysisFeatureImpl.DuringAnalysisAccessImpl(standaloneAnalysisFeatureManager, analysisClassLoader, bigbang,
debugContext);
bigbang.getUniverse().setConcurrentAnalysisAccess(config);
bigbang.runAnalysis(debugContext, (analysisUniverse) -> {
bigbang.getHostVM().notifyClassReachabilityListener(analysisUniverse, config);
standaloneAnalysisFeatureManager.forEachFeature(feature -> feature.duringAnalysis(config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ protected void scanEmbeddedRoot(JavaConstant root, Object position) {
@Override
protected final void scanField(AnalysisField field, JavaConstant receiver, ScanReason prevReason) {
if (shouldScanField.test(field)) {
super.scanField(field, receiver, prevReason);
if (field.isStatic()) {
if (field.getDeclaringClass().isInitialized()) {
super.scanField(field, receiver, prevReason);
}
} else {
super.scanField(field, receiver, prevReason);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,26 @@ protected Class<?> getClass(String className) {

@Override
public ValueSupplier<JavaConstant> readHostedFieldValue(AnalysisField field, JavaConstant receiver) {
if (field.isStatic() && !field.getDeclaringClass().isInitialized()) {
return ValueSupplier.eagerValue(getConstantValue(field));
}
ValueSupplier<JavaConstant> ret = super.readHostedFieldValue(field, receiver);
if (ret.get() == null && field.isStatic()) {
ResolvedJavaField wrappedField = field.getWrapped();
JavaConstant constant = wrappedField.getConstantValue();
if (constant == null) {
constant = JavaConstant.defaultForKind(wrappedField.getJavaKind());
}
return ValueSupplier.eagerValue(constant);
return ValueSupplier.eagerValue(getConstantValue(field));
} else {
return ret;
}
}

private static JavaConstant getConstantValue(AnalysisField field) {
ResolvedJavaField wrappedField = field.getWrapped();
JavaConstant constant = wrappedField.getConstantValue();
if (constant == null) {
constant = JavaConstant.defaultForKind(wrappedField.getJavaKind());
}
return constant;
}

@Override
public void scanEmbeddedRoot(JavaConstant root, BytecodePosition position) {
if (shouldScanConstant.test(root)) {
Expand Down
Loading