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));
}
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());
}
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());
}
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);
}
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");
}
Aggregations