@Test
 public void testJoinInterface1() {
   Stamp aNonNull = StampFactory.declaredNonNull(getType(A.class));
   Stamp i = StampFactory.declaredTrusted(getType(I.class));
   Stamp join = join(aNonNull, i);
   Assert.assertTrue(join instanceof ObjectStamp);
   Assert.assertTrue(((ObjectStamp) join).nonNull());
 }
 @Test
 public void testJoin7() {
   Stamp aExact = StampFactory.exact(getType(A.class));
   Stamp e = StampFactory.declared(getType(E.class));
   Stamp join = join(aExact, e);
   Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
   Assert.assertNull(StampTool.typeOrNull(join));
   Assert.assertFalse(StampTool.isExactType(join));
 }
 @Test
 public void testJoin6() {
   Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class));
   Stamp alwaysNull = StampFactory.alwaysNull();
   Stamp join = join(alwaysNull, dExactNonNull);
   Assert.assertFalse(join.isLegal());
   Assert.assertFalse(StampTool.isPointerNonNull(join));
   Assert.assertFalse(StampTool.isPointerAlwaysNull(join));
 }
 @Test
 public void testJoin5() {
   Stamp dExact = StampFactory.exact(getType(D.class));
   Stamp c = StampFactory.declared(getType(C.class));
   Stamp join = join(c, dExact);
   Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
   Assert.assertNull(StampTool.typeOrNull(join));
   Assert.assertFalse(StampTool.isExactType(join));
 }
 @Test
 public void testJoin9() {
   Stamp bExact = StampFactory.exact(getType(B.class));
   Stamp dExact = StampFactory.exact(getType(D.class));
   Stamp join = join(bExact, dExact);
   Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
   Assert.assertNull(StampTool.typeOrNull(join));
   Assert.assertNull(StampTool.typeOrNull(join));
 }
 @Test
 public void testJoin1() {
   Stamp aNonNull = StampFactory.declaredNonNull(getType(A.class));
   Stamp b = StampFactory.declared(getType(B.class));
   Stamp bNonNull = StampFactory.declaredNonNull(getType(B.class));
   Assert.assertEquals(bNonNull, join(aNonNull, b));
 }
 @Test
 public void testJoinInterface3() {
   Stamp bExact = StampFactory.exactNonNull(getType(B.class));
   Stamp i = StampFactory.declared(getType(I.class)); // not trusted
   Stamp join = join(i, bExact);
   Assert.assertEquals(bExact, join);
 }
 @Test
 public void testJoinInterface2() {
   Stamp bExact = StampFactory.exactNonNull(getType(B.class));
   Stamp i = StampFactory.declaredTrusted(getType(I.class));
   Stamp join = join(i, bExact);
   Assert.assertEquals(StampFactory.illegal(Kind.Object), join);
 }
 @Test
 public void testJoin8() {
   Stamp bExact = StampFactory.exactNonNull(getType(B.class));
   Stamp dExact = StampFactory.exact(getType(D.class));
   Stamp join = join(bExact, dExact);
   Assert.assertFalse(join.isLegal());
 }
예제 #10
0
  protected InstalledCode assembleMethod(Method m, CodeGenTest test) {
    ResolvedJavaMethod method = codeCache.lookupJavaMethod(m);
    RegisterConfig registerConfig = codeCache.lookupRegisterConfig();
    CallingConvention cc =
        CodeUtil.getCallingConvention(codeCache, CallingConvention.Type.JavaCallee, method, false);

    CompilationResult compResult = new CompilationResult();
    Buffer codeBuffer = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
    compResult.setTargetCode(codeBuffer.close(true), codeBuffer.position());

    InstalledCode code = codeCache.addMethod(method, compResult);

    DisassemblerProvider dis = Graal.getRuntime().getCapability(DisassemblerProvider.class);
    if (dis != null) {
      String disasm = dis.disassemble(code);
      Assert.assertTrue(code.toString(), disasm == null || disasm.length() > 0);
    }
    return code;
  }
 @Test
 public void testJoin4() {
   Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class));
   Stamp c = StampFactory.declared(getType(C.class));
   Assert.assertEquals(StampFactory.illegal(Kind.Object), join(c, dExactNonNull));
 }
 @Test
 public void testJoin3() {
   Stamp d = StampFactory.declared(getType(D.class));
   Stamp c = StampFactory.declared(getType(C.class));
   Assert.assertTrue(StampTool.isPointerAlwaysNull(join(c, d)));
 }
 @Test
 public void testJoin2() {
   Stamp aExact = StampFactory.exactNonNull(getType(A.class));
   Stamp b = StampFactory.declared(getType(B.class));
   Assert.assertEquals(StampFactory.illegal(Kind.Object), join(aExact, b));
 }
 @Test
 public void testJoin0() {
   Stamp a = StampFactory.declared(getType(A.class));
   Stamp b = StampFactory.declared(getType(B.class));
   Assert.assertEquals(b, join(a, b));
 }
 @Test
 public void testJoinInterface0() {
   Stamp a = StampFactory.declared(getType(A.class));
   Stamp i = StampFactory.declaredTrusted(getType(I.class));
   Assert.assertNotSame(StampFactory.illegal(Kind.Object), join(a, i));
 }
예제 #16
0
 protected void assertReturn(
     String methodName, CodeGenTest test, Object expected, Object... args) {
   Object actual = runTest(methodName, test, args);
   Assert.assertEquals("unexpected return value", expected, actual);
 }