Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/VirtualObject.java @ 21788:c1610658bba0
fixed regression causing mx not to install jars into $(SHARED_DIR)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 08 Jun 2015 20:24:05 +0200 |
parents | f5b549811bac |
children |
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 */ |
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 /** |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
35 * 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
|
36 * 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
|
37 * object. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 */ |
18319
56cc1a799a60
(re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18189
diff
changeset
|
39 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
|
40 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
41 private final ResolvedJavaType type; |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
42 private Value[] values; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 private final int id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7060
diff
changeset
|
46 * 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
|
47 * {@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
|
48 * 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
|
49 * {@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
|
50 * length. |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14160
diff
changeset
|
51 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7060
diff
changeset
|
52 * @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
|
53 * 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
|
54 * @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
|
55 * recreated |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7060
diff
changeset
|
56 * @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
|
57 * position in the compiled code. |
5774
a1db0ea58b53
Removed left over Ci* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5550
diff
changeset
|
58 * @return a new {@link VirtualObject} instance. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 */ |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
60 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
|
61 return new VirtualObject(type, values, id); |
3733
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 |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
64 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:
14160
diff
changeset
|
65 super(LIRKind.reference(Kind.Object)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 this.type = type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 this.values = values; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 this.id = id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
71 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
|
72 if (value instanceof VirtualObject) { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
73 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
|
74 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
|
75 if (!visited.contains(vo)) { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
76 visited.add(vo); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
77 buf.append('{'); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
78 if (vo.values == null) { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
79 buf.append("<uninitialized>"); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
80 } else { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
81 if (vo.type.isArray()) { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
82 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
|
83 if (i != 0) { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
84 buf.append(','); |
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 buf.append(i).append('='); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
87 appendValue(buf, vo.values[i], visited); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
88 } |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
89 } else { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
90 ResolvedJavaField[] fields = vo.type.getInstanceFields(true); |
14157 | 91 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
|
92 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
|
93 if (i != 0) { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
94 buf.append(','); |
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 buf.append(fields[i].getName()).append('='); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
97 appendValue(buf, vo.values[i], visited); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
98 } |
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 buf.append('}'); |
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 } else { |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
104 buf.append(value); |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
105 } |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
106 return buf; |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
107 } |
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
108 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 @Override |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
110 public String toString() { |
8289
59bd299750a8
fixed StackOverflowError in VirtualObject.toString()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
111 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
|
112 return appendValue(new StringBuilder(), this, visited).toString(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 } |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7060
diff
changeset
|
116 * 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
|
117 * either an instance of an array type. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 */ |
6959
9c71ad0a0652
extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
119 public ResolvedJavaType getType() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 return type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 /** |
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
|
124 * 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
|
125 */ |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
126 public Value[] getValues() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 return values; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7060
diff
changeset
|
131 * 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
|
132 * position in the compiled code. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 */ |
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
|
134 public int getId() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 return id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
138 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
|
139 if (values != null) { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
6959
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 Kind valKind = values[i].getKind().getStackKind(); |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
146 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
|
147 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
|
148 } else { |
16584
ab84673bedc2
change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16530
diff
changeset
|
149 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
|
150 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
|
151 fieldIndex++; |
ab84673bedc2
change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16530
diff
changeset
|
152 } else { |
ab84673bedc2
change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16530
diff
changeset
|
153 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
|
154 } |
12617
bca33c3135de
PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents:
9785
diff
changeset
|
155 } |
6959
9c71ad0a0652
extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
156 } |
12617
bca33c3135de
PEA: support for unsafe stores of mismatching sizes, cleanup, documentation
Lukas Stadler <lukas.stadler@jku.at>
parents:
9785
diff
changeset
|
157 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
|
158 } else { |
9c71ad0a0652
extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
159 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
|
160 if (componentKind == Kind.Object) { |
ab84673bedc2
change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16530
diff
changeset
|
161 for (int i = 0; i < values.length; i++) { |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
162 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
|
163 } |
ab84673bedc2
change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16530
diff
changeset
|
164 } else { |
ab84673bedc2
change assertions in VirtualObject to look at the LIRKind
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16530
diff
changeset
|
165 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
|
166 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
|
167 (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
|
168 } |
6959
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 } |
9c71ad0a0652
extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
172 return true; |
9c71ad0a0652
extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
173 } |
9c71ad0a0652
extra assertion checking when initializing the values of a VirtualObject
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
174 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 * 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
|
177 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7060
diff
changeset
|
178 * @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
|
179 * recreated. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 */ |
19662
f595e97626fd
Use Value instead of JavaValue in BytecodeFrame and VirtualObject
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18319
diff
changeset
|
181 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
|
182 assert checkValues(type, values); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 this.values = values; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 public int hashCode() { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14160
diff
changeset
|
188 return getLIRKind().hashCode() + type.hashCode(); |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 public boolean equals(Object o) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 if (o == this) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 } |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 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
|
202 /* |
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 * 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
|
204 * 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
|
205 */ |
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 if (!same(values[i], l.values[i])) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 } |
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
|
214 |
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 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
|
216 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
|
217 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 } |