Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java @ 21526:1da7aef31a08
created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 19 May 2015 23:16:07 +0200 |
parents | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java@082417ac43e4 |
children |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
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 */ |
21526
1da7aef31a08
created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
23 package com.oracle.graal.hotspot.jvmci; |
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 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14963
diff
changeset
|
28 import com.oracle.graal.compiler.common.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.hotspot.*; |
3733
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 * Represents a method signature. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 */ |
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
|
34 public class HotSpotSignature implements Signature { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
36 private final List<String> parameters = new ArrayList<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 private final String returnType; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 private final String originalString; |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
39 private ResolvedJavaType[] parameterTypes; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
40 private ResolvedJavaType returnTypeCache; |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
41 private final HotSpotGraalRuntimeProvider runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
43 public HotSpotSignature(HotSpotGraalRuntimeProvider runtime, String signature) { |
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
44 this.runtime = runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 assert signature.length() > 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 this.originalString = signature; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 if (signature.charAt(0) == '(') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 int cur = 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 while (cur < signature.length() && signature.charAt(cur) != ')') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 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
|
52 parameters.add(signature.substring(cur, nextCur)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 cur = nextCur; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 cur++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 int nextCur = parseSignature(signature, cur); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 returnType = signature.substring(cur, nextCur); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 assert nextCur == signature.length(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 returnType = null; |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
65 public HotSpotSignature(HotSpotGraalRuntimeProvider runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { |
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
79 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
80 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
|
81 int cur = start; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 char first; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 do { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 first = signature.charAt(cur++); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 } while (first == '['); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 switch (first) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 case 'L': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 while (signature.charAt(cur) != ';') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 cur++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 cur++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 case 'V': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 case 'I': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 case 'B': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 case 'C': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 case 'D': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 case 'F': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 case 'J': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 case 'S': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 case 'Z': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 default: |
7359
6a16788a29a6
added API method for parsing a valid Method Descriptor string (JVMS 4.3.3) into a Signature object
Doug Simon <doug.simon@oracle.com>
parents:
7357
diff
changeset
|
105 throw new GraalInternalError("Invalid character at index " + cur + " in signature: " + signature); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 return cur; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 @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
|
111 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
|
112 return parameters.size() + (withReceiver ? 1 : 0); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 @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
|
116 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
|
117 return Kind.fromTypeString(parameters.get(index)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
120 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
|
121 assert accessingClass != null; |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
122 if (type == null) { |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
123 return false; |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
124 } else if (type instanceof HotSpotResolvedObjectTypeImpl) { |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
16575
diff
changeset
|
125 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
|
126 } |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
127 return true; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
128 } |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
129 |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
130 private static JavaType getUnresolvedOrPrimitiveType(HotSpotGraalRuntimeProvider runtime, String name) { |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
131 if (name.length() == 1) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
132 Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
133 return runtime.getHostProviders().getMetaAccess().lookupJavaType(kind.toJavaClass()); |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
134 } |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
135 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
|
136 } |
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
137 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 @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
|
139 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
|
140 if (accessingClass == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
141 // 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
|
142 // 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
|
143 return getUnresolvedOrPrimitiveType(runtime, parameters.get(index)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 } |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
145 if (parameterTypes == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
146 parameterTypes = new ResolvedJavaType[parameters.size()]; |
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 |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
149 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
|
150 if (!checkValidCache(type, accessingClass)) { |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
151 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
|
152 if (result instanceof ResolvedJavaType) { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
153 type = (ResolvedJavaType) result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
154 parameterTypes[index] = type; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
155 } else { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
156 return result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
157 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 return type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 |
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
|
162 @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
|
163 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
|
164 assert originalString.equals(Signature.super.toMethodDescriptor()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 return originalString; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 @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
|
169 public Kind getReturnKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
170 return Kind.fromTypeString(returnType); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 @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
|
174 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
|
175 if (accessingClass == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
176 // 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
|
177 // 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
|
178 return getUnresolvedOrPrimitiveType(runtime, returnType); |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
179 } |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
180 if (!checkValidCache(returnTypeCache, accessingClass)) { |
19447
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
181 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
|
182 if (result instanceof ResolvedJavaType) { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
183 returnTypeCache = (ResolvedJavaType) result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
184 } else { |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
185 return result; |
2452e881fad5
Do not eagerly resolve types in lookupType.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18564
diff
changeset
|
186 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 return returnTypeCache; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 public String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 return "HotSpotSignature<" + originalString + ">"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
196 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
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 } |
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 false; |
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 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
210 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
|
211 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
|
212 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 } |