annotate graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java @ 19525:35481bcb5882

Remove LIRInstruction interface. Rename LIRInstructionBase to LIRInstruction.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 18:08:53 +0100
parents 61d3cb8e1280
children 8fc336a04d77
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 /*
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18181
diff changeset
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
18178
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.*;
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
35 import com.oracle.graal.graph.*;
18178
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.*;
18531
cdb9c605051a removed some static accesses to HotSpotGraalRuntime from some tests
Doug Simon <doug.simon@oracle.com>
parents: 18487
diff changeset
40 import com.oracle.graal.hotspot.test.*;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.lir.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.lir.asm.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43 import com.oracle.graal.lir.gen.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.nodeinfo.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 import com.oracle.graal.nodes.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
46 import com.oracle.graal.nodes.spi.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
47
18531
cdb9c605051a removed some static accesses to HotSpotGraalRuntime from some tests
Doug Simon <doug.simon@oracle.com>
parents: 18487
diff changeset
48 public class DataPatchInConstantsTest extends HotSpotGraalCompilerTest {
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
49
18181
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
50 @Before
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
51 public void checkAMD64() {
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
52 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
53 }
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
54
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
55 private static final Object object = new Object() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57 @Override
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
58 public String toString() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
59 return "testObject";
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 private static Object loadThroughPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
64 return obj;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
67 public static Object oopSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
68 Object patch = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
69 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
70 return "invalid patch";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
71 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
72 System.gc();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
73 patch = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
74 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
75 return "failed after gc";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
76 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
77 return patch;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
80 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
81 public void oopTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
82 test("oopSnippet");
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
85 private static Object loadThroughCompressedPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
86 return obj;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
89 public static Object narrowOopSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
90 Object patch = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
91 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
92 return "invalid patch";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
93 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
94 System.gc();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
95 patch = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
96 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
97 return "failed after gc";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
98 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
99 return patch;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
102 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
103 public void narrowOopTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
104 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
105 test("narrowOopSnippet");
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
108 public static Object compareSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
109 Object uncompressed = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
110 Object compressed = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
111 if (object != uncompressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
112 return "uncompressed failed";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
113 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
114 if (object != compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
115 return "compressed failed";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
116 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
117 if (uncompressed != compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
118 return "uncompressed != compressed";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
119 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
120 return object;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
123 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
124 public void compareTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
125 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
126 test("compareSnippet");
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
129 private static final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
130 private static boolean initReplacements = false;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
131
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
132 @Before
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
133 public void initReplacements() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
134 if (!initReplacements) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
135 getReplacements().registerSubstitutions(DataPatchInConstantsTest.class, DataPatchInConstantsTestSubstitutions.class);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
136 initReplacements = true;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
140 @ClassSubstitution(DataPatchInConstantsTest.class)
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
141 private static class DataPatchInConstantsTestSubstitutions {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
142
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
143 @MethodSubstitution
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
144 public static Object loadThroughPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
145 return LoadThroughPatchNode.load(obj);
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
148 @MethodSubstitution
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
149 public static Object loadThroughCompressedPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
150 Object compressed = CompressionNode.compression(CompressionOp.Compress, obj, config.getOopEncoding());
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
151 Object patch = LoadThroughPatchNode.load(compressed);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
152 return CompressionNode.compression(CompressionOp.Uncompress, patch, config.getOopEncoding());
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
156 @NodeInfo
18998
ec0733b5a90a Allow final modifier on node subclasses and start adding the modifier to leaf classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
157 private static final class LoadThroughPatchNode extends FixedWithNextNode implements LIRLowerable {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19396
diff changeset
158 public static final NodeClass<LoadThroughPatchNode> TYPE = NodeClass.get(LoadThroughPatchNode.class);
18178
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 @Input protected ValueNode input;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
161
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18531
diff changeset
162 public LoadThroughPatchNode(ValueNode input) {
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
163 super(TYPE, input.stamp());
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
164 this.input = input;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
165 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
166
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
167 public void generate(NodeLIRBuilderTool generator) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
168 assert input.isConstant();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
169
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
170 LIRGeneratorTool gen = generator.getLIRGeneratorTool();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
171 Variable ret = gen.newVariable(gen.getLIRKind(stamp()));
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
172
18487
0f4813e0b4a9 Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
173 gen.append(new LoadThroughPatchOp(input.asConstant(), stamp() instanceof NarrowOopStamp, ret));
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
174 generator.setResult(this, ret);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
175 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
176
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
177 @NodeIntrinsic
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
178 public static native Object load(Object obj);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
179 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
180
19525
35481bcb5882 Remove LIRInstruction interface. Rename LIRInstructionBase to LIRInstruction.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
181 private static class LoadThroughPatchOp extends LIRInstruction {
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
182
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
183 final Constant c;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
184 final boolean compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
185 @Def({REG}) AllocatableValue result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
186
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
187 LoadThroughPatchOp(Constant c, boolean compressed, AllocatableValue result) {
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
188 this.c = c;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
189 this.compressed = compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
190 this.result = result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
191 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
192
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
193 @Override
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
194 public void emitCode(CompilationResultBuilder crb) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
195 AMD64Address address = (AMD64Address) crb.recordDataReferenceInCode(c, compressed ? 4 : 8);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
196 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
197 if (compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
198 asm.movl(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
199 } else {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
200 asm.movq(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
201 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
202 }
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 }