Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java @ 9278:8cf939b349dd
Frame API: automatically change frame slot type for uninitialized slots
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 24 Apr 2013 14:14:22 +0200 |
parents | 07f8d136a05e |
children | 447465567e6f |
comparison
equal
deleted
inserted
replaced
9277:1fcaf6edc69d | 9278:8cf939b349dd |
---|---|
36 this(node.slot); | 36 this(node.slot); |
37 } | 37 } |
38 | 38 |
39 @Specialization(rewriteOn = FrameSlotTypeException.class) | 39 @Specialization(rewriteOn = FrameSlotTypeException.class) |
40 public int write(VirtualFrame frame, int right) throws FrameSlotTypeException { | 40 public int write(VirtualFrame frame, int right) throws FrameSlotTypeException { |
41 try { | 41 frame.setInt(slot, right); |
42 frame.setInt(slot, right); | |
43 } catch (FrameSlotTypeException e) { | |
44 if (slot.getType() == null) { | |
45 FrameUtil.setIntSafe(frame, slot, right); | |
46 } else { | |
47 throw e; | |
48 } | |
49 } | |
50 return right; | 42 return right; |
51 } | 43 } |
52 | 44 |
53 @Specialization(rewriteOn = FrameSlotTypeException.class) | 45 @Specialization(rewriteOn = FrameSlotTypeException.class) |
54 public boolean write(VirtualFrame frame, boolean right) throws FrameSlotTypeException { | 46 public boolean write(VirtualFrame frame, boolean right) throws FrameSlotTypeException { |
55 try { | 47 frame.setBoolean(slot, right); |
56 frame.setBoolean(slot, right); | |
57 } catch (FrameSlotTypeException e) { | |
58 if (slot.getType() == null) { | |
59 FrameUtil.setBooleanSafe(frame, slot, right); | |
60 } else { | |
61 throw e; | |
62 } | |
63 } | |
64 return right; | 48 return right; |
65 } | 49 } |
66 | 50 |
67 @Generic(useSpecializations = false) | 51 @Generic(useSpecializations = false) |
68 public Object writeGeneric(VirtualFrame frame, Object right) { | 52 public Object writeGeneric(VirtualFrame frame, Object right) { |