24 |
24 |
25 package org.graalvm.compiler.hotspot; |
25 package org.graalvm.compiler.hotspot; |
26 |
26 |
27 import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; |
27 import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; |
28 import org.graalvm.compiler.bytecode.BytecodeProvider; |
28 import org.graalvm.compiler.bytecode.BytecodeProvider; |
|
29 import org.graalvm.compiler.hotspot.meta.HotSpotWordOperationPlugin; |
29 import org.graalvm.compiler.hotspot.word.HotSpotOperation; |
30 import org.graalvm.compiler.hotspot.word.HotSpotOperation; |
|
31 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderPlugin; |
30 import org.graalvm.compiler.options.OptionValues; |
32 import org.graalvm.compiler.options.OptionValues; |
31 import org.graalvm.compiler.phases.util.Providers; |
33 import org.graalvm.compiler.phases.util.Providers; |
32 import org.graalvm.compiler.printer.GraalDebugHandlersFactory; |
34 import org.graalvm.compiler.printer.GraalDebugHandlersFactory; |
33 import org.graalvm.compiler.replacements.ReplacementsImpl; |
35 import org.graalvm.compiler.replacements.ReplacementsImpl; |
34 |
36 |
38 /** |
40 /** |
39 * Filters certain method substitutions based on whether there is underlying hardware support for |
41 * Filters certain method substitutions based on whether there is underlying hardware support for |
40 * them. |
42 * them. |
41 */ |
43 */ |
42 public class HotSpotReplacementsImpl extends ReplacementsImpl { |
44 public class HotSpotReplacementsImpl extends ReplacementsImpl { |
43 |
|
44 public HotSpotReplacementsImpl(OptionValues options, Providers providers, SnippetReflectionProvider snippetReflection, BytecodeProvider bytecodeProvider, TargetDescription target) { |
45 public HotSpotReplacementsImpl(OptionValues options, Providers providers, SnippetReflectionProvider snippetReflection, BytecodeProvider bytecodeProvider, TargetDescription target) { |
45 super(options, new GraalDebugHandlersFactory(snippetReflection), providers, snippetReflection, bytecodeProvider, target); |
46 super(options, new GraalDebugHandlersFactory(snippetReflection), providers, snippetReflection, bytecodeProvider, target); |
46 } |
47 } |
47 |
48 |
48 @Override |
49 @Override |
49 protected boolean hasGenericInvocationPluginAnnotation(ResolvedJavaMethod method) { |
50 public Class<? extends GraphBuilderPlugin> getIntrinsifyingPlugin(ResolvedJavaMethod method) { |
50 return method.getAnnotation(HotSpotOperation.class) != null || super.hasGenericInvocationPluginAnnotation(method); |
51 return method.getAnnotation(HotSpotOperation.class) != null ? HotSpotWordOperationPlugin.class : super.getIntrinsifyingPlugin(method); |
|
52 } |
|
53 |
|
54 private boolean snippetRegistrationClosed; |
|
55 |
|
56 @Override |
|
57 public void registerSnippet(ResolvedJavaMethod method, ResolvedJavaMethod original, Object receiver, boolean trackNodeSourcePosition) { |
|
58 assert !snippetRegistrationClosed; |
|
59 super.registerSnippet(method, original, receiver, trackNodeSourcePosition); |
|
60 } |
|
61 |
|
62 @Override |
|
63 public void closeSnippetRegistration() { |
|
64 snippetRegistrationClosed = true; |
51 } |
65 } |
52 } |
66 } |