Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java @ 9986:4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 11 Jun 2013 01:31:47 +0200 |
parents | |
children | 0a59959177c9 |
rev | line source |
---|---|
9986
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 package com.oracle.graal.hotspot.phases; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.api.meta.MetaUtil.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import static java.lang.reflect.Modifier.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import java.util.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.api.meta.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.graph.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.hotspot.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.hotspot.meta.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.java.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.java.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.graal.nodes.util.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.graal.options.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 import com.oracle.graal.phases.*; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 /** |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 * Verifies that a class that declares one or more HotSpot {@linkplain OptionValue options} has a |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 * class initializer that only initializes the option(s). This sanity check prevents an option being |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 * read to initialize some global state before it is parsed on the command line. The latter occurs |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 * if an option declaring class has a class initializer that reads options or triggers other class |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 * initializers that read options. |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 */ |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 public class VerifyHotSpotOptionsPhase extends Phase { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 public static boolean checkOptions() { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 HotSpotRuntime runtime = graalRuntime().getRuntime(); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 ServiceLoader<Options> sl = ServiceLoader.loadInstalled(Options.class); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 Set<HotSpotResolvedObjectType> checked = new HashSet<>(); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 for (Options opts : sl) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 for (OptionDescriptor desc : opts) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 if (HotSpotOptions.isHotSpotOption(desc)) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 HotSpotResolvedObjectType holder = (HotSpotResolvedObjectType) runtime.lookupJavaType(desc.getDeclaringClass()); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 if (!checked.contains(holder)) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 checked.add(holder); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 for (ResolvedJavaMethod method : holder.getMethods()) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 if (method.isClassInitializer()) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 StructuredGraph graph = new StructuredGraph(method); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 new VerifyHotSpotOptionsPhase(holder, runtime).apply(graph); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 return true; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 private final HotSpotRuntime runtime; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 private final ResolvedJavaType declaringClass; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 private final ResolvedJavaType optionValueType; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 private final Set<ResolvedJavaType> boxingTypes; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 public VerifyHotSpotOptionsPhase(ResolvedJavaType declaringClass, HotSpotRuntime runtime) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 this.runtime = runtime; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 this.declaringClass = declaringClass; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 this.optionValueType = runtime.lookupJavaType(OptionValue.class); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 this.boxingTypes = new HashSet<>(); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 for (Class c : new Class[]{Boolean.class, Byte.class, Short.class, Character.class, Integer.class, Float.class, Long.class, Double.class}) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 this.boxingTypes.add(runtime.lookupJavaType(c)); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 /** |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 * Checks whether a given method is allowed to be called. |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 */ |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 private boolean checkInvokeTarget(ResolvedJavaMethod method) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 ResolvedJavaType holder = method.getDeclaringClass(); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 if (method.isConstructor()) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 if (optionValueType.isAssignableFrom(holder)) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 return true; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 } else if (boxingTypes.contains(holder)) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 return method.getName().equals("valueOf"); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 } else if (method.getDeclaringClass() == runtime.lookupJavaType(Class.class)) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 return method.getName().equals("desiredAssertionStatus"); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 return false; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 @Override |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 protected void run(StructuredGraph graph) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 for (ValueNode node : graph.getNodes().filter(ValueNode.class)) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 if (node instanceof StoreFieldNode) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) ((StoreFieldNode) node).field(); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 verify(field.getDeclaringClass() == declaringClass, node, "store to field " + format("%H.%n", field)); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 verify(isStatic(field.getModifiers()), node, "store to field " + format("%H.%n", field)); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 if (optionValueType.isAssignableFrom((ResolvedJavaType) field.getType())) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 verify(isFinal(field.getModifiers()), node, "option field " + format("%H.%n", field) + " not final"); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 } else { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 verify((field.isSynthetic()), node, "store to non-synthetic field " + format("%H.%n", field)); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 } else if (node instanceof Invoke) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 Invoke invoke = (Invoke) node; |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget(); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 ResolvedJavaMethod targetMethod = callTarget.targetMethod(); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 verify(checkInvokeTarget(targetMethod), node, "invocation of " + format("%H.%n(%p)", targetMethod)); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 private void verify(boolean condition, Node node, String message) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 if (!condition) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 error(node, message); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 private void error(Node node, String message) { |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 String loc = GraphUtil.approxSourceLocation(node); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 throw new GraalInternalError(String.format("HotSpot option declarer %s contains code pattern implying action other than initialization of an option:%n %s%n %s", |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 toJavaName(declaringClass), loc, message)); |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 } |
4f542ceb5fed
added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 } |