annotate graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java @ 18734:61b6c57421c2

Add cast to void to fix compilation warning. Contributed-by: vladimir.kozlov@oracle.com
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Fri, 19 Dec 2014 12:44:00 -0800
parents 56cc1a799a60
children f595e97626fd
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 /*
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14160
diff changeset
2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
23 package com.oracle.graal.api.code;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
25 import java.util.*;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
26
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
27 import com.oracle.graal.api.meta.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 /**
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
30 * An instance of this class represents an object whose allocation was removed by escape analysis.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
31 * The information stored in the {@link VirtualObject} is used during deoptimization to recreate the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
32 * object.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 */
18319
56cc1a799a60 (re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18189
diff changeset
34 public final class VirtualObject extends AbstractValue implements JavaValue {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
35
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
36 private static final long serialVersionUID = -2907197776426346021L;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
38 private final ResolvedJavaType type;
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
39 private JavaValue[] values;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 private final int id;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
43 * Creates a new {@link VirtualObject} for the given type, with the given fields. If
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
44 * {@code type} is an instance class then {@code values} provides the values for the fields
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
45 * returned by {@link ResolvedJavaType#getInstanceFields(boolean) getInstanceFields(true)}. If
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
46 * {@code type} is an array then the length of the values array determines the reallocated array
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
47 * length.
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14160
diff changeset
48 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
49 * @param type the type of the object whose allocation was removed during compilation. This can
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
50 * be either an instance of an array type.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
51 * @param values an array containing all the values to be stored into the object when it is
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
52 * recreated
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
53 * @param id a unique id that identifies the object within the debug information for one
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
54 * position in the compiled code.
5774
a1db0ea58b53 Removed left over Ci* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5550
diff changeset
55 * @return a new {@link VirtualObject} instance.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 */
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
57 public static VirtualObject get(ResolvedJavaType type, JavaValue[] values, int id) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
58 return new VirtualObject(type, values, id);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
61 private VirtualObject(ResolvedJavaType type, JavaValue[] values, int id) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14160
diff changeset
62 super(LIRKind.reference(Kind.Object));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 this.type = type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 this.values = values;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 this.id = id;
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
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
68 private static StringBuilder appendValue(StringBuilder buf, JavaValue value, Set<VirtualObject> visited) {
8289
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
69 if (value instanceof VirtualObject) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
70 VirtualObject vo = (VirtualObject) value;
16478
1f1ac8857d92 moved toJavaName(JavaType type, boolean qualified) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 16094
diff changeset
71 buf.append("vobject:").append(vo.type.toJavaName(false)).append(':').append(vo.id);
8289
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
72 if (!visited.contains(vo)) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
73 visited.add(vo);
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
74 buf.append('{');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
75 if (vo.values == null) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
76 buf.append("<uninitialized>");
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
77 } else {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
78 if (vo.type.isArray()) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
79 for (int i = 0; i < vo.values.length; i++) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
80 if (i != 0) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
81 buf.append(',');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
82 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
83 buf.append(i).append('=');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
84 appendValue(buf, vo.values[i], visited);
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
85 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
86 } else {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
87 ResolvedJavaField[] fields = vo.type.getInstanceFields(true);
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 12617
diff changeset
88 assert fields.length == vo.values.length : vo.type + ", fields=" + Arrays.toString(fields) + ", values=" + Arrays.toString(vo.values);
8289
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
89 for (int i = 0; i < vo.values.length; i++) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
90 if (i != 0) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
91 buf.append(',');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
92 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
93 buf.append(fields[i].getName()).append('=');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
94 appendValue(buf, vo.values[i], visited);
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
95 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
96 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
97 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
98 buf.append('}');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
99 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
100 } else {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
101 buf.append(value);
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
102 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
103 return buf;
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
104 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
105
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 @Override
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
107 public String toString() {
8289
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
108 Set<VirtualObject> visited = Collections.newSetFromMap(new IdentityHashMap<VirtualObject, Boolean>());
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
109 return appendValue(new StringBuilder(), this, visited).toString();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
113 * Returns the type of the object whose allocation was removed during compilation. This can be
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
114 * either an instance of an array type.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 */
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
116 public ResolvedJavaType getType() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 return type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 }
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 /**
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
121 * Returns an array containing all the values to be stored into the object when it is recreated.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 */
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
123 public JavaValue[] getValues() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 return values;
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
128 * Returns the unique id that identifies the object within the debug information for one
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
129 * position in the compiled code.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 */
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
131 public int getId() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 return id;
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
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
135 private static boolean checkValues(ResolvedJavaType type, JavaValue[] values) {
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
136 if (values != null) {
7060
06d5f450f32b rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents: 6959
diff changeset
137 if (!type.isArray()) {
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
138 ResolvedJavaField[] fields = type.getInstanceFields(true);
12617
bca33c3135de PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents: 9785
diff changeset
139 int fieldIndex = 0;
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
140 for (int i = 0; i < values.length; i++) {
12617
bca33c3135de PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents: 9785
diff changeset
141 ResolvedJavaField field = fields[fieldIndex++];
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
142 Kind valKind = values[i].getKind().getStackKind();
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
143 if (field.getKind() == Kind.Object && values[i] instanceof Value) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
144 assert ((Value) values[i]).getLIRKind().isReference(0) : field + ": " + valKind + " != " + field.getKind();
12617
bca33c3135de PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents: 9785
diff changeset
145 } else {
16584
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
146 if ((valKind == Kind.Double || valKind == Kind.Long) && field.getKind() == Kind.Int) {
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
147 assert fields[fieldIndex].getKind() == Kind.Int;
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
148 fieldIndex++;
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
149 } else {
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
150 assert valKind == field.getKind().getStackKind() : field + ": " + valKind + " != " + field.getKind();
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
151 }
12617
bca33c3135de PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents: 9785
diff changeset
152 }
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
153 }
12617
bca33c3135de PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents: 9785
diff changeset
154 assert fields.length == fieldIndex : type + ": fields=" + Arrays.toString(fields) + ", field values=" + Arrays.toString(values);
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
155 } else {
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
156 Kind componentKind = type.getComponentType().getKind().getStackKind();
16584
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
157 if (componentKind == Kind.Object) {
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
158 for (int i = 0; i < values.length; i++) {
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
159 if (values[i] instanceof Value) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
160 assert ((Value) values[i]).getLIRKind().isReference(0) : values[i].getKind() + " != " + componentKind;
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
161 }
16584
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
162 }
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
163 } else {
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
164 for (int i = 0; i < values.length; i++) {
18111
03259118b81b Truffle: relax assertions for object state entries of int kind
Andreas Woess <andreas.woess@jku.at>
parents: 17446
diff changeset
165 assert values[i].getKind() == componentKind || componentKind.getBitCount() >= values[i].getKind().getBitCount() ||
03259118b81b Truffle: relax assertions for object state entries of int kind
Andreas Woess <andreas.woess@jku.at>
parents: 17446
diff changeset
166 (componentKind == Kind.Int && values[i].getKind().getBitCount() >= Kind.Int.getBitCount()) : values[i].getKind() + " != " + componentKind;
16584
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
167 }
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
168 }
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
169 }
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
170 }
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
171 return true;
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
172 }
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
173
3733
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 * Overwrites the current set of values with a new one.
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14160
diff changeset
176 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
177 * @param values an array containing all the values to be stored into the object when it is
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
178 * recreated.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 */
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
180 public void setValues(JavaValue[] values) {
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
181 assert checkValues(type, values);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 this.values = values;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 public int hashCode() {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14160
diff changeset
187 return getLIRKind().hashCode() + type.hashCode();
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 public boolean equals(Object o) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 if (o == this) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 }
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
195 if (o instanceof VirtualObject) {
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
196 VirtualObject l = (VirtualObject) o;
14160
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
197 if (!l.type.equals(type) || l.values.length != values.length) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 return false;
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 for (int i = 0; i < values.length; i++) {
16530
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
201 /*
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
202 * Virtual objects can form cycles. Calling equals() could therefore lead to
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
203 * infinite recursion.
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
204 */
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
205 if (!same(values[i], l.values[i])) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 return false;
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 return true;
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 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 }
16530
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
213
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
214 private static boolean same(Object o1, Object o2) {
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
215 return o1 == o2;
6694631668a6 Avoid infinite recursion of deep equals checks, but also satisfy the automatic checking that does not allow == on values
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16478
diff changeset
216 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217 }