author | rschatz |
Thu, 16 Jun 2016 16:41:50 +0000 | |
changeset 39423 | 0f8dc3693499 |
parent 38692 | 54a84b7f3721 |
child 39450 | 78e99b030d5f |
permissions | -rw-r--r-- |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
1 |
/* |
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
4 |
* |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
8 |
* |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
13 |
* accompanied this code). |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
14 |
* |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
18 |
* |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
21 |
* questions. |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
22 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
23 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
24 |
/** |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
25 |
* @test |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
26 |
* @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" |
36508 | 27 |
* @library / |
28 |
* @modules jdk.vm.ci/jdk.vm.ci.hotspot |
|
29 |
* jdk.vm.ci/jdk.vm.ci.meta |
|
30 |
* jdk.vm.ci/jdk.vm.ci.code |
|
31 |
* jdk.vm.ci/jdk.vm.ci.code.site |
|
32 |
* jdk.vm.ci/jdk.vm.ci.runtime |
|
33 |
* jdk.vm.ci/jdk.vm.ci.amd64 |
|
34 |
* jdk.vm.ci/jdk.vm.ci.sparc |
|
39423
0f8dc3693499
8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents:
38692
diff
changeset
|
35 |
* @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java |
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
36 |
* @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.VirtualObjectDebugInfoTest |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
37 |
*/ |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
38 |
|
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
39 |
package jdk.vm.ci.code.test; |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
40 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
41 |
import java.util.ArrayList; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
42 |
import java.util.Objects; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
43 |
|
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
44 |
import org.junit.Assert; |
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
45 |
import org.junit.Test; |
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
46 |
|
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
47 |
import jdk.vm.ci.code.Register; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
48 |
import jdk.vm.ci.code.VirtualObject; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
49 |
import jdk.vm.ci.hotspot.HotSpotConstant; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
50 |
import jdk.vm.ci.meta.JavaConstant; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
51 |
import jdk.vm.ci.meta.JavaKind; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
52 |
import jdk.vm.ci.meta.JavaValue; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
53 |
import jdk.vm.ci.meta.ResolvedJavaField; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
54 |
import jdk.vm.ci.meta.ResolvedJavaType; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
55 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
56 |
public class VirtualObjectDebugInfoTest extends DebugInfoTest { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
57 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
58 |
private static class TestClass { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
59 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
60 |
private long longField; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
61 |
private int intField; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
62 |
private float floatField; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
63 |
private Object[] arrayField; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
64 |
|
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
65 |
TestClass() { |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
66 |
this.longField = 8472; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
67 |
this.intField = 42; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
68 |
this.floatField = 3.14f; |
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
69 |
this.arrayField = new Object[]{Integer.valueOf(58), this, null, Integer.valueOf(17), "Hello, World!"}; |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
70 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
71 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
72 |
@Override |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
73 |
public boolean equals(Object o) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
74 |
if (!(o instanceof TestClass)) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
75 |
return false; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
76 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
77 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
78 |
TestClass other = (TestClass) o; |
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
79 |
if (this.longField != other.longField || this.intField != other.intField || this.floatField != other.floatField || this.arrayField.length != other.arrayField.length) { |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
80 |
return false; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
81 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
82 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
83 |
for (int i = 0; i < this.arrayField.length; i++) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
84 |
// break cycle |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
85 |
if (this.arrayField[i] == this && other.arrayField[i] == other) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
86 |
continue; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
87 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
88 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
89 |
if (!Objects.equals(this.arrayField[i], other.arrayField[i])) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
90 |
return false; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
91 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
92 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
93 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
94 |
return true; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
95 |
} |
38027
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
96 |
|
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
97 |
@Override |
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
98 |
public int hashCode() { |
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
99 |
return super.hashCode(); |
8a5693d27400
8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents:
36508
diff
changeset
|
100 |
} |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
101 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
102 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
103 |
public static TestClass buildObject() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
104 |
return new TestClass(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
105 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
106 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
107 |
private VirtualObject[] compileBuildObject(TestAssembler asm, JavaValue[] values) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
108 |
TestClass template = new TestClass(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
109 |
ArrayList<VirtualObject> vobjs = new ArrayList<>(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
110 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
111 |
ResolvedJavaType retType = metaAccess.lookupJavaType(TestClass.class); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
112 |
VirtualObject ret = VirtualObject.get(retType, vobjs.size()); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
113 |
vobjs.add(ret); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
114 |
values[0] = ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
115 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
116 |
ResolvedJavaType arrayType = metaAccess.lookupJavaType(Object[].class); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
117 |
VirtualObject array = VirtualObject.get(arrayType, vobjs.size()); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
118 |
vobjs.add(array); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
119 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
120 |
// build array for ret.arrayField |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
121 |
ResolvedJavaType integerType = metaAccess.lookupJavaType(Integer.class); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
122 |
JavaValue[] arrayContent = new JavaValue[template.arrayField.length]; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
123 |
JavaKind[] arrayKind = new JavaKind[template.arrayField.length]; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
124 |
for (int i = 0; i < arrayContent.length; i++) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
125 |
arrayKind[i] = JavaKind.Object; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
126 |
if (template.arrayField[i] == null) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
127 |
arrayContent[i] = JavaConstant.NULL_POINTER; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
128 |
} else if (template.arrayField[i] == template) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
129 |
arrayContent[i] = ret; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
130 |
} else if (template.arrayField[i] instanceof Integer) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
131 |
int value = (Integer) template.arrayField[i]; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
132 |
VirtualObject boxed = VirtualObject.get(integerType, vobjs.size()); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
133 |
vobjs.add(boxed); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
134 |
arrayContent[i] = boxed; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
135 |
boxed.setValues(new JavaValue[]{JavaConstant.forInt(value)}, new JavaKind[]{JavaKind.Int}); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
136 |
} else if (template.arrayField[i] instanceof String) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
137 |
String value = (String) template.arrayField[i]; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
138 |
Register reg = asm.emitLoadPointer((HotSpotConstant) constantReflection.forString(value)); |
38692
54a84b7f3721
8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents:
38027
diff
changeset
|
139 |
arrayContent[i] = reg.asValue(asm.getValueKind(JavaKind.Object)); |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
140 |
} else { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
141 |
Assert.fail("unexpected value"); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
142 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
143 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
144 |
array.setValues(arrayContent, arrayKind); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
145 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
146 |
// build return object |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
147 |
ResolvedJavaField[] fields = retType.getInstanceFields(true); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
148 |
JavaValue[] retContent = new JavaValue[fields.length]; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
149 |
JavaKind[] retKind = new JavaKind[fields.length]; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
150 |
for (int i = 0; i < fields.length; i++) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
151 |
retKind[i] = fields[i].getJavaKind(); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
152 |
switch (retKind[i]) { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
153 |
case Long: // template.longField |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
154 |
retContent[i] = JavaConstant.forLong(template.longField); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
155 |
break; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
156 |
case Int: // template.intField |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
157 |
Register intReg = asm.emitLoadInt(template.intField); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
158 |
retContent[i] = asm.emitIntToStack(intReg); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
159 |
break; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
160 |
case Float: // template.floatField |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
161 |
Register fReg = asm.emitLoadFloat(template.floatField); |
38692
54a84b7f3721
8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents:
38027
diff
changeset
|
162 |
retContent[i] = fReg.asValue(asm.getValueKind(JavaKind.Float)); |
35137
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
163 |
break; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
164 |
case Object: // template.arrayField |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
165 |
retContent[i] = array; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
166 |
break; |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
167 |
default: |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
168 |
Assert.fail("unexpected field"); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
169 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
170 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
171 |
ret.setValues(retContent, retKind); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
172 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
173 |
return vobjs.toArray(new VirtualObject[0]); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
174 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
175 |
|
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
176 |
@Test |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
177 |
public void testBuildObject() { |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
178 |
test(this::compileBuildObject, getMethod("buildObject"), 7, JavaKind.Object); |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
179 |
} |
c8f8f6de68a7
8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff
changeset
|
180 |
} |