Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java @ 22205:7804ee711b7d
Ensure materialized frame is really materialized
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 30 Sep 2015 10:59:40 +0200 |
parents | dc83cc1f94f2 |
children | 71ec6de11cea |
comparison
equal
deleted
inserted
replaced
22202:3d9e283e2487 | 22205:7804ee711b7d |
---|---|
25 import com.oracle.truffle.api.CallTarget; | 25 import com.oracle.truffle.api.CallTarget; |
26 import com.oracle.truffle.api.Truffle; | 26 import com.oracle.truffle.api.Truffle; |
27 import com.oracle.truffle.api.TruffleRuntime; | 27 import com.oracle.truffle.api.TruffleRuntime; |
28 import com.oracle.truffle.api.frame.Frame; | 28 import com.oracle.truffle.api.frame.Frame; |
29 import com.oracle.truffle.api.frame.FrameDescriptor; | 29 import com.oracle.truffle.api.frame.FrameDescriptor; |
30 import com.oracle.truffle.api.frame.FrameInstance; | |
30 import com.oracle.truffle.api.frame.FrameSlot; | 31 import com.oracle.truffle.api.frame.FrameSlot; |
31 import com.oracle.truffle.api.frame.FrameSlotKind; | 32 import com.oracle.truffle.api.frame.FrameSlotKind; |
32 import com.oracle.truffle.api.frame.FrameSlotTypeException; | 33 import com.oracle.truffle.api.frame.FrameSlotTypeException; |
34 import com.oracle.truffle.api.frame.MaterializedFrame; | |
33 import com.oracle.truffle.api.frame.VirtualFrame; | 35 import com.oracle.truffle.api.frame.VirtualFrame; |
34 import com.oracle.truffle.api.nodes.Node; | 36 import com.oracle.truffle.api.nodes.Node; |
35 import com.oracle.truffle.api.nodes.RootNode; | 37 import com.oracle.truffle.api.nodes.RootNode; |
36 import org.junit.Assert; | 38 import org.junit.Assert; |
39 import static org.junit.Assert.assertEquals; | |
40 import static org.junit.Assert.assertTrue; | |
37 import org.junit.Test; | 41 import org.junit.Test; |
38 | 42 |
39 /** | 43 /** |
40 * <h3>Storing Values in Frame Slots</h3> | 44 * <h3>Storing Values in Frame Slots</h3> |
41 * | 45 * |
150 } catch (FrameSlotTypeException e) { | 154 } catch (FrameSlotTypeException e) { |
151 throw new IllegalStateException(e); | 155 throw new IllegalStateException(e); |
152 } | 156 } |
153 } | 157 } |
154 } | 158 } |
159 | |
160 @Test | |
161 public void framesCanBeMaterialized() { | |
162 final TruffleRuntime runtime = Truffle.getRuntime(); | |
163 | |
164 class FrameRootNode extends RootNode { | |
165 | |
166 public FrameRootNode() { | |
167 super(TestingLanguage.class, null, null); | |
168 } | |
169 | |
170 @Override | |
171 public Object execute(VirtualFrame frame) { | |
172 FrameInstance frameInstance = runtime.getCurrentFrame(); | |
173 Frame readWrite = frameInstance.getFrame(FrameInstance.FrameAccess.READ_WRITE, true); | |
174 Frame materialized = frameInstance.getFrame(FrameInstance.FrameAccess.MATERIALIZE, true); | |
175 | |
176 assertTrue("Really materilized: " + materialized, materialized instanceof MaterializedFrame); | |
177 assertEquals("It's my frame", frame, readWrite); | |
178 return this; | |
179 } | |
180 } | |
181 | |
182 FrameRootNode frn = new FrameRootNode(); | |
183 Object ret = Truffle.getRuntime().createCallTarget(frn).call(); | |
184 assertEquals("Returns itself", frn, ret); | |
185 } | |
155 } | 186 } |