Mercurial > hg > truffle
annotate graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiKind.java @ 5467:174eb2b7f6ba
removed leftover debugging code
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 01 Jun 2012 14:07:00 +0200 |
parents | a5e43a18ac52 |
children | d89b20486d87 |
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) 2009, 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 */ |
4199
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
23 package com.oracle.max.cri.ci; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
4199
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
25 import static com.oracle.max.cri.ci.CiKind.Flags.*; |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
26 |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
27 import java.lang.reflect.*; |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
28 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import sun.misc.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 |
4199
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
31 import com.oracle.max.cri.ri.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
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 * Denotes the basic kinds of types in CRI, including the all the Java primitive types, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 * for example, {@link CiKind#Int} for {@code int} and {@link CiKind#Object} |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 * for all object types. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 * A kind has a single character short name, a Java name, and a set of flags |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 * further describing its behavior. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 public enum CiKind { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 Boolean('z', "boolean", FIELD_TYPE | RETURN_TYPE | PRIMITIVE | STACK_INT), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 Byte ('b', "byte", FIELD_TYPE | RETURN_TYPE | PRIMITIVE | STACK_INT), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 Short ('s', "short", FIELD_TYPE | RETURN_TYPE | PRIMITIVE | STACK_INT), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 Char ('c', "char", FIELD_TYPE | RETURN_TYPE | PRIMITIVE | STACK_INT), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 Int ('i', "int", FIELD_TYPE | RETURN_TYPE | PRIMITIVE | STACK_INT), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 Float ('f', "float", FIELD_TYPE | RETURN_TYPE | PRIMITIVE), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 Long ('j', "long", FIELD_TYPE | RETURN_TYPE | PRIMITIVE), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 Double ('d', "double", FIELD_TYPE | RETURN_TYPE | PRIMITIVE), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 Object ('a', "Object", FIELD_TYPE | RETURN_TYPE), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 Void ('v', "void", RETURN_TYPE), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 /** Denote a bytecode address in a {@code JSR} bytecode. */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 Jsr ('r', "jsr", 0), |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 /** The non-type. */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 Illegal('-', "illegal", 0); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 public static final CiKind[] VALUES = values(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 public static final CiKind[] JAVA_VALUES = new CiKind[] {CiKind.Boolean, CiKind.Byte, CiKind.Short, CiKind.Char, CiKind.Int, CiKind.Float, CiKind.Long, CiKind.Double, CiKind.Object}; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 CiKind(char ch, String name, int flags) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 this.typeChar = ch; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 this.javaName = name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 this.flags = flags; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 static class Flags { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 * Can be an object field type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 public static final int FIELD_TYPE = 0x0001; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 * Can be result type of a method. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 public static final int RETURN_TYPE = 0x0002; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 * Behaves as an integer when on Java evaluation stack. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 public static final int STACK_INT = 0x0004; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 * Represents a Java primitive type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 public static final int PRIMITIVE = 0x0008; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 } |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 * The flags for this kind. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 private final int flags; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 * The name of the kind as a single character. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 public final char typeChar; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 * The name of this kind which will also be it Java programming language name if |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 * it is {@linkplain #isPrimitive() primitive} or {@code void}. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 public final String javaName; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 * Checks whether this kind is valid as the type of a field. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 * @return {@code true} if this kind is valid as the type of a Java field |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 public boolean isValidFieldType() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 return (flags & FIELD_TYPE) != 0; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 * Checks whether this kind is valid as the return type of a method. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 * @return {@code true} if this kind is valid as the return type of a Java method |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 public boolean isValidReturnType() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 return (flags & RETURN_TYPE) != 0; |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 * Checks whether this type is valid as an {@code int} on the Java operand stack. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 * @return {@code true} if this type is represented by an {@code int} on the operand stack |
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 public boolean isInt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 return (flags & STACK_INT) != 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 |
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 * Checks whether this type is a Java primitive type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 * @return {@code true} if this is {@link #Boolean}, {@link #Byte}, {@link #Char}, {@link #Short}, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 * {@link #Int}, {@link #Long}, {@link #Float} or {@link #Double}. |
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 public boolean isPrimitive() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 return (flags & PRIMITIVE) != 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 * Gets the kind that represents this kind when on the Java operand stack. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 * @return the kind used on the operand stack |
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 public CiKind stackKind() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 if (isInt()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 return Int; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 public static CiKind fromTypeString(String typeString) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 assert typeString.length() > 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 final char first = typeString.charAt(0); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 if (first == '[' || first == 'L') { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 return CiKind.Object; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 return CiKind.fromPrimitiveOrVoidTypeChar(first); |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 * Gets the kind from the character describing a primitive or void. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 * @param ch the character |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 * @return the kind |
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 public static CiKind fromPrimitiveOrVoidTypeChar(char ch) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 // Checkstyle: stop |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 switch (ch) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 case 'Z': return Boolean; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 case 'C': return Char; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 case 'F': return Float; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 case 'D': return Double; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 case 'B': return Byte; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 case 'S': return Short; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 case 'I': return Int; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 case 'J': return Long; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 case 'V': return Void; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 // Checkstyle: resume |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 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
|
173 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 public Class< ? > toJavaClass() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 // Checkstyle: stop |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 switch(this) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 case Void: return java.lang.Void.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 case Long: return java.lang.Long.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 case Int: return java.lang.Integer.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 case Byte: return java.lang.Byte.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 case Char: return java.lang.Character.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 case Double: return java.lang.Double.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 case Float: return java.lang.Float.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 case Short: return java.lang.Short.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 case Boolean: return java.lang.Boolean.TYPE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 default: return null; |
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 // Checkstyle: resume |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 |
5349
077ec9468516
rename CiKind.toUnboxedJavaClass to toBoxedJavaClass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4468
diff
changeset
|
192 public Class< ? > toBoxedJavaClass() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 // Checkstyle: stop |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 switch(this) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 case Void: return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 case Long: return java.lang.Long.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 case Int: return java.lang.Integer.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 case Byte: return java.lang.Byte.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
199 case Char: return java.lang.Character.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 case Double: return java.lang.Double.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 case Float: return java.lang.Float.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 case Short: return java.lang.Short.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 case Boolean: return java.lang.Boolean.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 default: return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 // Checkstyle: resume |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 * Checks whether this value type is void. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 * @return {@code true} if this type is void |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 public final boolean isVoid() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 return this == CiKind.Void; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 * Checks whether this value type is long. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 * @return {@code true} if this type is long |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 public final boolean isLong() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 return this == CiKind.Long; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 * Checks whether this value type is float. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 * @return {@code true} if this type is float |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 public final boolean isFloat() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
230 return this == CiKind.Float; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 } |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
234 * Checks whether this value type is double. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
235 * @return {@code true} if this type is double |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 public final boolean isDouble() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 return this == CiKind.Double; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
239 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 * Checks whether this value type is float or double. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 * @return {@code true} if this type is float or double |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 public final boolean isFloatOrDouble() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 return this == CiKind.Double || this == CiKind.Float; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
247 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 * Checks whether this value type is an object type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 * @return {@code true} if this type is an object |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
252 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
253 public final boolean isObject() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 return this == CiKind.Object; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
256 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 * Checks whether this value type is an address type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 * @return {@code true} if this type is an address |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 public boolean isJsr() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 return this == CiKind.Jsr; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 * Converts this value type to a string. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 public String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 return javaName; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 * Marker interface for types that should be {@linkplain CiKind#format(Object) formatted} |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 * with their {@link Object#toString()} value. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
276 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 public interface FormatWithToString {} |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 * Gets a formatted string for a given value of this kind. |
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 * @param value a value of this kind |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 * @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
|
284 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 public String format(Object value) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
286 if (isObject()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 if (value == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 return "null"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 if (value instanceof String) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 String s = (String) value; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 if (s.length() > 50) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 return "\"" + s.substring(0, 30) + "...\""; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 return " \"" + s + '"'; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 } else if (value instanceof RiType) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 return "class " + CiUtil.toJavaName((RiType) value); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 } else if (value instanceof Enum || value instanceof FormatWithToString) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 return String.valueOf(value); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 } else if (value instanceof Class< ? >) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 return ((Class< ? >) value).getName() + ".class"; |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
303 } 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
|
304 return formatArray(value); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
305 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 return CiUtil.getSimpleName(value.getClass(), true) + "@" + System.identityHashCode(value); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
307 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
309 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
310 return value.toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
311 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 |
5363
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
314 private static final int MAX_FORMAT_ARRAY_LENGTH = Integer.getInteger("maxFormatArrayLength", 5); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
315 |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
316 private static String formatArray(Object array) { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
317 Class< ? > componentType = array.getClass().getComponentType(); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
318 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
|
319 int arrayLength = Array.getLength(array); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
320 StringBuilder buf = new StringBuilder(CiUtil.getSimpleName(componentType, true)). |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
321 append('['). |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
322 append(arrayLength). |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
323 append("]{"); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
324 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
|
325 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
|
326 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
|
327 if (primitive) { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
328 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
|
329 } else { |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
330 Object o = ((Object[]) array)[i]; |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
331 buf.append(CiKind.Object.format(o)); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
332 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
333 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
|
334 buf.append(", "); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
335 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
336 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
337 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
|
338 buf.append(", ..."); |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
339 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
340 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
|
341 } |
1d760684d958
expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents:
5349
diff
changeset
|
342 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 public final char signatureChar() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 return Character.toUpperCase(typeChar); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
345 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 |
5456
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
347 public final int arrayBaseOffset() { |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
348 switch(this) { |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
349 case Boolean: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
350 return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
351 case Byte: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
352 return Unsafe.ARRAY_BYTE_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
353 case Char: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
354 return Unsafe.ARRAY_CHAR_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
355 case Short: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
356 return Unsafe.ARRAY_SHORT_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
357 case Int: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
358 return Unsafe.ARRAY_INT_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
359 case Long: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
360 return Unsafe.ARRAY_LONG_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
361 case Float: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
362 return Unsafe.ARRAY_FLOAT_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
363 case Double: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
364 return Unsafe.ARRAY_DOUBLE_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
365 case Object: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
366 return Unsafe.ARRAY_OBJECT_BASE_OFFSET; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
367 default: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
368 assert false : "unexpected kind: " + this; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
369 return -1; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
370 } |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
371 } |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
372 |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
373 public final int arrayIndexScale() { |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
374 switch(this) { |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
375 case Boolean: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
376 return Unsafe.ARRAY_BOOLEAN_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
377 case Byte: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
378 return Unsafe.ARRAY_BYTE_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
379 case Char: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
380 return Unsafe.ARRAY_CHAR_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
381 case Short: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
382 return Unsafe.ARRAY_SHORT_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
383 case Int: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
384 return Unsafe.ARRAY_INT_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
385 case Long: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
386 return Unsafe.ARRAY_LONG_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
387 case Float: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
388 return Unsafe.ARRAY_FLOAT_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
389 case Double: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
390 return Unsafe.ARRAY_DOUBLE_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
391 case Object: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
392 return Unsafe.ARRAY_OBJECT_INDEX_SCALE; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
393 default: |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
394 assert false : "unexpected kind: " + this; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
395 return -1; |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
396 } |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
397 } |
a5e43a18ac52
added computation of array base offset and index scaling into CiKind and used it to remove a hard coded assumption in canonicalization of LoadIndexedNode
Doug Simon <doug.simon@oracle.com>
parents:
5441
diff
changeset
|
398 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
399 public CiConstant readUnsafeConstant(Object value, long displacement) { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4199
diff
changeset
|
400 assert value != null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 Unsafe u = Unsafe.getUnsafe(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
402 switch(this) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
403 case Boolean: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 return CiConstant.forBoolean(u.getBoolean(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 case Byte: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 return CiConstant.forByte(u.getByte(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
407 case Char: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
408 return CiConstant.forChar(u.getChar(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
409 case Short: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 return CiConstant.forShort(u.getShort(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
411 case Int: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
412 return CiConstant.forInt(u.getInt(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
413 case Long: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
414 return CiConstant.forLong(u.getLong(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
415 case Float: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
416 return CiConstant.forFloat(u.getFloat(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 case Double: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 return CiConstant.forDouble(u.getDouble(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 case Object: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 return CiConstant.forObject(u.getObject(value, displacement)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
421 default: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
422 assert false : "unexpected kind: " + this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
423 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
424 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
425 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
426 |
5441
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
427 public long minValue() { |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
428 switch (this) { |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
429 case Boolean: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
430 return 0; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
431 case Byte: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
432 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
|
433 case Char: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
434 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
|
435 case Short: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
436 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
|
437 case Jsr: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
438 case Int: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
439 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
|
440 case Long: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
441 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
|
442 default: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
443 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
|
444 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
445 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
446 |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
447 public long maxValue() { |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
448 switch (this) { |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
449 case Boolean: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
450 return 1; |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
451 case Byte: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
452 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
|
453 case Char: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
454 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
|
455 case Short: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
456 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
|
457 case Jsr: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
458 case Int: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
459 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
|
460 case Long: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
461 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
|
462 default: |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
463 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
|
464 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
465 } |
ab31310d4af9
CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents:
5363
diff
changeset
|
466 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 } |