Search in sources :

Example 16 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class FrameTest method testFrameDescriptorAccess2.

@Test
public void testFrameDescriptorAccess2() {
    FrameDescriptorAccess2Node node = FrameDescriptorAccess2NodeGen.create();
    FrameDescriptor descriptor = new FrameDescriptor();
    VirtualFrame frame = Truffle.getRuntime().createVirtualFrame(null, descriptor);
    Assert.assertSame(frame.getFrameDescriptor(), node.execute(frame, 2));
    Assert.assertSame(frame.getFrameDescriptor(), node.execute(frame, 3));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) Test(org.junit.Test)

Example 17 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class FrameDescriptorTest method copy.

@Test
public void copy() throws Exception {
    Object defaultValue = "default";
    FrameDescriptor d = new FrameDescriptor(defaultValue);
    s1 = d.addFrameSlot("v1", "i1", FrameSlotKind.Boolean);
    s2 = d.addFrameSlot("v2", "i2", FrameSlotKind.Float);
    assertEquals(2, d.getSize());
    assertEquals(d.getSlots().get(1).getInfo(), "i2");
    assertEquals(d.getSlots().get(1).getKind(), FrameSlotKind.Float);
    assertEquals(d.getSlots().get(1).getIndex(), 1);
    FrameDescriptor copy = d.copy();
    assertEquals(2, copy.getSize());
    assertEquals(1, copy.getSlots().get(1).getIndex());
    assertEquals("Info is copied", "i2", copy.getSlots().get(1).getInfo());
    assertEquals("Kind isn't copied", FrameSlotKind.Illegal, copy.getSlots().get(1).getKind());
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) Test(org.junit.Test)

Example 18 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class FrameDescriptorTest method version.

@Test
public void version() {
    FrameDescriptor d = new FrameDescriptor();
    s1 = d.addFrameSlot("v1", "i1", FrameSlotKind.Boolean);
    s2 = d.addFrameSlot("v2", "i2", FrameSlotKind.Float);
    Assumption version;
    version = d.getVersion();
    assertTrue(version.isValid());
    // add slot
    s3 = d.addFrameSlot("v3", "i3", FrameSlotKind.Int);
    assertEquals(3, d.getSize());
    assertFalse(version.isValid());
    version = d.getVersion();
    assertTrue(version.isValid());
    assertSame("1st slot", s1, d.getSlots().get(0));
    assertSame("2nd slot", s2, d.getSlots().get(1));
    assertSame("3rd slot", s3, d.getSlots().get(2));
    // change kind
    s3.setKind(FrameSlotKind.Object);
    assertFalse(version.isValid());
    version = d.getVersion();
    assertTrue(version.isValid());
    // remove slot
    d.removeFrameSlot("v3");
    assertEquals(2, d.getSize());
    assertFalse(version.isValid());
    version = d.getVersion();
    assertTrue(version.isValid());
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 19 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class FrameDescriptorTest method shallowCopy.

@Test
public void shallowCopy() {
    Object defaultValue = "default";
    FrameDescriptor d = new FrameDescriptor(defaultValue);
    s1 = d.addFrameSlot("v1", "i1", FrameSlotKind.Boolean);
    s2 = d.addFrameSlot("v2", "i2", FrameSlotKind.Float);
    assertEquals(2, d.getSize());
    final FrameSlot first = d.getSlots().get(1);
    assertEquals(first.getInfo(), "i2");
    assertEquals(first.getKind(), FrameSlotKind.Float);
    assertEquals(first.getIndex(), 1);
    FrameDescriptor copy = d.shallowCopy();
    assertEquals(2, copy.getSize());
    final FrameSlot firstCopy = copy.getSlots().get(1);
    assertEquals("Info is copied", firstCopy.getInfo(), "i2");
    assertEquals("Kind is copied", firstCopy.getKind(), FrameSlotKind.Float);
    assertEquals(firstCopy.getIndex(), 1);
    firstCopy.setKind(FrameSlotKind.Int);
    assertEquals("Kind is changed", firstCopy.getKind(), FrameSlotKind.Int);
    assertEquals("Kind is changed in original too!", first.getKind(), FrameSlotKind.Int);
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) Test(org.junit.Test)

Example 20 with FrameDescriptor

use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.

the class FrameDescriptorTest method notInFrameAssumption.

@Test
public void notInFrameAssumption() {
    FrameDescriptor d = new FrameDescriptor();
    Assumption[] ass = new Assumption[] { d.getNotInFrameAssumption("v1"), d.getNotInFrameAssumption("v2"), d.getNotInFrameAssumption("v3") };
    assertTrue(ass[0].isValid());
    assertTrue(ass[1].isValid());
    assertTrue(ass[2].isValid());
    s1 = d.addFrameSlot("v1", "i1", FrameSlotKind.Boolean);
    assertFalse(ass[0].isValid());
    assertTrue(ass[1].isValid());
    assertTrue(ass[2].isValid());
    s2 = d.addFrameSlot("v2", "i2", FrameSlotKind.Float);
    assertFalse(ass[0].isValid());
    assertFalse(ass[1].isValid());
    assertTrue(ass[2].isValid());
    s3 = d.addFrameSlot("v3", "i3", FrameSlotKind.Int);
    assertFalse(ass[0].isValid());
    assertFalse(ass[1].isValid());
    assertFalse(ass[2].isValid());
    for (String identifier : new String[] { "v1", "v2", "v3" }) {
        try {
            d.getNotInFrameAssumption(identifier);
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        // expected
        }
    }
    d.getNotInFrameAssumption("v4");
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Aggregations

FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)72 Test (org.junit.Test)61 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)50 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)43 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)14 ConstantTestNode (org.graalvm.compiler.truffle.test.nodes.ConstantTestNode)14 RootNode (com.oracle.truffle.api.nodes.RootNode)12 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)9 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)7 AddTestNode (org.graalvm.compiler.truffle.test.nodes.AddTestNode)7 BlockTestNode (org.graalvm.compiler.truffle.test.nodes.BlockTestNode)6 Assumption (com.oracle.truffle.api.Assumption)5 CallTarget (com.oracle.truffle.api.CallTarget)5 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)3 LoadLocalTestNode (org.graalvm.compiler.truffle.test.nodes.LoadLocalTestNode)3 NestedExplodedLoopTestNode (org.graalvm.compiler.truffle.test.nodes.NestedExplodedLoopTestNode)3 StoreLocalTestNode (org.graalvm.compiler.truffle.test.nodes.StoreLocalTestNode)3 RootCallTarget (com.oracle.truffle.api.RootCallTarget)2 WeakReference (java.lang.ref.WeakReference)2 List (java.util.List)2