src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/StringCompressInflateTest.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 import org.graalvm.compiler.nodes.StructuredGraph; |
33 import org.graalvm.compiler.nodes.StructuredGraph; |
34 import org.graalvm.compiler.replacements.amd64.AMD64StringLatin1InflateNode; |
34 import org.graalvm.compiler.replacements.amd64.AMD64StringLatin1InflateNode; |
35 import org.graalvm.compiler.replacements.amd64.AMD64StringLatin1Substitutions; |
35 import org.graalvm.compiler.replacements.amd64.AMD64StringLatin1Substitutions; |
36 import org.graalvm.compiler.replacements.amd64.AMD64StringUTF16CompressNode; |
36 import org.graalvm.compiler.replacements.amd64.AMD64StringUTF16CompressNode; |
37 import org.graalvm.compiler.replacements.amd64.AMD64StringUTF16Substitutions; |
37 import org.graalvm.compiler.replacements.amd64.AMD64StringUTF16Substitutions; |
|
38 import org.graalvm.compiler.serviceprovider.JavaVersionUtil; |
38 import org.graalvm.compiler.test.AddExports; |
39 import org.graalvm.compiler.test.AddExports; |
39 import org.junit.Before; |
40 import org.junit.Before; |
40 import org.junit.Test; |
41 import org.junit.Test; |
41 |
42 |
42 import jdk.vm.ci.amd64.AMD64; |
43 import jdk.vm.ci.amd64.AMD64; |
53 |
54 |
54 static final int N = 1000; |
55 static final int N = 1000; |
55 |
56 |
56 @Before |
57 @Before |
57 public void checkAMD64() { |
58 public void checkAMD64() { |
58 assumeFalse(Java8OrEarlier); |
59 assumeFalse(JavaVersionUtil.JAVA_SPEC <= 8); |
59 // Test case is (currently) AMD64 only. |
60 // Test case is (currently) AMD64 only. |
60 assumeTrue(getTarget().arch instanceof AMD64); |
61 assumeTrue(getTarget().arch instanceof AMD64); |
61 } |
62 } |
62 |
63 |
63 @Test |
64 @Test |
112 @Test |
113 @Test |
113 public void testStringLatin1InflateByteByte() throws ClassNotFoundException { |
114 public void testStringLatin1InflateByteByte() throws ClassNotFoundException { |
114 Class<?> javaclass = Class.forName("java.lang.StringLatin1"); |
115 Class<?> javaclass = Class.forName("java.lang.StringLatin1"); |
115 |
116 |
116 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "inflate", byte[].class, int.class, byte[].class, int.class, int.class); |
117 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "inflate", byte[].class, int.class, byte[].class, int.class, int.class); |
117 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext()); |
118 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), null); |
118 assertInGraph(graph, AMD64StringLatin1InflateNode.class); |
119 assertInGraph(graph, AMD64StringLatin1InflateNode.class); |
119 |
120 |
120 InstalledCode code = getCode(caller, graph); |
121 InstalledCode code = getCode(caller, graph); |
121 |
122 |
122 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
123 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
150 @Test |
151 @Test |
151 public void testStringLatin1InflateByteChar() throws ClassNotFoundException { |
152 public void testStringLatin1InflateByteChar() throws ClassNotFoundException { |
152 Class<?> javaclass = Class.forName("java.lang.StringLatin1"); |
153 Class<?> javaclass = Class.forName("java.lang.StringLatin1"); |
153 |
154 |
154 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "inflate", byte[].class, int.class, char[].class, int.class, int.class); |
155 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "inflate", byte[].class, int.class, char[].class, int.class, int.class); |
155 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext()); |
156 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), null); |
156 assertInGraph(graph, AMD64StringLatin1InflateNode.class); |
157 assertInGraph(graph, AMD64StringLatin1InflateNode.class); |
157 |
158 |
158 InstalledCode code = getCode(caller, graph); |
159 InstalledCode code = getCode(caller, graph); |
159 |
160 |
160 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
161 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
215 @Test |
216 @Test |
216 public void testStringUTF16CompressByteByte() throws ClassNotFoundException { |
217 public void testStringUTF16CompressByteByte() throws ClassNotFoundException { |
217 Class<?> javaclass = Class.forName("java.lang.StringUTF16"); |
218 Class<?> javaclass = Class.forName("java.lang.StringUTF16"); |
218 |
219 |
219 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "compress", byte[].class, int.class, byte[].class, int.class, int.class); |
220 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "compress", byte[].class, int.class, byte[].class, int.class, int.class); |
220 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext()); |
221 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), null); |
221 assertInGraph(graph, AMD64StringUTF16CompressNode.class); |
222 assertInGraph(graph, AMD64StringUTF16CompressNode.class); |
222 |
223 |
223 InstalledCode code = getCode(caller, graph); |
224 InstalledCode code = getCode(caller, graph); |
224 |
225 |
225 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
226 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
251 @Test |
252 @Test |
252 public void testStringUTF16CompressCharByte() throws ClassNotFoundException { |
253 public void testStringUTF16CompressCharByte() throws ClassNotFoundException { |
253 Class<?> javaclass = Class.forName("java.lang.StringUTF16"); |
254 Class<?> javaclass = Class.forName("java.lang.StringUTF16"); |
254 |
255 |
255 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "compress", char[].class, int.class, byte[].class, int.class, int.class); |
256 ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "compress", char[].class, int.class, byte[].class, int.class, int.class); |
256 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext()); |
257 StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), null); |
257 assertInGraph(graph, AMD64StringUTF16CompressNode.class); |
258 assertInGraph(graph, AMD64StringUTF16CompressNode.class); |
258 |
259 |
259 InstalledCode code = getCode(caller, graph); |
260 InstalledCode code = getCode(caller, graph); |
260 |
261 |
261 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
262 for (int dstOffset = 0; dstOffset < 2; dstOffset++) { |
297 private class TestMethods { |
298 private class TestMethods { |
298 |
299 |
299 TestMethods(String testmname, Class<?> javaclass, Class<?> intrinsicClass, String javamname, Class<?>... params) { |
300 TestMethods(String testmname, Class<?> javaclass, Class<?> intrinsicClass, String javamname, Class<?>... params) { |
300 javamethod = getResolvedJavaMethod(javaclass, javamname, params); |
301 javamethod = getResolvedJavaMethod(javaclass, javamname, params); |
301 testmethod = getResolvedJavaMethod(testmname); |
302 testmethod = getResolvedJavaMethod(testmname); |
302 testgraph = getReplacements().getIntrinsicGraph(javamethod, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext()); |
303 testgraph = getReplacements().getIntrinsicGraph(javamethod, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext(), null); |
303 assertInGraph(testgraph, intrinsicClass); |
304 assertInGraph(testgraph, intrinsicClass); |
304 |
305 |
305 assert javamethod != null; |
306 assert javamethod != null; |
306 assert testmethod != null; |
307 assert testmethod != null; |
307 |
308 |