25 import static jdk.vm.ci.meta.DeoptimizationAction.InvalidateRecompile;
26 import static jdk.vm.ci.meta.DeoptimizationReason.Unresolved;
27 import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC;
28 import static org.graalvm.compiler.hotspot.meta.HotSpotAOTProfilingPlugin.Options.TieredAOT;
29 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.JAVA_THREAD_THREAD_OBJECT_LOCATION;
30 import static org.graalvm.compiler.java.BytecodeParserOptions.InlineDuringParsing;
31 import static org.graalvm.compiler.serviceprovider.JDK9Method.Java8OrEarlier;
32
33 import java.lang.invoke.ConstantCallSite;
34 import java.lang.invoke.MutableCallSite;
35 import java.lang.invoke.VolatileCallSite;
36 import java.lang.reflect.Method;
37 import java.lang.reflect.Modifier;
38 import java.math.BigInteger;
39 import java.util.zip.CRC32;
40
41 import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
42 import org.graalvm.compiler.bytecode.BytecodeProvider;
43 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
44 import org.graalvm.compiler.debug.GraalError;
45 import org.graalvm.compiler.hotspot.FingerprintUtil;
46 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
47 import org.graalvm.compiler.hotspot.nodes.CurrentJavaThreadNode;
48 import org.graalvm.compiler.hotspot.replacements.AESCryptSubstitutions;
49 import org.graalvm.compiler.hotspot.replacements.BigIntegerSubstitutions;
50 import org.graalvm.compiler.hotspot.replacements.CRC32Substitutions;
51 import org.graalvm.compiler.hotspot.replacements.CallSiteTargetNode;
52 import org.graalvm.compiler.hotspot.replacements.CipherBlockChainingSubstitutions;
53 import org.graalvm.compiler.hotspot.replacements.ClassGetHubNode;
54 import org.graalvm.compiler.hotspot.replacements.HotSpotClassSubstitutions;
55 import org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode;
56 import org.graalvm.compiler.hotspot.replacements.ObjectCloneNode;
57 import org.graalvm.compiler.hotspot.replacements.ObjectSubstitutions;
58 import org.graalvm.compiler.hotspot.replacements.ReflectionGetCallerClassNode;
59 import org.graalvm.compiler.hotspot.replacements.ReflectionSubstitutions;
60 import org.graalvm.compiler.hotspot.replacements.SHA2Substitutions;
61 import org.graalvm.compiler.hotspot.replacements.SHA5Substitutions;
62 import org.graalvm.compiler.hotspot.replacements.SHASubstitutions;
63 import org.graalvm.compiler.hotspot.replacements.ThreadSubstitutions;
64 import org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode;
65 import org.graalvm.compiler.hotspot.word.HotSpotWordTypes;
131 ReplacementsImpl replacements) {
132 InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, compilerConfiguration);
133
134 Plugins plugins = new Plugins(invocationPlugins);
135 NodeIntrinsificationProvider nodeIntrinsificationProvider = new NodeIntrinsificationProvider(metaAccess, snippetReflection, foreignCalls, wordTypes);
136 HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(snippetReflection, wordTypes);
137 HotSpotNodePlugin nodePlugin = new HotSpotNodePlugin(wordOperationPlugin);
138
139 plugins.appendTypePlugin(nodePlugin);
140 plugins.appendNodePlugin(nodePlugin);
141 OptionValues options = replacements.getOptions();
142 if (GeneratePIC.getValue(options)) {
143 // AOT needs to filter out bad invokes
144 plugins.prependNodePlugin(new NodePlugin() {
145 @Override
146 public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
147 if (b.parsingIntrinsic()) {
148 return false;
149 }
150 // check if the holder has a valid fingerprint
151 if (FingerprintUtil.getFingerprint((HotSpotResolvedObjectType) method.getDeclaringClass()) == 0) {
152 // Deopt otherwise
153 b.append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
154 return true;
155 }
156 // the last argument that may come from appendix, check if it is a supported
157 // constant type
158 if (args.length > 0) {
159 JavaConstant constant = args[args.length - 1].asJavaConstant();
160 if (constant != null && constant instanceof HotSpotObjectConstant) {
161 HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) ((HotSpotObjectConstant) constant).getType();
162 Class<?> clazz = type.mirror();
163 if (clazz.equals(String.class)) {
164 return false;
165 }
166 if (Class.class.isAssignableFrom(clazz) && FingerprintUtil.getFingerprint((HotSpotResolvedObjectType) type) != 0) {
167 return false;
168 }
169 b.append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
170 return true;
171 }
172 }
173 return false;
174 }
175 });
176 }
177 plugins.appendNodePlugin(new MethodHandlePlugin(constantReflection.getMethodHandleAccess(), true));
178 plugins.appendInlineInvokePlugin(replacements);
179 if (InlineDuringParsing.getValue(options)) {
180 plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin());
181 }
182
183 if (GeneratePIC.getValue(options)) {
184 plugins.setClassInitializationPlugin(new HotSpotClassInitializationPlugin());
185 if (TieredAOT.getValue(options)) {
186 plugins.setProfilingPlugin(new HotSpotAOTProfilingPlugin());
|
25 import static jdk.vm.ci.meta.DeoptimizationAction.InvalidateRecompile;
26 import static jdk.vm.ci.meta.DeoptimizationReason.Unresolved;
27 import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC;
28 import static org.graalvm.compiler.hotspot.meta.HotSpotAOTProfilingPlugin.Options.TieredAOT;
29 import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.JAVA_THREAD_THREAD_OBJECT_LOCATION;
30 import static org.graalvm.compiler.java.BytecodeParserOptions.InlineDuringParsing;
31 import static org.graalvm.compiler.serviceprovider.JDK9Method.Java8OrEarlier;
32
33 import java.lang.invoke.ConstantCallSite;
34 import java.lang.invoke.MutableCallSite;
35 import java.lang.invoke.VolatileCallSite;
36 import java.lang.reflect.Method;
37 import java.lang.reflect.Modifier;
38 import java.math.BigInteger;
39 import java.util.zip.CRC32;
40
41 import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
42 import org.graalvm.compiler.bytecode.BytecodeProvider;
43 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
44 import org.graalvm.compiler.debug.GraalError;
45 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
46 import org.graalvm.compiler.hotspot.nodes.CurrentJavaThreadNode;
47 import org.graalvm.compiler.hotspot.replacements.AESCryptSubstitutions;
48 import org.graalvm.compiler.hotspot.replacements.BigIntegerSubstitutions;
49 import org.graalvm.compiler.hotspot.replacements.CRC32Substitutions;
50 import org.graalvm.compiler.hotspot.replacements.CallSiteTargetNode;
51 import org.graalvm.compiler.hotspot.replacements.CipherBlockChainingSubstitutions;
52 import org.graalvm.compiler.hotspot.replacements.ClassGetHubNode;
53 import org.graalvm.compiler.hotspot.replacements.HotSpotClassSubstitutions;
54 import org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode;
55 import org.graalvm.compiler.hotspot.replacements.ObjectCloneNode;
56 import org.graalvm.compiler.hotspot.replacements.ObjectSubstitutions;
57 import org.graalvm.compiler.hotspot.replacements.ReflectionGetCallerClassNode;
58 import org.graalvm.compiler.hotspot.replacements.ReflectionSubstitutions;
59 import org.graalvm.compiler.hotspot.replacements.SHA2Substitutions;
60 import org.graalvm.compiler.hotspot.replacements.SHA5Substitutions;
61 import org.graalvm.compiler.hotspot.replacements.SHASubstitutions;
62 import org.graalvm.compiler.hotspot.replacements.ThreadSubstitutions;
63 import org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode;
64 import org.graalvm.compiler.hotspot.word.HotSpotWordTypes;
130 ReplacementsImpl replacements) {
131 InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, compilerConfiguration);
132
133 Plugins plugins = new Plugins(invocationPlugins);
134 NodeIntrinsificationProvider nodeIntrinsificationProvider = new NodeIntrinsificationProvider(metaAccess, snippetReflection, foreignCalls, wordTypes);
135 HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(snippetReflection, wordTypes);
136 HotSpotNodePlugin nodePlugin = new HotSpotNodePlugin(wordOperationPlugin);
137
138 plugins.appendTypePlugin(nodePlugin);
139 plugins.appendNodePlugin(nodePlugin);
140 OptionValues options = replacements.getOptions();
141 if (GeneratePIC.getValue(options)) {
142 // AOT needs to filter out bad invokes
143 plugins.prependNodePlugin(new NodePlugin() {
144 @Override
145 public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
146 if (b.parsingIntrinsic()) {
147 return false;
148 }
149 // check if the holder has a valid fingerprint
150 if (((HotSpotResolvedObjectType) method.getDeclaringClass()).getFingerprint() == 0) {
151 // Deopt otherwise
152 b.append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
153 return true;
154 }
155 // the last argument that may come from appendix, check if it is a supported
156 // constant type
157 if (args.length > 0) {
158 JavaConstant constant = args[args.length - 1].asJavaConstant();
159 if (constant != null && constant instanceof HotSpotObjectConstant) {
160 HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) ((HotSpotObjectConstant) constant).getType();
161 Class<?> clazz = type.mirror();
162 if (clazz.equals(String.class)) {
163 return false;
164 }
165 if (Class.class.isAssignableFrom(clazz) && ((HotSpotResolvedObjectType) type).getFingerprint() != 0) {
166 return false;
167 }
168 b.append(new DeoptimizeNode(InvalidateRecompile, Unresolved));
169 return true;
170 }
171 }
172 return false;
173 }
174 });
175 }
176 plugins.appendNodePlugin(new MethodHandlePlugin(constantReflection.getMethodHandleAccess(), true));
177 plugins.appendInlineInvokePlugin(replacements);
178 if (InlineDuringParsing.getValue(options)) {
179 plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin());
180 }
181
182 if (GeneratePIC.getValue(options)) {
183 plugins.setClassInitializationPlugin(new HotSpotClassInitializationPlugin());
184 if (TieredAOT.getValue(options)) {
185 plugins.setProfilingPlugin(new HotSpotAOTProfilingPlugin());
|