annotate graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/VirtualObject.java @ 21561:ce2113326bc8

Merge.
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 May 2015 17:13:22 +0200
parents 48c1ebd24120
children f5b549811bac
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: 14158
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 */
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
23 package com.oracle.jvmci.code;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
25 import com.oracle.jvmci.meta.ResolvedJavaField;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
26 import com.oracle.jvmci.meta.JavaValue;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
27 import com.oracle.jvmci.meta.Kind;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
28 import com.oracle.jvmci.meta.AbstractValue;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
29 import com.oracle.jvmci.meta.Value;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
30 import com.oracle.jvmci.meta.ResolvedJavaType;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
31 import com.oracle.jvmci.meta.LIRKind;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
32 import java.util.*;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
33
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 /**
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
36 * 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
37 * 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
38 * object.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 */
18319
56cc1a799a60 (re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18189
diff changeset
40 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
41
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
42 private final ResolvedJavaType type;
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
43 private Value[] values;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 private final int id;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
47 * 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
48 * {@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
49 * 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
50 * {@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
51 * length.
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14158
diff changeset
52 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
53 * @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
54 * 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
55 * @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
56 * recreated
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
57 * @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
58 * position in the compiled code.
5774
a1db0ea58b53 Removed left over Ci* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5550
diff changeset
59 * @return a new {@link VirtualObject} instance.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 */
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
61 public static VirtualObject get(ResolvedJavaType type, Value[] 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
62 return new VirtualObject(type, values, id);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
65 private VirtualObject(ResolvedJavaType type, Value[] values, int id) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14158
diff changeset
66 super(LIRKind.reference(Kind.Object));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 this.type = type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 this.values = values;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 this.id = id;
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
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
72 private static StringBuilder appendValue(StringBuilder buf, Value value, Set<VirtualObject> visited) {
8289
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
73 if (value instanceof VirtualObject) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
74 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
75 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
76 if (!visited.contains(vo)) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
77 visited.add(vo);
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
78 buf.append('{');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
79 if (vo.values == null) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
80 buf.append("<uninitialized>");
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
81 } else {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
82 if (vo.type.isArray()) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
83 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
84 if (i != 0) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
85 buf.append(',');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
86 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
87 buf.append(i).append('=');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
88 appendValue(buf, vo.values[i], visited);
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
89 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
90 } else {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
91 ResolvedJavaField[] fields = vo.type.getInstanceFields(true);
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 12617
diff changeset
92 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
93 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
94 if (i != 0) {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
95 buf.append(',');
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 buf.append(fields[i].getName()).append('=');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
98 appendValue(buf, vo.values[i], visited);
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 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
101 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
102 buf.append('}');
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
103 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
104 } else {
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
105 buf.append(value);
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
106 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
107 return buf;
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
108 }
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
109
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 @Override
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
111 public String toString() {
8289
59bd299750a8 fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
112 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
113 return appendValue(new StringBuilder(), this, visited).toString();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
117 * 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
118 * either an instance of an array type.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 */
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
120 public ResolvedJavaType getType() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 return type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 /**
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
125 * 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
126 */
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
127 public Value[] getValues() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 return values;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
132 * 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
133 * position in the compiled code.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 */
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
135 public int getId() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 return id;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
139 private static boolean checkValues(ResolvedJavaType type, Value[] values) {
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
140 if (values != null) {
7060
06d5f450f32b rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents: 6959
diff changeset
141 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
142 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
143 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
144 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
145 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
146 Kind valKind = values[i].getKind().getStackKind();
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
147 if (field.getKind() == Kind.Object) {
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
148 assert 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
149 } else {
16584
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
150 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
151 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
152 fieldIndex++;
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
153 } else {
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
154 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
155 }
12617
bca33c3135de PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents: 9785
diff changeset
156 }
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
157 }
12617
bca33c3135de PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents: 9785
diff changeset
158 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
159 } else {
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
160 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
161 if (componentKind == Kind.Object) {
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
162 for (int i = 0; i < values.length; i++) {
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
163 assert values[i].getLIRKind().isReference(0) : 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
164 }
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
165 } else {
ab84673bedc2 change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16530
diff changeset
166 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
167 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
168 (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
169 }
6959
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 }
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 return true;
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
174 }
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
175
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 * 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: 14158
diff changeset
178 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7060
diff changeset
179 * @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
180 * recreated.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 */
19669
f595e97626fd Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18319
diff changeset
182 public void setValues(Value[] values) {
6959
9c71ad0a0652 extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
183 assert checkValues(type, values);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 this.values = values;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 }
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 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 public int hashCode() {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14158
diff changeset
189 return getLIRKind().hashCode() + type.hashCode();
3733
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 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 public boolean equals(Object o) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 if (o == this) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 }
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
197 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
198 VirtualObject l = (VirtualObject) o;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
199 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
200 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 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
203 /*
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 * 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
205 * 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
206 */
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
207 if (!same(values[i], l.values[i])) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 }
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
215
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 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
217 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
218 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 }