Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java @ 16575:adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 20 Jul 2014 17:10:04 +0200 |
parents | 8853b9304083 |
children | 17c98fad6980 |
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 */ |
5548
8872bc0eebdf
Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
23 package com.oracle.graal.hotspot.meta; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
7676
diff
changeset
|
25 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
7676
diff
changeset
|
26 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14963
diff
changeset
|
30 import com.oracle.graal.compiler.common.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.hotspot.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.java.*; |
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 */ |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
37 public class HotSpotSignature extends CompilerObject implements Signature { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
39 private static final long serialVersionUID = -2890917956072366116L; |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
40 private final List<String> parameters = new ArrayList<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 private final String returnType; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 private final String originalString; |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
43 private ResolvedJavaType[] parameterTypes; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
44 private ResolvedJavaType returnTypeCache; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
5530
9da759562a42
Remove compiler member field from HotSpot's implementation of the Ri* interfaces.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5526
diff
changeset
|
46 public HotSpotSignature(String signature) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 assert signature.length() > 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 this.originalString = signature; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 if (signature.charAt(0) == '(') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 int cur = 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 while (cur < signature.length() && signature.charAt(cur) != ')') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 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
|
54 parameters.add(signature.substring(cur, nextCur)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 cur = nextCur; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 } |
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 cur++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 int nextCur = parseSignature(signature, cur); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 returnType = signature.substring(cur, nextCur); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 assert nextCur == signature.length(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 returnType = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 } |
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 |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
67 public HotSpotSignature(ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { |
9657
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.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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 } |
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(")").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
|
77 this.originalString = sb.toString(); |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
78 assert new HotSpotSignature(originalString).equals(this); |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
79 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
80 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
81 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
|
82 int cur = start; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 char first; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 do { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 first = signature.charAt(cur++); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 } while (first == '['); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 switch (first) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 case 'L': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 while (signature.charAt(cur) != ';') { |
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 } |
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 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 case 'V': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 case 'I': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 case 'B': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 case 'C': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 case 'D': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 case 'F': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 case 'J': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 case 'S': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 case 'Z': |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 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
|
106 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
|
107 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 return cur; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 @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
|
112 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
|
113 return parameters.size() + (withReceiver ? 1 : 0); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 @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
|
117 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
|
118 return Kind.fromTypeString(parameters.get(index)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 @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
|
122 public int getParameterSlots(boolean withReceiver) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 int argSlots = 0; |
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
|
124 for (int i = 0; i < getParameterCount(false); i++) { |
14792
b9805a622546
Created abstract class FrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
12431
diff
changeset
|
125 argSlots += HIRFrameStateBuilder.stackSlots(getParameterKind(i)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 return argSlots + (withReceiver ? 1 : 0); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
130 private static boolean checkValidCache(JavaType type, ResolvedJavaType accessingClass) { |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
131 assert accessingClass != null; |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
132 if (!(type instanceof ResolvedJavaType)) { |
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
133 return false; |
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
134 } |
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 if (type instanceof HotSpotResolvedObjectType) { |
16575
adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
Doug Simon <doug.simon@oracle.com>
parents:
16492
diff
changeset
|
137 return ((HotSpotResolvedObjectType) type).isDefinitelyResolvedWithRespectTo(accessingClass); |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
138 } |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
139 return true; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
140 } |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
141 |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
142 private static JavaType getUnresolvedOrPrimitiveType(String name) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
143 if (name.length() == 1) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
144 Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
145 return HotSpotResolvedPrimitiveType.fromKind(kind); |
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 return new HotSpotUnresolvedJavaType(name); |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
148 } |
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
149 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 @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
|
151 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
|
152 if (accessingClass == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
153 // 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
|
154 // or primitive type (primitive type resolution is context free) |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
155 return getUnresolvedOrPrimitiveType(parameters.get(index)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 } |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
157 if (parameterTypes == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
158 parameterTypes = new ResolvedJavaType[parameters.size()]; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
159 } |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
160 |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
161 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
|
162 if (!checkValidCache(type, accessingClass)) { |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
163 type = (ResolvedJavaType) runtime().lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, true); |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
164 parameterTypes[index] = type; |
3733
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 return type; |
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 |
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
|
169 @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
|
170 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
|
171 assert originalString.equals(Signature.super.toMethodDescriptor()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 return originalString; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 } |
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 @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
|
176 public Kind getReturnKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
177 return Kind.fromTypeString(returnType); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 @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
|
181 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
|
182 if (accessingClass == null) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
183 // 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
|
184 // or primitive type (primitive type resolution is context free) |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
185 return getUnresolvedOrPrimitiveType(returnType); |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
186 } |
14963
0c2e34446bd7
Check for correct classloader before returning cached resolved type.
Roland Schatz <roland.schatz@oracle.com>
parents:
14792
diff
changeset
|
187 if (!checkValidCache(returnTypeCache, accessingClass)) { |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16483
diff
changeset
|
188 returnTypeCache = (ResolvedJavaType) runtime().lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, true); |
3733
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 return returnTypeCache; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 } |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 public String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 return "HotSpotSignature<" + originalString + ">"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
198 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
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 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
|
209 } |
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 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
212 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
|
213 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
|
214 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 } |