src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotInvocationPlugins.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
28 |
28 |
29 import java.lang.reflect.Type; |
29 import java.lang.reflect.Type; |
30 import java.util.function.Predicate; |
30 import java.util.function.Predicate; |
31 |
31 |
32 import org.graalvm.compiler.core.common.GraalOptions; |
32 import org.graalvm.compiler.core.common.GraalOptions; |
|
33 import org.graalvm.compiler.debug.GraalError; |
33 import org.graalvm.compiler.graph.Node; |
34 import org.graalvm.compiler.graph.Node; |
34 import org.graalvm.compiler.graph.iterators.NodeIterable; |
35 import org.graalvm.compiler.graph.iterators.NodeIterable; |
35 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig; |
36 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig; |
|
37 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; |
36 import org.graalvm.compiler.hotspot.phases.AheadOfTimeVerificationPhase; |
38 import org.graalvm.compiler.hotspot.phases.AheadOfTimeVerificationPhase; |
37 import org.graalvm.compiler.nodes.ConstantNode; |
39 import org.graalvm.compiler.nodes.ConstantNode; |
38 import org.graalvm.compiler.nodes.FrameState; |
40 import org.graalvm.compiler.nodes.FrameState; |
39 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; |
41 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; |
40 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin; |
42 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin; |
48 |
50 |
49 /** |
51 /** |
50 * Extension of {@link InvocationPlugins} that disables plugins based on runtime configuration. |
52 * Extension of {@link InvocationPlugins} that disables plugins based on runtime configuration. |
51 */ |
53 */ |
52 final class HotSpotInvocationPlugins extends InvocationPlugins { |
54 final class HotSpotInvocationPlugins extends InvocationPlugins { |
|
55 private final HotSpotGraalRuntimeProvider graalRuntime; |
53 private final GraalHotSpotVMConfig config; |
56 private final GraalHotSpotVMConfig config; |
54 private final Predicate<ResolvedJavaType> intrinsificationPredicate; |
57 private final Predicate<ResolvedJavaType> intrinsificationPredicate; |
55 |
58 |
56 HotSpotInvocationPlugins(GraalHotSpotVMConfig config, CompilerConfiguration compilerConfiguration) { |
59 HotSpotInvocationPlugins(HotSpotGraalRuntimeProvider graalRuntime, GraalHotSpotVMConfig config, CompilerConfiguration compilerConfiguration) { |
|
60 this.graalRuntime = graalRuntime; |
57 this.config = config; |
61 this.config = config; |
58 this.intrinsificationPredicate = runtime().getIntrinsificationTrustPredicate(compilerConfiguration.getClass()); |
62 this.intrinsificationPredicate = runtime().getIntrinsificationTrustPredicate(compilerConfiguration.getClass()); |
59 } |
63 } |
60 |
64 |
61 @Override |
65 @Override |
104 return type != null && "Ljava/lang/Class;".equals(type.getName()); |
108 return type != null && "Ljava/lang/Class;".equals(type.getName()); |
105 } |
109 } |
106 |
110 |
107 @Override |
111 @Override |
108 public boolean canBeIntrinsified(ResolvedJavaType declaringClass) { |
112 public boolean canBeIntrinsified(ResolvedJavaType declaringClass) { |
109 return intrinsificationPredicate.test(declaringClass); |
113 if (!intrinsificationPredicate.test(declaringClass)) { |
|
114 if (graalRuntime.isBootstrapping()) { |
|
115 throw GraalError.shouldNotReachHere("Class declaring a method for which a Graal intrinsic is available should be trusted for intrinsification: " + declaringClass.toJavaName()); |
|
116 } |
|
117 return false; |
|
118 } |
|
119 return true; |
|
120 |
110 } |
121 } |
111 } |
122 } |