Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java @ 9657:4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 13 May 2013 13:50:46 +0200 |
parents | 261a43921c5e |
children | 7080a96be216 |
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.*; |
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
|
30 import com.oracle.graal.graph.*; |
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; |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
43 private JavaType[] parameterTypes; |
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
|
44 private JavaType 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 |
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 public HotSpotSignature(JavaType returnType, JavaType... parameterTypes) { |
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++) { |
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
|
125 argSlots += FrameStateBuilder.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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 @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
|
131 public JavaType getParameterType(int index, ResolvedJavaType accessingClass) { |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
132 if (parameterTypes == null) { |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
133 parameterTypes = new JavaType[parameters.size()]; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 } |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
135 JavaType type = parameterTypes[index]; |
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
|
136 if (type == null || !(type instanceof ResolvedJavaType)) { |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
137 type = graalRuntime().lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, false); |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
138 parameterTypes[index] = type; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 return type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 |
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
|
143 public String getMethodDescriptor() { |
7676
ca9061b6694c
getMethodDescriptor does not need to be in the Signature interface
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7359
diff
changeset
|
144 assert originalString.equals(MetaUtil.signatureToMethodDescriptor(this)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 return originalString; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 @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
|
149 public Kind getReturnKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
150 return Kind.fromTypeString(returnType); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 @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
|
154 public JavaType getReturnType(ResolvedJavaType accessingClass) { |
7040
fdcdbc3dd76c
HotSpotSignature.getParameterType should not try eager resolving.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6539
diff
changeset
|
155 if (returnTypeCache == null || !(returnTypeCache instanceof ResolvedJavaType)) { |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
7676
diff
changeset
|
156 returnTypeCache = graalRuntime().lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false); |
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 returnTypeCache; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 public String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 return "HotSpotSignature<" + originalString + ">"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 |
9657
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
166 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
175 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
176 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
|
177 } |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
178 |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
179 @Override |
4c162e218809
enabled creation of a HotSpotSignature from types (in addition to a string)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
180 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
|
181 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
|
182 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 } |