Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaKind.java @ 23376:ae27c683c128
Make ResolvedJava* types extend AnnotatedElement.
Contributed-by: Vojin Jovanovic <vojin.jovanovic@oracle.com>
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 06 May 2016 13:21:20 +0200 |
parents | 4b58c92e939b |
children | 1d4ce2d19e52 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22510
diff
changeset
|
2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22612
diff
changeset
|
23 package jdk.vm.ci.meta; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22536
diff
changeset
|
25 import java.lang.reflect.Array; |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
26 |
18679
b7d28233da5d
Add missing //JaCoCo Exclude.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
27 //JaCoCo Exclude |
b7d28233da5d
Add missing //JaCoCo Exclude.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
28 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
30 * Denotes the basic kinds of types in CRI, including the all the Java primitive types, for example, |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
31 * {@link JavaKind#Int} for {@code int} and {@link JavaKind#Object} for all object types. A kind has |
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
32 * a single character short name, a Java name, and a set of flags further describing its behavior. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 */ |
22612
976555bdc7c6
JavaKind is not a PlatformKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22577
diff
changeset
|
34 public enum JavaKind { |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
35 /** The primitive boolean kind, represented as an int on the stack. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
36 Boolean('z', "boolean", 1, true, java.lang.Boolean.TYPE, java.lang.Boolean.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
37 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
38 /** The primitive byte kind, represented as an int on the stack. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
39 Byte('b', "byte", 1, true, java.lang.Byte.TYPE, java.lang.Byte.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
40 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
41 /** The primitive short kind, represented as an int on the stack. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
42 Short('s', "short", 1, true, java.lang.Short.TYPE, java.lang.Short.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
43 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
44 /** The primitive char kind, represented as an int on the stack. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
45 Char('c', "char", 1, true, java.lang.Character.TYPE, java.lang.Character.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
46 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
47 /** The primitive int kind, represented as an int on the stack. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
48 Int('i', "int", 1, true, java.lang.Integer.TYPE, java.lang.Integer.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
49 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
50 /** The primitive float kind. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
51 Float('f', "float", 1, false, java.lang.Float.TYPE, java.lang.Float.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
52 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
53 /** The primitive long kind. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
54 Long('j', "long", 2, false, java.lang.Long.TYPE, java.lang.Long.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
55 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
56 /** The primitive double kind. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
57 Double('d', "double", 2, false, java.lang.Double.TYPE, java.lang.Double.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
58 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
59 /** The Object kind, also used for arrays. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
60 Object('a', "Object", 1, false, null, null), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
61 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
62 /** The void float kind. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
63 Void('v', "void", 0, false, java.lang.Void.TYPE, java.lang.Void.class), |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
64 |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
65 /** The non-type. */ |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
66 Illegal('-', "illegal", 0, false, null, null); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 |
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:
6437
diff
changeset
|
68 private final char typeChar; |
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:
6437
diff
changeset
|
69 private final String javaName; |
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:
6437
diff
changeset
|
70 private final boolean isStackInt; |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
71 private final Class<?> primitiveJavaClass; |
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
72 private final Class<?> boxedJavaClass; |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
73 private final int slotCount; |
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:
6437
diff
changeset
|
74 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
22672
diff
changeset
|
75 JavaKind(char typeChar, String javaName, int slotCount, boolean isStackInt, Class<?> primitiveJavaClass, Class<?> boxedJavaClass) { |
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:
6437
diff
changeset
|
76 this.typeChar = typeChar; |
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:
6437
diff
changeset
|
77 this.javaName = javaName; |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
78 this.slotCount = slotCount; |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
79 this.isStackInt = isStackInt; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
80 this.primitiveJavaClass = primitiveJavaClass; |
13893 | 81 this.boxedJavaClass = boxedJavaClass; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
82 assert primitiveJavaClass == null || javaName.equals(primitiveJavaClass.getName()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 |
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:
6437
diff
changeset
|
85 /** |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
86 * Returns the number of stack slots occupied by this kind according to the Java bytecodes |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
87 * specification. |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
88 */ |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
89 public int getSlotCount() { |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
90 return this.slotCount; |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
91 } |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
92 |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
93 /** |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
94 * Returns whether this kind occupied two stack slots. |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
95 */ |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
96 public boolean needsTwoSlots() { |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
97 return this.slotCount == 2; |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
98 } |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
99 |
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18877
diff
changeset
|
100 /** |
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:
6437
diff
changeset
|
101 * Returns the name of the kind as a single character. |
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:
6437
diff
changeset
|
102 */ |
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:
6437
diff
changeset
|
103 public char getTypeChar() { |
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:
6437
diff
changeset
|
104 return typeChar; |
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:
6437
diff
changeset
|
105 } |
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 /** |
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:
6437
diff
changeset
|
108 * Returns the name of this kind which will also be it Java programming language name if it is |
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:
6437
diff
changeset
|
109 * {@linkplain #isPrimitive() primitive} or {@code void}. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 */ |
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:
6437
diff
changeset
|
111 public String getJavaName() { |
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:
6437
diff
changeset
|
112 return javaName; |
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:
6437
diff
changeset
|
113 } |
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 * Checks whether this type is a Java primitive type. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
117 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
118 * @return {@code true} if this is {@link #Boolean}, {@link #Byte}, {@link #Char}, |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
119 * {@link #Short}, {@link #Int}, {@link #Long}, {@link #Float}, {@link #Double}, or |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
120 * {@link #Void}. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 public boolean isPrimitive() { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
123 return primitiveJavaClass != null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 /** |
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:
6437
diff
changeset
|
127 * Returns the kind that represents this kind when on the Java operand stack. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
128 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 * @return the kind used on the operand stack |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 */ |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
131 public JavaKind getStackKind() { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
132 if (isStackInt) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 return Int; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
138 /** |
12695
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
139 * Checks whether this type is a Java primitive type representing an integer number. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
140 * |
12695
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
141 * @return {@code true} if the stack kind is {@link #Int} or {@link #Long}. |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
142 */ |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
143 public boolean isNumericInteger() { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
144 return isStackInt || this == JavaKind.Long; |
12695
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
145 } |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
146 |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
147 /** |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13966
diff
changeset
|
148 * Checks whether this type is a Java primitive type representing an unsigned number. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
149 * |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13966
diff
changeset
|
150 * @return {@code true} if the kind is {@link #Boolean} or {@link #Char}. |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13966
diff
changeset
|
151 */ |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13966
diff
changeset
|
152 public boolean isUnsigned() { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
153 return this == JavaKind.Boolean || this == JavaKind.Char; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13966
diff
changeset
|
154 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13966
diff
changeset
|
155 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13966
diff
changeset
|
156 /** |
12695
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
157 * Checks whether this type is a Java primitive type representing a floating point number. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
158 * |
12695
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
159 * @return {@code true} if this is {@link #Float} or {@link #Double}. |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
160 */ |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
161 public boolean isNumericFloat() { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
162 return this == JavaKind.Float || this == JavaKind.Double; |
12695
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
163 } |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
164 |
4aec62c32a82
Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents:
9785
diff
changeset
|
165 /** |
14019
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13999
diff
changeset
|
166 * Checks whether this represent an Object of some sort. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
167 * |
14563
82e4fe6fa525
Remove all references to NarrowOop from VM independent code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14019
diff
changeset
|
168 * @return {@code true} if this is {@link #Object}. |
14019
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13999
diff
changeset
|
169 */ |
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13999
diff
changeset
|
170 public boolean isObject() { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
171 return this == JavaKind.Object; |
14019
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13999
diff
changeset
|
172 } |
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13999
diff
changeset
|
173 |
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13999
diff
changeset
|
174 /** |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
175 * Returns the kind corresponding to the Java type string. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
176 * |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
177 * @param typeString the Java type string |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
178 * @return the kind |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
179 */ |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
180 public static JavaKind fromTypeString(String typeString) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 assert typeString.length() > 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 final char first = typeString.charAt(0); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 if (first == '[' || first == 'L') { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
184 return JavaKind.Object; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 } |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
186 return JavaKind.fromPrimitiveOrVoidTypeChar(first); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 /** |
7645
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
190 * Returns the kind of a word given the size of a word in bytes. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
191 * |
7645
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
192 * @param wordSizeInBytes the size of a word in bytes |
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
193 * @return the kind representing a word value |
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
194 */ |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
195 public static JavaKind fromWordSize(int wordSizeInBytes) { |
7645
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
196 if (wordSizeInBytes == 8) { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
197 return JavaKind.Long; |
7645
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
198 } else { |
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
199 assert wordSizeInBytes == 4 : "Unsupported word size!"; |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
200 return JavaKind.Int; |
7645
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
201 } |
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
202 } |
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
203 |
f3fcc94f7120
Clean up and remove TODO.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
204 /** |
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:
6437
diff
changeset
|
205 * Returns the kind from the character describing a primitive or void. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
206 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 * @param ch the character |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 * @return the kind |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 */ |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
210 public static JavaKind fromPrimitiveOrVoidTypeChar(char ch) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 switch (ch) { |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
212 case 'Z': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
213 return Boolean; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
214 case 'C': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
215 return Char; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
216 case 'F': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
217 return Float; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
218 case 'D': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
219 return Double; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
220 case 'B': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
221 return Byte; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
222 case 'S': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
223 return Short; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
224 case 'I': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
225 return Int; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
226 case 'J': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
227 return Long; |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
228 case 'V': |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
229 return Void; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
230 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 throw new IllegalArgumentException("unknown primitive or void type character: " + ch); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
234 /** |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
235 * Returns the Kind representing the given Java class. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
236 * |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
237 * @param klass the class |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
238 * @return the kind |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
239 */ |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
240 public static JavaKind fromJavaClass(Class<?> klass) { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
241 if (klass == Boolean.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
242 return Boolean; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
243 } else if (klass == Byte.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
244 return Byte; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
245 } else if (klass == Short.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
246 return Short; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
247 } else if (klass == Char.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
248 return Char; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
249 } else if (klass == Int.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
250 return Int; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
251 } else if (klass == Long.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
252 return Long; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
253 } else if (klass == Float.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
254 return Float; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
255 } else if (klass == Double.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
256 return Double; |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
257 } else if (klass == Void.primitiveJavaClass) { |
6437
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
258 return Void; |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
259 } else { |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
260 return Object; |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
261 } |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
262 } |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
263 |
8f820c815cc2
Add conversion from java.lang.Class to Kind
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6328
diff
changeset
|
264 /** |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
265 * Returns the Java class representing this kind. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
266 * |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
267 * @return the Java class |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
268 */ |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
269 public Class<?> toJavaClass() { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
270 return primitiveJavaClass; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
271 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
273 /** |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
274 * Returns the Java class for instances of boxed values of this kind. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
275 * |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
276 * @return the Java class |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
277 */ |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
278 public Class<?> toBoxedJavaClass() { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
279 return boxedJavaClass; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 * Converts this value type to a string. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
286 public String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 return javaName; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 /** |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
291 * Marker interface for types that should be {@linkplain JavaKind#format(Object) formatted} with |
13901
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
292 * their {@link Object#toString()} value. Calling {@link Object#toString()} on other objects |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
293 * poses a security risk because it can potentially call user code. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 */ |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
295 public interface FormatWithToString { |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
296 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 /** |
13901
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
299 * Classes for which invoking {@link Object#toString()} does not run user code. |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
300 */ |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
301 private static boolean isToStringSafe(Class<?> c) { |
13901
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
302 return c == Boolean.class || c == Byte.class || c == Character.class || c == Short.class || c == Integer.class || c == Float.class || c == Long.class || c == Double.class; |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
303 } |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
304 |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
305 /** |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 * Gets a formatted string for a given value of this kind. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
307 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 * @param value a value of this kind |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
309 * @return a formatted string for {@code value} based on this kind |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
310 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
311 public String format(Object value) { |
13901
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
312 if (isPrimitive()) { |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
313 assert isToStringSafe(value.getClass()); |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
314 return value.toString(); |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
315 } else { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 if (value == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 return "null"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 if (value instanceof String) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 String s = (String) value; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
321 if (s.length() > 50) { |
5793
6c80d73cf81a
added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents:
5545
diff
changeset
|
322 return "String:\"" + s.substring(0, 30) + "...\""; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 } else { |
5793
6c80d73cf81a
added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents:
5545
diff
changeset
|
324 return "String:\"" + s + '"'; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 } |
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
|
326 } else if (value instanceof JavaType) { |
16479
558cf39c646b
moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents:
16012
diff
changeset
|
327 return "JavaType:" + ((JavaType) value).toJavaName(); |
13901
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
328 } else if (value instanceof Enum) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
329 return MetaUtil.getSimpleName(value.getClass(), true) + ":" + ((Enum<?>) value).name(); |
13901
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
330 } else if (value instanceof FormatWithToString) { |
5793
6c80d73cf81a
added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents:
5545
diff
changeset
|
331 return MetaUtil.getSimpleName(value.getClass(), true) + ":" + String.valueOf(value); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
332 } else if (value instanceof Class<?>) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
333 return "Class:" + ((Class<?>) value).getName(); |
13901
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
334 } else if (isToStringSafe(value.getClass())) { |
45f9dbb93988
modified Kind.format() to avoid calling any user code (JBS:GRAAL-14)
Doug Simon <doug.simon@oracle.com>
parents:
13893
diff
changeset
|
335 return value.toString(); |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
336 } else if (value.getClass().isArray()) { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
337 return formatArray(value); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 } else { |
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
|
339 return MetaUtil.getSimpleName(value.getClass(), true) + "@" + System.identityHashCode(value); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
340 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
345 private static final int MAX_FORMAT_ARRAY_LENGTH = 5; |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
346 |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
347 private static String formatArray(Object array) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
348 Class<?> componentType = array.getClass().getComponentType(); |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
349 assert componentType != null; |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
350 int arrayLength = Array.getLength(array); |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
351 StringBuilder buf = new StringBuilder(MetaUtil.getSimpleName(componentType, true)).append('[').append(arrayLength).append("]{"); |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
352 int length = Math.min(MAX_FORMAT_ARRAY_LENGTH, arrayLength); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
353 boolean primitive = componentType.isPrimitive(); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
354 for (int i = 0; i < length; i++) { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
355 if (primitive) { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
356 buf.append(Array.get(array, i)); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
357 } else { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
358 Object o = ((Object[]) array)[i]; |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
359 buf.append(JavaKind.Object.format(o)); |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
360 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
361 if (i != length - 1) { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
362 buf.append(", "); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
363 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
364 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
365 if (arrayLength != length) { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
366 buf.append(", ..."); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
367 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
368 return buf.append('}').toString(); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
369 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
370 |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
371 /** |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
372 * The minimum value that can be represented as a value of this kind. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
373 * |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
374 * @return the minimum value |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
375 */ |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
376 public long getMinValue() { |
5441
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
377 switch (this) { |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
378 case Boolean: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
379 return 0; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
380 case Byte: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
381 return java.lang.Byte.MIN_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
382 case Char: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
383 return java.lang.Character.MIN_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
384 case Short: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
385 return java.lang.Short.MIN_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
386 case Int: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
387 return java.lang.Integer.MIN_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
388 case Long: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
389 return java.lang.Long.MIN_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
390 default: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
391 throw new IllegalArgumentException("illegal call to minValue on " + this); |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
392 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
393 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
394 |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
395 /** |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
396 * The maximum value that can be represented as a value of this kind. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
397 * |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
398 * @return the maximum value |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
399 */ |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
400 public long getMaxValue() { |
5441
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
401 switch (this) { |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
402 case Boolean: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
403 return 1; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
404 case Byte: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
405 return java.lang.Byte.MAX_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
406 case Char: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
407 return java.lang.Character.MAX_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
408 case Short: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
409 return java.lang.Short.MAX_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
410 case Int: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
411 return java.lang.Integer.MAX_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
412 case Long: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
413 return java.lang.Long.MAX_VALUE; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
414 default: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
415 throw new IllegalArgumentException("illegal call to maxValue on " + this); |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
416 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
417 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
418 |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
419 /** |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
420 * Number of bytes that are necessary to represent a value of this kind. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
421 * |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
422 * @return the number of bytes |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
423 */ |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
424 public int getByteCount() { |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
425 if (this == Boolean) { |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
426 return 1; |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
427 } else { |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
428 return getBitCount() >> 3; |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
429 } |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
430 } |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
431 |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13901
diff
changeset
|
432 /** |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
433 * Number of bits that are necessary to represent a value of this kind. |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
434 * |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
435 * @return the number of bits |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
436 */ |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
437 public int getBitCount() { |
5874
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
438 switch (this) { |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
439 case Boolean: |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
440 return 1; |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
441 case Byte: |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
442 return 8; |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
443 case Char: |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
444 case Short: |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
445 return 16; |
9785
ecd5cd2806e8
Relax assertion for virtual array component kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9422
diff
changeset
|
446 case Float: |
ecd5cd2806e8
Relax assertion for virtual array component kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9422
diff
changeset
|
447 return 32; |
5874
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
448 case Int: |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
449 return 32; |
9785
ecd5cd2806e8
Relax assertion for virtual array component kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9422
diff
changeset
|
450 case Double: |
ecd5cd2806e8
Relax assertion for virtual array component kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9422
diff
changeset
|
451 return 64; |
5874
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
452 case Long: |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
453 return 64; |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
454 default: |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
455 throw new IllegalArgumentException("illegal call to bits on " + this); |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
456 } |
f0d4304243ff
Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5793
diff
changeset
|
457 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
458 } |