Ejemplo n.º 1
0
 @Test
 public void test3() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode =
       getInstalledCode("compareAndSwapTest", Object.class, Object.class, Object.class);
   Object initial = new Object();
   Object replacement = new Object();
   AtomicReference<Object> cas = new AtomicReference<>();
   Assert.assertEquals(cas.get(), null);
   installedBenchmarkCode.executeVarargs(cas, null, initial);
   Assert.assertEquals(cas.get(), initial);
   installedBenchmarkCode.executeVarargs(cas, initial, replacement);
   Assert.assertEquals(cas.get(), replacement);
 }
Ejemplo n.º 2
0
 @Test
 public void test1() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode =
       getInstalledCode("arrayTest", Object.class, Object.class, Object.class);
   ArrayContainer ac = new ArrayContainer();
   Assert.assertEquals(ac.a[9], installedBenchmarkCode.executeVarargs(ac.a, 0, 9));
   Assert.assertEquals(ac.a[8], installedBenchmarkCode.executeVarargs(ac.a, 1, 8));
   Assert.assertEquals(ac.a[7], installedBenchmarkCode.executeVarargs(ac.a, 2, 7));
   Assert.assertEquals(ac.a[6], installedBenchmarkCode.executeVarargs(ac.a, 3, 6));
   Assert.assertEquals(ac.a[5], installedBenchmarkCode.executeVarargs(ac.a, 4, 5));
   Assert.assertEquals(ac.a[4], installedBenchmarkCode.executeVarargs(ac.a, 5, 4));
   Assert.assertEquals(ac.a[3], installedBenchmarkCode.executeVarargs(ac.a, 6, 3));
   Assert.assertEquals(ac.a[2], installedBenchmarkCode.executeVarargs(ac.a, 7, 2));
   Assert.assertEquals(ac.a[1], installedBenchmarkCode.executeVarargs(ac.a, 8, 1));
   Assert.assertEquals(ac.a[0], installedBenchmarkCode.executeVarargs(ac.a, 9, 0));
 }
Ejemplo n.º 3
0
 @Test
 public void test18() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilder");
   StringBuilder b = (StringBuilder) installedBenchmarkCode.executeVarargs();
   Assert.assertTrue(b.capacity() == 16);
   Assert.assertTrue(b.length() == 0);
 }
Ejemplo n.º 4
0
 @Test
 public void test9() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTest", Object.class);
   List<Object> list = new ArrayList<>();
   Object[] array = (Object[]) installedBenchmarkCode.executeVarargs(list);
   Assert.assertTrue(list.size() == array.length);
 }
Ejemplo n.º 5
0
  @Test
  public void test7() throws Exception {
    HotSpotInstalledCode installedBenchmarkCode =
        getInstalledCode("queueTest", Object.class, Object.class);
    ArrayDeque<Object> q = new ArrayDeque<>();
    Object[] objects = new Object[512];
    for (int i = 0; i < objects.length; i++) {
      objects[i] = new Object();
    }
    int j = 0;
    while (j < objects.length) {
      if (!installedBenchmarkCode.isValid()) {
        // This can get invalidated due to lack of MDO update
        installedBenchmarkCode = getInstalledCode("queueTest", Object.class, Object.class);
      }
      installedBenchmarkCode.executeVarargs(q, objects[j]);
      j++;
    }

    System.gc();
    Assert.assertTrue(q.size() == objects.length);
    Assert.assertTrue(!q.isEmpty());
    j = 0;
    while (j < objects.length) {
      Assert.assertTrue(objects[j] == q.remove());
      j++;
    }

    Assert.assertTrue(q.size() == 0);
    Assert.assertTrue(q.isEmpty());
  }
Ejemplo n.º 6
0
 @Test
 public void test12() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode =
       getInstalledCode("stringConstantEqualsTest", Object.class);
   String s1 = new String("Test");
   boolean result = ((Boolean) (installedBenchmarkCode.executeVarargs(s1))).booleanValue();
   Assert.assertTrue(result);
 }
Ejemplo n.º 7
0
 @Test
 public void test6() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode =
       getInstalledCode("stringCopyTest", Object.class, Object.class);
   String a = new String("Test ");
   String b = new String("String");
   String c = (String) installedBenchmarkCode.executeVarargs(a, b);
   Assert.assertTrue(c.equals("Test String"));
 }
Ejemplo n.º 8
0
 @Test
 public void test2() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode =
       getInstalledCode("arrayCopyTest", Object.class, Object.class);
   ArrayContainer source = new ArrayContainer();
   ArrayContainer destination = new ArrayContainer();
   Assert.assertEquals(source.a.length, destination.a.length);
   Assert.assertFalse(Arrays.equals(source.a, destination.a));
   installedBenchmarkCode.executeVarargs(source.a, destination.a);
   Assert.assertArrayEquals(source.a, destination.a);
 }
Ejemplo n.º 9
0
 @Test
 public void test5() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode =
       getInstalledCode("charContainerArrayCopyTest", Object.class, Object.class, Object.class);
   StringContainer1 source1 = new StringContainer1();
   StringContainer2 source2 = new StringContainer2();
   char[] result = new char[source1.value.length + source2.value.length];
   installedBenchmarkCode.executeVarargs(source1, source2, result);
   Assert.assertArrayEquals(
       new char[] {'T', 'e', 's', 't', ' ', 'S', 't', 'r', 'i', 'n', 'g'}, result);
 }
Ejemplo n.º 10
0
 @Test
 public void test14() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode =
       getInstalledCode("stringBuilderTest", Object.class, Object.class);
   StringBuilder buffer = new StringBuilder("TestTestTestTestTestTestTest");
   Assert.assertTrue(buffer.length() == 28);
   String a = new String("TestTestTestTestTestTestTest");
   installedBenchmarkCode.executeVarargs(buffer, a.toCharArray());
   Assert.assertTrue(buffer.length() == 56);
   Assert.assertTrue(
       buffer.toString().equals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest"));
 }
Ejemplo n.º 11
0
 @Test
 public void test8() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTest", Object.class);
   List<Object> list = new ArrayList<>();
   for (int i = 0; i < 512; i++) {
     list.add(new Object());
   }
   Object[] array = (Object[]) installedBenchmarkCode.executeVarargs(list);
   Assert.assertTrue(list.size() == array.length);
   int i = 0;
   for (Object obj : list) {
     Assert.assertTrue(obj == array[i]);
     i++;
   }
 }
Ejemplo n.º 12
0
 @Test
 public void test() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("fieldTest", Object.class);
   Container c1 = new Container();
   Assert.assertEquals(c1.b, installedBenchmarkCode.executeVarargs(c1));
 }
Ejemplo n.º 13
0
 @Test
 public void test17() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringFormat");
   installedBenchmarkCode.executeVarargs();
 }
Ejemplo n.º 14
0
 @Test
 public void test16() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilderArrayCopy");
   installedBenchmarkCode.executeVarargs();
 }
Ejemplo n.º 15
0
 public void test10() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("constantTest", Object.class);
   Container c = new Container();
   Assert.assertFalse((boolean) installedBenchmarkCode.executeVarargs(c));
 }