1 /* |
1 /* |
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 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. |
29 |
29 |
30 import org.graalvm.compiler.graph.Node; |
30 import org.graalvm.compiler.graph.Node; |
31 import org.graalvm.compiler.graph.spi.CanonicalizerTool; |
31 import org.graalvm.compiler.graph.spi.CanonicalizerTool; |
32 import org.graalvm.compiler.nodes.StructuredGraph; |
32 import org.graalvm.compiler.nodes.StructuredGraph; |
33 import org.graalvm.compiler.nodes.java.MethodCallTargetNode; |
33 import org.graalvm.compiler.nodes.java.MethodCallTargetNode; |
|
34 import org.graalvm.compiler.nodes.spi.CoreProviders; |
34 import org.graalvm.compiler.phases.VerifyPhase; |
35 import org.graalvm.compiler.phases.VerifyPhase; |
35 import org.graalvm.compiler.phases.tiers.PhaseContext; |
|
36 |
36 |
37 import jdk.vm.ci.meta.MetaAccessProvider; |
37 import jdk.vm.ci.meta.MetaAccessProvider; |
38 import jdk.vm.ci.meta.ResolvedJavaMethod; |
38 import jdk.vm.ci.meta.ResolvedJavaMethod; |
39 import jdk.vm.ci.meta.ResolvedJavaMethod.Parameter; |
39 import jdk.vm.ci.meta.ResolvedJavaMethod.Parameter; |
40 import jdk.vm.ci.meta.ResolvedJavaType; |
40 import jdk.vm.ci.meta.ResolvedJavaType; |
43 * {@link Node#getOptions()} is unsafe for use during canonicalization so try to verify that it |
43 * {@link Node#getOptions()} is unsafe for use during canonicalization so try to verify that it |
44 * isn't used when a {@link CanonicalizerTool} is available in the arguments. This is slightly more |
44 * isn't used when a {@link CanonicalizerTool} is available in the arguments. This is slightly more |
45 * general but since there are several canonical methods with varying signatures this covers more |
45 * general but since there are several canonical methods with varying signatures this covers more |
46 * cases. |
46 * cases. |
47 */ |
47 */ |
48 public class VerifyGetOptionsUsage extends VerifyPhase<PhaseContext> { |
48 public class VerifyGetOptionsUsage extends VerifyPhase<CoreProviders> { |
49 static Method lookupMethod(Class<?> klass, String name) { |
49 static Method lookupMethod(Class<?> klass, String name) { |
50 for (Method m : klass.getDeclaredMethods()) { |
50 for (Method m : klass.getDeclaredMethods()) { |
51 if (m.getName().equals(name)) { |
51 if (m.getName().equals(name)) { |
52 return m; |
52 return m; |
53 } |
53 } |
54 } |
54 } |
55 throw new InternalError(); |
55 throw new InternalError(); |
56 } |
56 } |
57 |
57 |
58 @Override |
58 @Override |
59 protected void verify(StructuredGraph graph, PhaseContext context) { |
59 protected void verify(StructuredGraph graph, CoreProviders context) { |
60 MetaAccessProvider metaAccess = context.getMetaAccess(); |
60 MetaAccessProvider metaAccess = context.getMetaAccess(); |
61 ResolvedJavaType canonicalizerToolClass = metaAccess.lookupJavaType(CanonicalizerTool.class); |
61 ResolvedJavaType canonicalizerToolClass = metaAccess.lookupJavaType(CanonicalizerTool.class); |
62 boolean hasTool = false; |
62 boolean hasTool = false; |
63 ResolvedJavaMethod method = graph.method(); |
63 ResolvedJavaMethod method = graph.method(); |
64 try { |
64 try { |