annotate graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java @ 6313:7ac010ae8c97

Add inferStamp for a number of ConvertNode's operations
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 04 Sep 2012 17:10:42 +0200
parents f0d4304243ff
children 6e66d97a16ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
23 package com.oracle.graal.api.meta;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
25 import static com.oracle.graal.api.meta.Kind.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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 * Denotes the basic kinds of types in CRI, including the all the Java primitive types,
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
33 * for example, {@link Kind#Int} for {@code int} and {@link Kind#Object}
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 * for all object types.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 * 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
36 * further describing its behavior.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 */
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
38 public enum Kind {
5545
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
39 Boolean('z', "boolean", PRIMITIVE | STACK_INT),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
40 Byte ('b', "byte", PRIMITIVE | STACK_INT),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
41 Short ('s', "short", PRIMITIVE | STACK_INT),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
42 Char ('c', "char", PRIMITIVE | STACK_INT),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
43 Int ('i', "int", PRIMITIVE | STACK_INT),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
44 Float ('f', "float", PRIMITIVE),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
45 Long ('j', "long", PRIMITIVE),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
46 Double ('d', "double", PRIMITIVE),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
47 Object ('a', "Object", 0),
65f832e7476b Further clean up on api.meta project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
48 Void ('v', "void", 0),
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 /** 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
50 Jsr ('r', "jsr", 0),
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 /** The non-type. */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 Illegal('-', "illegal", 0);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
54 public static final Kind[] VALUES = values();
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
55 public static final Kind[] JAVA_VALUES = new Kind[] {Kind.Boolean, Kind.Byte, Kind.Short, Kind.Char, Kind.Int, Kind.Float, Kind.Long, Kind.Double, Kind.Object};
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
57 Kind(char ch, String name, int flags) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 this.typeChar = ch;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 this.javaName = name;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 this.flags = flags;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 static class Flags {
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 * 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
66 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 public static final int STACK_INT = 0x0004;
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 * Represents a Java primitive type.
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 public static final int PRIMITIVE = 0x0008;
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
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 * The flags for this kind.
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 private final int flags;
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 * 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
81 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 public final char typeChar;
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 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
86 * it is {@linkplain #isPrimitive() primitive} or {@code void}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 public final String javaName;
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 * 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
92 * @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
93 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 public boolean isInt() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 return (flags & STACK_INT) != 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 }
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 * 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
100 * @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
101 * {@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
102 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 public boolean isPrimitive() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 return (flags & PRIMITIVE) != 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 }
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 * 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
109 * @return the kind used on the operand stack
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 */
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
111 public Kind stackKind() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 if (isInt()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 return Int;
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 return this;
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
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
118 public static Kind fromTypeString(String typeString) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 assert typeString.length() > 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 final char first = typeString.charAt(0);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 if (first == '[' || first == 'L') {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
122 return Kind.Object;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 }
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
124 return Kind.fromPrimitiveOrVoidTypeChar(first);
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 * 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
129 * @param ch the character
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 * @return the kind
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 */
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
132 public static Kind fromPrimitiveOrVoidTypeChar(char ch) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 // Checkstyle: stop
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 switch (ch) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 case 'Z': return Boolean;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 case 'C': return Char;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 case 'F': return Float;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 case 'D': return Double;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 case 'B': return Byte;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 case 'S': return Short;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 case 'I': return Int;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 case 'J': return Long;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 case 'V': return Void;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 // Checkstyle: resume
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 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
147 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 public Class< ? > toJavaClass() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 // Checkstyle: stop
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 switch(this) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 case Void: return java.lang.Void.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 case Long: return java.lang.Long.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 case Int: return java.lang.Integer.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 case Byte: return java.lang.Byte.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 case Char: return java.lang.Character.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 case Double: return java.lang.Double.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 case Float: return java.lang.Float.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 case Short: return java.lang.Short.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 case Boolean: return java.lang.Boolean.TYPE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161 default: return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 // Checkstyle: resume
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165
5349
077ec9468516 rename CiKind.toUnboxedJavaClass to toBoxedJavaClass
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4468
diff changeset
166 public Class< ? > toBoxedJavaClass() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 // Checkstyle: stop
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 switch(this) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 case Void: return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 case Long: return java.lang.Long.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 case Int: return java.lang.Integer.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 case Byte: return java.lang.Byte.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 case Char: return java.lang.Character.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 case Double: return java.lang.Double.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 case Float: return java.lang.Float.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 case Short: return java.lang.Short.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 case Boolean: return java.lang.Boolean.class;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 default: return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 // Checkstyle: resume
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 * Checks whether this value type is void.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 * @return {@code true} if this type is void
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 public final boolean isVoid() {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
188 return this == Kind.Void;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 * Checks whether this value type is long.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 * @return {@code true} if this type is long
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 public final boolean isLong() {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
196 return this == Kind.Long;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 * Checks whether this value type is float.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 * @return {@code true} if this type is float
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 public final boolean isFloat() {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
204 return this == Kind.Float;
3733
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
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 * Checks whether this value type is double.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 * @return {@code true} if this type is double
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 public final boolean isDouble() {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
212 return this == Kind.Double;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214
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 * 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
217 * @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
218 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 public final boolean isFloatOrDouble() {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
220 return this == Kind.Double || this == Kind.Float;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222
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 * 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
225 * @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
226 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 public final boolean isObject() {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
228 return this == Kind.Object;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 }
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 * 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
233 * @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
234 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235 public boolean isJsr() {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
236 return this == Kind.Jsr;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238
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 * Converts this value type to a string.
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 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 return javaName;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 /**
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
248 * Marker interface for types that should be {@linkplain Kind#format(Object) formatted}
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 * with their {@link Object#toString()} value.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 public interface FormatWithToString {}
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 * 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
255 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 * @param value a value of this kind
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257 * @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
258 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 public String format(Object value) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 if (isObject()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 if (value == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 return "null";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 if (value instanceof String) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265 String s = (String) value;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 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
267 return "String:\"" + s.substring(0, 30) + "...\"";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 } 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
269 return "String:\"" + s + '"';
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
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
271 } else if (value instanceof JavaType) {
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
272 return "JavaType:" + MetaUtil.toJavaName((JavaType) value);
6c80d73cf81a added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents: 5545
diff changeset
273 } else if (value instanceof Enum || value instanceof FormatWithToString || value instanceof Number) {
6c80d73cf81a added prefix to formatted object Constants to denote the type of the constant
Doug Simon <doug.simon@oracle.com>
parents: 5545
diff changeset
274 return MetaUtil.getSimpleName(value.getClass(), true) + ":" + String.valueOf(value);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 } else if (value instanceof Class< ? >) {
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
276 return "Class:" + ((Class< ? >) value).getName();
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
277 } 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
278 return formatArray(value);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 } 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
280 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
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 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 return value.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
288 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
289
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
290 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
291 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
292 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
293 int arrayLength = Array.getLength(array);
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
294 StringBuilder buf = new StringBuilder(MetaUtil.getSimpleName(componentType, true)).
5363
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
295 append('[').
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
296 append(arrayLength).
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
297 append("]{");
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
298 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
299 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
300 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
301 if (primitive) {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
302 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
303 } else {
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
304 Object o = ((Object[]) array)[i];
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
305 buf.append(Kind.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
306 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
307 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
308 buf.append(", ");
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
309 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
310 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
311 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
312 buf.append(", ...");
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
313 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
314 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
315 }
1d760684d958 expanded formatting of array CiConstants to show contents of the array
Doug Simon <doug.simon@oracle.com>
parents: 5349
diff changeset
316
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 public final char signatureChar() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 return Character.toUpperCase(typeChar);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320
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
321 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
322 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
323 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
324 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
325 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
326 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
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343 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
344 }
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
345 }
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
346
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 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
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_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
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_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
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_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
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_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
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_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
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_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
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_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
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_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
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_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
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
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
373 public Constant readUnsafeConstant(Object value, long displacement) {
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4199
diff changeset
374 assert value != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 Unsafe u = Unsafe.getUnsafe();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 switch(this) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 case Boolean:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
378 return Constant.forBoolean(u.getBoolean(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 case Byte:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
380 return Constant.forByte(u.getByte(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 case Char:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
382 return Constant.forChar(u.getChar(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 case Short:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
384 return Constant.forShort(u.getShort(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385 case Int:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
386 return Constant.forInt(u.getInt(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 case Long:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
388 return Constant.forLong(u.getLong(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 case Float:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
390 return Constant.forFloat(u.getFloat(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 case Double:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
392 return Constant.forDouble(u.getDouble(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 case Object:
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
394 return Constant.forObject(u.getObject(value, displacement));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 default:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396 assert false : "unexpected kind: " + this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400
5441
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
401 public long minValue() {
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
402 switch (this) {
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
403 case Boolean:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
404 return 0;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
405 case Byte:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
406 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
407 case Char:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
408 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
409 case Short:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
410 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
411 case Jsr:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
412 case Int:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
413 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
414 case Long:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
415 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
416 default:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
417 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
418 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
419 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
420
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
421 public long maxValue() {
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
422 switch (this) {
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
423 case Boolean:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
424 return 1;
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
425 case Byte:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
426 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
427 case Char:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
428 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
429 case Short:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
430 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
431 case Jsr:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
432 case Int:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
433 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
434 case Long:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
435 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
436 default:
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
437 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
438 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
439 }
ab31310d4af9 CiKind.minValue and CiKind.maxValue for integer types
Lukas Stadler <lukas.stadler@jku.at>
parents: 5363
diff changeset
440
5874
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
441 public int bits() {
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
442 switch (this) {
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
443 case Boolean:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
444 return 1;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
445 case Byte:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
446 return 8;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
447 case Char:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
448 case Short:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
449 return 16;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
450 case Jsr:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
451 case Int:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
452 return 32;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
453 case Long:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
454 return 64;
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
455 default:
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
456 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
457 }
f0d4304243ff Add intrinsics for (Long|Integer).(reverseBytes|numberOf(Trail|Lead)ingZeros)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5793
diff changeset
458 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 }