annotate graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java @ 18845:f57d86eb036f

removed Node factory methods
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Jan 2015 20:39:04 +0100
parents cdb9c605051a
children ec0733b5a90a
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.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.hotspot.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.hotspot.nodes.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.hotspot.nodes.CompressionNode.CompressionOp;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 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
39 import com.oracle.graal.hotspot.test.*;
18178
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
18531
cdb9c605051a removed some static accesses to HotSpotGraalRuntime from some tests
Doug Simon <doug.simon@oracle.com>
parents: 18487
diff changeset
47 public class DataPatchInConstantsTest extends HotSpotGraalCompilerTest {
18178
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
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18531
diff changeset
160 public LoadThroughPatchNode(ValueNode input) {
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
161 super(input.stamp());
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
162 this.input = input;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
165 public void generate(NodeLIRBuilderTool generator) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
166 assert input.isConstant();
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 LIRGeneratorTool gen = generator.getLIRGeneratorTool();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
169 Variable ret = gen.newVariable(gen.getLIRKind(stamp()));
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
170
18487
0f4813e0b4a9 Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
171 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
172 generator.setResult(this, ret);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
173 }
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 @NodeIntrinsic
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
176 public static native Object load(Object obj);
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 private static class LoadThroughPatchOp extends LIRInstructionBase {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
180
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
181 final Constant c;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
182 final boolean compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
183 @Def({REG}) AllocatableValue result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
184
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
185 LoadThroughPatchOp(Constant c, boolean compressed, AllocatableValue result) {
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
186 this.c = c;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
187 this.compressed = compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
188 this.result = result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
189 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
190
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
191 @Override
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
192 public void emitCode(CompilationResultBuilder crb) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
193 AMD64Address address = (AMD64Address) crb.recordDataReferenceInCode(c, compressed ? 4 : 8);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
194 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
195 if (compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
196 asm.movl(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
197 } else {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
198 asm.movq(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
199 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
200 }
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 }