annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSignature.java @ 24114:2b760c6b0561

missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail - part 4 (JDK-8177673)
author Doug Simon <doug.simon@oracle.com>
date Sat, 01 Apr 2017 00:53:40 +0200
parents b3a816d3b844
children fbcbf83757cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
21552
9579a3c62a9e use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22598
diff changeset
23 package jdk.vm.ci.hotspot;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
22569
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
25 import java.util.ArrayList;
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22536
diff changeset
26 import java.util.List;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
28 import jdk.vm.ci.common.JVMCIError;
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22598
diff changeset
29 import jdk.vm.ci.meta.JavaKind;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22598
diff changeset
30 import jdk.vm.ci.meta.JavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22598
diff changeset
31 import jdk.vm.ci.meta.ResolvedJavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22598
diff changeset
32 import jdk.vm.ci.meta.Signature;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 * Represents a method signature.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 */
21411
082417ac43e4 removed com.oracle.graal.hotspot.server and uses of Serializable it depended upon (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19451
diff changeset
37 public class HotSpotSignature implements Signature {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38
9657
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
39 private final List<String> parameters = new ArrayList<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 private final String returnType;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 private final String originalString;
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
42 private ResolvedJavaType[] parameterTypes;
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
43 private ResolvedJavaType returnTypeCache;
21552
9579a3c62a9e use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
44 private final HotSpotJVMCIRuntimeProvider runtime;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
21552
9579a3c62a9e use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
46 public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, String signature) {
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18374
diff changeset
47 this.runtime = runtime;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 assert signature.length() > 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 this.originalString = signature;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 if (signature.charAt(0) == '(') {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 int cur = 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 while (cur < signature.length() && signature.charAt(cur) != ')') {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 int nextCur = parseSignature(signature, cur);
9657
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
55 parameters.add(signature.substring(cur, nextCur));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 cur = nextCur;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 cur++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 int nextCur = parseSignature(signature, cur);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 returnType = signature.substring(cur, nextCur);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 assert nextCur == signature.length();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 returnType = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67
21552
9579a3c62a9e use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
68 public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) {
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18374
diff changeset
69 this.runtime = runtime;
9657
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
70 this.parameterTypes = parameterTypes.clone();
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
71 this.returnTypeCache = returnType;
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
72 this.returnType = returnType.getName();
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
73 StringBuilder sb = new StringBuilder("(");
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
74 for (JavaType type : parameterTypes) {
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
75 parameters.add(type.getName());
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
76 sb.append(type.getName());
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
77 }
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
78 sb.append(")").append(returnType.getName());
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
79 this.originalString = sb.toString();
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18374
diff changeset
80 assert new HotSpotSignature(runtime, originalString).equals(this);
9657
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
81 }
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
82
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
83 private static int parseSignature(String signature, int start) {
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
84 int cur = start;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 char first;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 do {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 first = signature.charAt(cur++);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 } while (first == '[');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 switch (first) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 case 'L':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 while (signature.charAt(cur) != ';') {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 cur++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 cur++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 case 'V':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 case 'I':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 case 'B':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 case 'C':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 case 'D':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 case 'F':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 case 'J':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 case 'S':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 case 'Z':
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 default:
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
108 throw new JVMCIError("Invalid character at index %d in signature: %s", cur, signature);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 return cur;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6403
diff changeset
114 public int getParameterCount(boolean withReceiver) {
9657
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
115 return parameters.size() + (withReceiver ? 1 : 0);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 @Override
22536
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
119 public JavaKind getParameterKind(int index) {
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
120 return JavaKind.fromTypeString(parameters.get(index));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122
19451
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
123 private static boolean checkValidCache(ResolvedJavaType type, ResolvedJavaType accessingClass) {
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
124 assert accessingClass != null;
19451
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
125 if (type == null) {
14963
0c2e34446bd7 Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents: 14792
diff changeset
126 return false;
19451
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
127 } else if (type instanceof HotSpotResolvedObjectTypeImpl) {
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 16575
diff changeset
128 return ((HotSpotResolvedObjectTypeImpl) type).isDefinitelyResolvedWithRespectTo(accessingClass);
14963
0c2e34446bd7 Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents: 14792
diff changeset
129 }
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
130 return true;
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
131 }
14963
0c2e34446bd7 Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents: 14792
diff changeset
132
21552
9579a3c62a9e use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
133 private static JavaType getUnresolvedOrPrimitiveType(HotSpotJVMCIRuntimeProvider runtime, String name) {
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
134 if (name.length() == 1) {
22536
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
135 JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0));
21552
9579a3c62a9e use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
136 return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(kind.toJavaClass());
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
137 }
22598
ed53e370f04c Make implementation classes package private.
Roland Schatz <roland.schatz@oracle.com>
parents: 22569
diff changeset
138 return HotSpotUnresolvedJavaType.create(runtime, name);
14963
0c2e34446bd7 Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents: 14792
diff changeset
139 }
0c2e34446bd7 Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents: 14792
diff changeset
140
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6403
diff changeset
142 public JavaType getParameterType(int index, ResolvedJavaType accessingClass) {
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
143 if (accessingClass == null) {
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
144 // Caller doesn't care about resolution context so return an unresolved
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
145 // or primitive type (primitive type resolution is context free)
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18374
diff changeset
146 return getUnresolvedOrPrimitiveType(runtime, parameters.get(index));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 }
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
148 if (parameterTypes == null) {
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
149 parameterTypes = new ResolvedJavaType[parameters.size()];
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
150 }
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
151
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
152 ResolvedJavaType type = parameterTypes[index];
14963
0c2e34446bd7 Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents: 14792
diff changeset
153 if (!checkValidCache(type, accessingClass)) {
19451
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
154 JavaType result = runtime.lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, false);
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
155 if (result instanceof ResolvedJavaType) {
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
156 type = (ResolvedJavaType) result;
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
157 parameterTypes[index] = type;
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
158 } else {
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
159 return result;
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
160 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 return type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164
16483
3c3cd36a3836 moved signatureToMethodDescriptor(Signature sig) from MetaUtil to be a default method in Signature
Doug Simon <doug.simon@oracle.com>
parents: 15193
diff changeset
165 @Override
3c3cd36a3836 moved signatureToMethodDescriptor(Signature sig) from MetaUtil to be a default method in Signature
Doug Simon <doug.simon@oracle.com>
parents: 15193
diff changeset
166 public String toMethodDescriptor() {
3c3cd36a3836 moved signatureToMethodDescriptor(Signature sig) from MetaUtil to be a default method in Signature
Doug Simon <doug.simon@oracle.com>
parents: 15193
diff changeset
167 assert originalString.equals(Signature.super.toMethodDescriptor());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 return originalString;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 @Override
22536
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
172 public JavaKind getReturnKind() {
dc1aeef79e7e Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
173 return JavaKind.fromTypeString(returnType);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6403
diff changeset
177 public JavaType getReturnType(ResolvedJavaType accessingClass) {
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
178 if (accessingClass == null) {
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
179 // Caller doesn't care about resolution context so return an unresolved
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
180 // or primitive type (primitive type resolution is context free)
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18374
diff changeset
181 return getUnresolvedOrPrimitiveType(runtime, returnType);
16492
8853b9304083 made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents: 16483
diff changeset
182 }
14963
0c2e34446bd7 Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents: 14792
diff changeset
183 if (!checkValidCache(returnTypeCache, accessingClass)) {
19451
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
184 JavaType result = runtime.lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false);
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
185 if (result instanceof ResolvedJavaType) {
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
186 returnTypeCache = (ResolvedJavaType) result;
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
187 } else {
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
188 return result;
2452e881fad5 Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18569
diff changeset
189 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 return returnTypeCache;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 return "HotSpotSignature<" + originalString + ">";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198
9657
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
199 @Override
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
200 public boolean equals(Object obj) {
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
201 if (obj instanceof HotSpotSignature) {
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
202 HotSpotSignature other = (HotSpotSignature) obj;
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
203 if (other.originalString.equals(originalString)) {
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
204 assert other.parameters.equals(parameters);
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
205 assert other.returnType.equals(returnType);
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
206 return true;
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
207 }
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
208 }
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
209 return false;
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
210 }
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
211
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
212 @Override
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
213 public int hashCode() {
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
214 return originalString.hashCode();
4c162e218809 enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
215 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 }