Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotSignature.java @ 21738:28943e5044b5
Merge
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 04 Jun 2015 19:49:45 -0700 |
parents | 48c1ebd24120 |
children |
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 */ |
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
|
23 package com.oracle.jvmci.hotspot; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
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
|
27 import com.oracle.jvmci.common.*; |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
28 import com.oracle.jvmci.meta.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 * Represents a method signature. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 */ |
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:
19447
diff
changeset
|
33 public class HotSpotSignature implements Signature { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
35 private final List<String> parameters = new ArrayList<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 private final String returnType; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 private final String originalString; |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
38 private ResolvedJavaType[] parameterTypes; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
39 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
|
40 private final HotSpotJVMCIRuntimeProvider runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
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
|
42 public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, String signature) { |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
43 this.runtime = runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 assert signature.length() > 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 this.originalString = signature; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 if (signature.charAt(0) == '(') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 int cur = 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 while (cur < signature.length() && signature.charAt(cur) != ')') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 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
|
51 parameters.add(signature.substring(cur, nextCur)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 cur = nextCur; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 cur++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 int nextCur = parseSignature(signature, cur); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 returnType = signature.substring(cur, nextCur); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 assert nextCur == signature.length(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 returnType = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
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
|
64 public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
74 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
|
75 this.originalString = sb.toString(); |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
76 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
|
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 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
79 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
|
80 int cur = start; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 char first; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 do { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 first = signature.charAt(cur++); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 } while (first == '['); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 switch (first) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 case 'L': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 while (signature.charAt(cur) != ';') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 cur++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 cur++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 case 'V': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 case 'I': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 case 'B': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 case 'C': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 case 'D': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 case 'F': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 case 'J': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 case 'S': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 case 'Z': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 default: |
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
|
104 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
|
105 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 return cur; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 @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
|
110 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
|
111 return parameters.size() + (withReceiver ? 1 : 0); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 @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
|
115 public Kind getParameterKind(int index) { |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
116 return Kind.fromTypeString(parameters.get(index)); |
3733
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 |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
119 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
|
120 assert accessingClass != null; |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
121 if (type == null) { |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
122 return false; |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
123 } else if (type instanceof HotSpotResolvedObjectTypeImpl) { |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
16575
diff
changeset
|
124 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
|
125 } |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
126 return true; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
127 } |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
128 |
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
|
129 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
|
130 if (name.length() == 1) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
131 Kind kind = Kind.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
|
132 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
|
133 } |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
134 return new HotSpotUnresolvedJavaType(name, runtime); |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
135 } |
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
136 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 @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
|
138 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
|
139 if (accessingClass == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
140 // 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
|
141 // or primitive type (primitive type resolution is context free) |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
142 return getUnresolvedOrPrimitiveType(runtime, parameters.get(index)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 } |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
144 if (parameterTypes == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
145 parameterTypes = new ResolvedJavaType[parameters.size()]; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
146 } |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
147 |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
148 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
|
149 if (!checkValidCache(type, accessingClass)) { |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
150 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:
18564
diff
changeset
|
151 if (result instanceof ResolvedJavaType) { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
152 type = (ResolvedJavaType) result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
153 parameterTypes[index] = type; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
154 } else { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
155 return result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
156 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 return type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 |
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
|
161 @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
|
162 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
|
163 assert originalString.equals(Signature.super.toMethodDescriptor()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 return originalString; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 @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
|
168 public Kind getReturnKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
169 return Kind.fromTypeString(returnType); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 @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
|
173 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
|
174 if (accessingClass == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
175 // 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
|
176 // or primitive type (primitive type resolution is context free) |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
177 return getUnresolvedOrPrimitiveType(runtime, returnType); |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
178 } |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
179 if (!checkValidCache(returnTypeCache, accessingClass)) { |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
180 JavaType result = runtime.lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false); |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
181 if (result instanceof ResolvedJavaType) { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
182 returnTypeCache = (ResolvedJavaType) result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
183 } else { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
184 return result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
185 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 return returnTypeCache; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 public String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 return "HotSpotSignature<" + originalString + ">"; |
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 |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
195 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
204 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
205 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
|
206 } |
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 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
209 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
|
210 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
|
211 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 } |