annotate graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java @ 21673:5024c80224c7

moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Tue, 02 Jun 2015 22:11:52 +0200
parents 48c1ebd24120
children 6df25b1418be
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
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
26 import com.oracle.jvmci.meta.AllocatableValue;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
27 import com.oracle.jvmci.meta.Constant;
21673
5024c80224c7 moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
28
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
29 import static com.oracle.jvmci.code.ValueUtil.*;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
30 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
31
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
32 import org.junit.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.api.replacements.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35 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
36 import com.oracle.graal.graph.*;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.hotspot.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.hotspot.nodes.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.hotspot.nodes.CompressionNode.CompressionOp;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40 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
41 import com.oracle.graal.hotspot.test.*;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.lir.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43 import com.oracle.graal.lir.asm.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.lir.gen.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 import com.oracle.graal.nodeinfo.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
46 import com.oracle.graal.nodes.*;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
47 import com.oracle.graal.nodes.spi.*;
21673
5024c80224c7 moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
48 import com.oracle.jvmci.amd64.*;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
49 import com.oracle.jvmci.hotspot.*;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
50
18531
cdb9c605051a removed some static accesses to HotSpotGraalRuntime from some tests
Doug Simon <doug.simon@oracle.com>
parents: 18487
diff changeset
51 public class DataPatchInConstantsTest extends HotSpotGraalCompilerTest {
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
52
18181
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
53 @Before
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
54 public void checkAMD64() {
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
55 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
56 }
d28acaa63680 Don't run AMD64 specific unit test on SPARC.
Roland Schatz <roland.schatz@oracle.com>
parents: 18178
diff changeset
57
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
58 private static final Object object = new Object() {
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 @Override
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
61 public String toString() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
62 return "testObject";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 }
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 private static Object loadThroughPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
67 return obj;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
68 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
69
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
70 public static Object oopSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
71 Object patch = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
72 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
73 return "invalid patch";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
74 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
75 System.gc();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
76 patch = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
77 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
78 return "failed after gc";
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 return patch;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
81 }
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 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
84 public void oopTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
85 test("oopSnippet");
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 private static Object loadThroughCompressedPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
89 return obj;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
90 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
91
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
92 public static Object narrowOopSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
93 Object patch = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
94 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
95 return "invalid patch";
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
96 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
97 System.gc();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
98 patch = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
99 if (object != patch) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
100 return "failed after gc";
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 return patch;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
103 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
104
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
105 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
106 public void narrowOopTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
107 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
108 test("narrowOopSnippet");
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
109 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
110
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
111 public static Object compareSnippet() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
112 Object uncompressed = loadThroughPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
113 Object compressed = loadThroughCompressedPatch(object);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
114 if (object != uncompressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
115 return "uncompressed 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 (object != compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
118 return "compressed failed";
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 if (uncompressed != compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
121 return "uncompressed != compressed";
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 return object;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
124 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
125
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
126 @Test
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
127 public void compareTest() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
128 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
129 test("compareSnippet");
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
132 private static final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
133 private static boolean initReplacements = false;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
134
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
135 @Before
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
136 public void initReplacements() {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
137 if (!initReplacements) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
138 getReplacements().registerSubstitutions(DataPatchInConstantsTest.class, DataPatchInConstantsTestSubstitutions.class);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
139 initReplacements = true;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
140 }
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
143 @ClassSubstitution(DataPatchInConstantsTest.class)
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
144 private static class DataPatchInConstantsTestSubstitutions {
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 @MethodSubstitution
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
147 public static Object loadThroughPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
148 return LoadThroughPatchNode.load(obj);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
149 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
150
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
151 @MethodSubstitution
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
152 public static Object loadThroughCompressedPatch(Object obj) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
153 Object compressed = CompressionNode.compression(CompressionOp.Compress, obj, config.getOopEncoding());
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
154 Object patch = LoadThroughPatchNode.load(compressed);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
155 return CompressionNode.compression(CompressionOp.Uncompress, patch, config.getOopEncoding());
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
156 }
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
159 @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
160 private static final class LoadThroughPatchNode extends FixedWithNextNode implements LIRLowerable {
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19525
diff changeset
161 public static final NodeClass<LoadThroughPatchNode> TYPE = NodeClass.create(LoadThroughPatchNode.class);
18178
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 @Input protected ValueNode input;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
164
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18531
diff changeset
165 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
166 super(TYPE, input.stamp());
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
167 this.input = input;
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
170 public void generate(NodeLIRBuilderTool generator) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
171 assert input.isConstant();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
172
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
173 LIRGeneratorTool gen = generator.getLIRGeneratorTool();
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
174 Variable ret = gen.newVariable(gen.getLIRKind(stamp()));
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
175
18487
0f4813e0b4a9 Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
176 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
177 generator.setResult(this, ret);
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
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
180 @NodeIntrinsic
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
181 public static native Object load(Object obj);
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
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19525
diff changeset
184 private static final class LoadThroughPatchOp extends LIRInstruction {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19525
diff changeset
185 public static final LIRInstructionClass<LoadThroughPatchOp> TYPE = LIRInstructionClass.create(LoadThroughPatchOp.class);
18178
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 final Constant c;
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
188 final boolean compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
189 @Def({REG}) AllocatableValue result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
190
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
191 LoadThroughPatchOp(Constant c, boolean compressed, AllocatableValue result) {
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19525
diff changeset
192 super(TYPE);
18178
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
193 this.c = c;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
194 this.compressed = compressed;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
195 this.result = result;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
196 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
197
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
198 @Override
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
199 public void emitCode(CompilationResultBuilder crb) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
200 AMD64Address address = (AMD64Address) crb.recordDataReferenceInCode(c, compressed ? 4 : 8);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
201 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm;
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
202 if (compressed) {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
203 asm.movl(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
204 } else {
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
205 asm.movq(asRegister(result), address);
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
206 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
207 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
208 }
b9f31ed0643b Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
209 }