Skip to content

Commit 0dfc6a5

Browse files
committed
improve intrinsification handling of layeredimagesingletons
1 parent 1c8e6d7 commit 0dfc6a5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/SubstrateGraphBuilderPlugins.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton;
9090
import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingletonBuilderFlags;
9191
import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingletonSupport;
92+
import com.oracle.svm.core.layeredimagesingleton.MultiLayeredImageSingleton;
9293
import com.oracle.svm.core.option.HostedOptionKey;
9394
import com.oracle.svm.core.snippets.KnownIntrinsics;
9495
import com.oracle.svm.core.util.UserError;
@@ -1125,6 +1126,18 @@ private static void registerVMConfigurationPlugins(InvocationPlugins plugins) {
11251126
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode classNode) {
11261127
Class<?> key = constantObjectParameter(b, targetMethod, 0, Class.class, classNode);
11271128
boolean result = ImageSingletons.contains(key);
1129+
if (!result && ImageLayerBuildingSupport.buildingImageLayer()) {
1130+
if (ApplicationLayerOnlyImageSingleton.class.isAssignableFrom(key) || MultiLayeredImageSingleton.class.isAssignableFrom(key)) {
1131+
/*
1132+
* ApplicationLayerOnlyImageSingletons and the array representation of a
1133+
* MultiLayeredImageSingleton will only be created in the final layer.
1134+
* However, we assume they exist in all layers. If lookup/getAllLayers is
1135+
* called on this key, then our infrastructure will ensure it is either
1136+
* created in the application layer or produce a buildtime error.
1137+
*/
1138+
result = true;
1139+
}
1140+
}
11281141
b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(result));
11291142
return true;
11301143
}

0 commit comments

Comments
 (0)