< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.jdk9.test/src/org/graalvm/compiler/hotspot/jdk9/test/StringUTF16ToBytesGetCharsTest.java

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.hotspot.jdk9.test;
  26 
  27 import static org.junit.Assume.assumeFalse;
  28 
  29 import jdk.vm.ci.code.InstalledCode;
  30 import jdk.vm.ci.meta.ResolvedJavaMethod;
  31 import org.graalvm.compiler.core.common.CompilationIdentifier;
  32 import org.graalvm.compiler.hotspot.replacements.StringUTF16Substitutions;
  33 import org.graalvm.compiler.nodes.StructuredGraph;
  34 import org.graalvm.compiler.nodes.java.NewArrayNode;
  35 import org.graalvm.compiler.replacements.arraycopy.ArrayCopyCallNode;
  36 import org.graalvm.compiler.replacements.test.MethodSubstitutionTest;
  37 import org.graalvm.compiler.test.AddExports;
  38 import org.junit.Before;
  39 import org.junit.Test;
  40 



  41 /**
  42  * Test substitutions for (innate) methods StringUTF16.toBytes and StringUTF16.getChars provided by
  43  * {@link StringUTF16Substitutions}.
  44  */
  45 @AddExports({"java.base/java.lang"})
  46 public final class StringUTF16ToBytesGetCharsTest extends MethodSubstitutionTest {
  47 
  48     private static final int N = 1000;
  49     private static final int N_OVERFLOW = 10;
  50 
  51     @Before
  52     public void checkAMD64() {
  53         assumeFalse(Java8OrEarlier);
  54     }
  55 
  56     @Test
  57     public void testStringUTF16ToBytes() throws ClassNotFoundException {
  58         Class<?> javaclass = Class.forName("java.lang.StringUTF16");
  59 
  60         ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "toBytes", char[].class, int.class, int.class);
  61         StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext());
  62         assertInGraph(graph, NewArrayNode.class);
  63         assertInGraph(graph, ArrayCopyCallNode.class);
  64 
  65         InstalledCode code = getCode(caller, graph);
  66 
  67         for (int srcOffset = 0; srcOffset < 2; srcOffset++) {
  68             for (int i = 0; i < N; i++) {
  69                 int length = i2sz(i);
  70                 char[] src = fillUTF16Chars(new char[length]);
  71                 int copiedLength = Math.max(0, length - srcOffset);
  72                 int srcDelta = Math.min(srcOffset, copiedLength);




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.hotspot.jdk9.test;
  26 
  27 import static org.junit.Assume.assumeFalse;
  28 


  29 import org.graalvm.compiler.core.common.CompilationIdentifier;
  30 import org.graalvm.compiler.hotspot.replacements.StringUTF16Substitutions;
  31 import org.graalvm.compiler.nodes.StructuredGraph;
  32 import org.graalvm.compiler.nodes.java.NewArrayNode;
  33 import org.graalvm.compiler.replacements.arraycopy.ArrayCopyCallNode;
  34 import org.graalvm.compiler.replacements.test.MethodSubstitutionTest;
  35 import org.graalvm.compiler.test.AddExports;

  36 import org.junit.Test;
  37 
  38 import jdk.vm.ci.code.InstalledCode;
  39 import jdk.vm.ci.meta.ResolvedJavaMethod;
  40 
  41 /**
  42  * Test substitutions for (innate) methods StringUTF16.toBytes and StringUTF16.getChars provided by
  43  * {@link StringUTF16Substitutions}.
  44  */
  45 @AddExports({"java.base/java.lang"})
  46 public final class StringUTF16ToBytesGetCharsTest extends MethodSubstitutionTest {
  47 
  48     private static final int N = 1000;
  49     private static final int N_OVERFLOW = 10;
  50 
  51     public StringUTF16ToBytesGetCharsTest() {

  52         assumeFalse(Java8OrEarlier);
  53     }
  54 
  55     @Test
  56     public void testStringUTF16ToBytes() throws ClassNotFoundException {
  57         Class<?> javaclass = Class.forName("java.lang.StringUTF16");
  58 
  59         ResolvedJavaMethod caller = getResolvedJavaMethod(javaclass, "toBytes", char[].class, int.class, int.class);
  60         StructuredGraph graph = getReplacements().getIntrinsicGraph(caller, CompilationIdentifier.INVALID_COMPILATION_ID, getDebugContext());
  61         assertInGraph(graph, NewArrayNode.class);
  62         assertInGraph(graph, ArrayCopyCallNode.class);
  63 
  64         InstalledCode code = getCode(caller, graph);
  65 
  66         for (int srcOffset = 0; srcOffset < 2; srcOffset++) {
  67             for (int i = 0; i < N; i++) {
  68                 int length = i2sz(i);
  69                 char[] src = fillUTF16Chars(new char[length]);
  70                 int copiedLength = Math.max(0, length - srcOffset);
  71                 int srcDelta = Math.min(srcOffset, copiedLength);


< prev index next >