annotate graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java @ 18181:d28acaa63680

Don't run AMD64 specific unit test on SPARC.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 29 Oct 2014 13:31:25 +0100
parents b9f31ed0643b
children 9619ba4daf4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
1 /*
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
4 *
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
8 *
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
13 * accompanied this code).
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
14 *
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
18 *
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
21 * questions.
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
22 */
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
23
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24 package com.oracle.graal.hotspot.amd64.test;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
25
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.api.code.ValueUtil.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
27 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
28
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
29 import org.junit.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
30
18181
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
31 import com.oracle.graal.amd64.*;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.api.meta.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.api.replacements.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.asm.amd64.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.compiler.test.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.hotspot.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.hotspot.nodes.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.hotspot.nodes.CompressionNode.CompressionOp;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.hotspot.nodes.type.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.lir.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.lir.asm.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.lir.gen.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43 import com.oracle.graal.nodeinfo.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.nodes.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 import com.oracle.graal.nodes.spi.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
46
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
47 public class DataPatchInConstantsTest extends GraalCompilerTest {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
48
18181
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
49 @Before
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
50 public void checkAMD64() {
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
51 Assume.assumeTrue("skipping AMD64 specific test", getTarget().arch instanceof AMD64);
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
52 }
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
53
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
54 private static final Object object = new Object() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
55
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56 @Override
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57 public String toString() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
58 return "testObject";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
59 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
60 };
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
61
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
62 private static Object loadThroughPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 return obj;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
64 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
65
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
66 public static Object oopSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
67 Object patch = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
68 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
69 return "invalid patch";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
70 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
71 System.gc();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
72 patch = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
73 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
74 return "failed after gc";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
75 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
76 return patch;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
77 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
78
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
79 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
80 public void oopTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
81 test("oopSnippet");
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
82 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
83
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
84 private static Object loadThroughCompressedPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
85 return obj;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
86 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
87
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
88 public static Object narrowOopSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
89 Object patch = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
90 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
91 return "invalid patch";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
92 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
93 System.gc();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
94 patch = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
95 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
96 return "failed after gc";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
97 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
98 return patch;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
99 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
100
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
101 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
102 public void narrowOopTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
103 Assume.assumeTrue("skipping narrow oop data patch test", config.useCompressedOops);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
104 test("narrowOopSnippet");
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
105 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
106
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
107 public static Object compareSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
108 Object uncompressed = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
109 Object compressed = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
110 if (object != uncompressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
111 return "uncompressed failed";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
112 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
113 if (object != compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
114 return "compressed failed";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
115 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
116 if (uncompressed != compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
117 return "uncompressed != compressed";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
118 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
119 return object;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
120 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
121
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
122 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
123 public void compareTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
124 Assume.assumeTrue("skipping narrow oop data patch test", config.useCompressedOops);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
125 test("compareSnippet");
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
126 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
127
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
128 private static final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
129 private static boolean initReplacements = false;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
130
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
131 @Before
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
132 public void initReplacements() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
133 if (!initReplacements) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
134 getReplacements().registerSubstitutions(DataPatchInConstantsTest.class, DataPatchInConstantsTestSubstitutions.class);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
135 initReplacements = true;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
136 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
137 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
138
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
139 @ClassSubstitution(DataPatchInConstantsTest.class)
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
140 private static class DataPatchInConstantsTestSubstitutions {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
141
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
142 @MethodSubstitution
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
143 public static Object loadThroughPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
144 return LoadThroughPatchNode.load(obj);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
145 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
146
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
147 @MethodSubstitution
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
148 public static Object loadThroughCompressedPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
149 Object compressed = CompressionNode.compression(CompressionOp.Compress, obj, config.getOopEncoding());
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
150 Object patch = LoadThroughPatchNode.load(compressed);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
151 return CompressionNode.compression(CompressionOp.Uncompress, patch, config.getOopEncoding());
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
152 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
153 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
154
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
155 @NodeInfo
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
156 private static class LoadThroughPatchNode extends FixedWithNextNode implements LIRLowerable {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
157
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
158 @Input protected ValueNode input;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
159
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
160 public static LoadThroughPatchNode create(ValueNode input) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
161 return new LoadThroughPatchNode(input);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
162 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
163
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
164 protected LoadThroughPatchNode(ValueNode input) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
165 super(input.stamp());
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
166 this.input = input;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
167 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
168
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
169 public void generate(NodeLIRBuilderTool generator) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
170 assert input.isConstant();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
171
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
172 LIRGeneratorTool gen = generator.getLIRGeneratorTool();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
173 Variable ret = gen.newVariable(gen.getLIRKind(stamp()));
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
174
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
175 gen.append(new LoadThroughPatchOp(input.asConstant(), stamp() instanceof NarrowOopStamp, ret));
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
176 generator.setResult(this, ret);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
177 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
179 @NodeIntrinsic
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
180 public static native Object load(Object obj);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
181 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
182
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
183 private static class LoadThroughPatchOp extends LIRInstructionBase {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
184
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
185 final Constant c;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
186 final boolean compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
187 @Def({REG}) AllocatableValue result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
188
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
189 LoadThroughPatchOp(Constant c, boolean compressed, AllocatableValue result) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
190 this.c = c;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
191 this.compressed = compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
192 this.result = result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
193 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
194
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
195 @Override
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
196 public void emitCode(CompilationResultBuilder crb) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
197 AMD64Address address = (AMD64Address) crb.recordDataReferenceInCode(c, compressed ? 4 : 8);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
198 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
199 if (compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
200 asm.movl(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
201 } else {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
202 asm.movq(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
203 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
204 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
205 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
206 }