Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java @ 13359:136df94b5aa8
SL: updated outdated implementation of write local variable nodes in SL.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 17 Dec 2013 15:44:02 +0100 |
parents | 139b84d713bc |
children |
comparison
equal
deleted
inserted
replaced
13338:652f24858aad | 13359:136df94b5aa8 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.sl.nodes; | 23 package com.oracle.truffle.sl.nodes; |
24 | 24 |
25 import com.oracle.truffle.api.*; | |
25 import com.oracle.truffle.api.dsl.*; | 26 import com.oracle.truffle.api.dsl.*; |
26 import com.oracle.truffle.api.frame.*; | 27 import com.oracle.truffle.api.frame.*; |
27 | 28 |
28 @NodeChild(value = "rightNode", type = TypedNode.class) | 29 @NodeChild(value = "rightNode", type = TypedNode.class) |
29 public abstract class WriteLocalNode extends FrameSlotNode { | 30 public abstract class WriteLocalNode extends FrameSlotNode { |
34 | 35 |
35 public WriteLocalNode(WriteLocalNode node) { | 36 public WriteLocalNode(WriteLocalNode node) { |
36 this(node.slot); | 37 this(node.slot); |
37 } | 38 } |
38 | 39 |
39 @Specialization | 40 @Specialization(guards = "isIntKind") |
40 public int write(VirtualFrame frame, int right) { | 41 public int write(VirtualFrame frame, int right) { |
41 frame.setInt(slot, right); | 42 frame.setInt(slot, right); |
42 return right; | 43 return right; |
43 } | 44 } |
44 | 45 |
45 @Specialization | 46 @Specialization(guards = "isBooleanKind") |
46 public boolean write(VirtualFrame frame, boolean right) { | 47 public boolean write(VirtualFrame frame, boolean right) { |
47 frame.setBoolean(slot, right); | 48 frame.setBoolean(slot, right); |
48 return right; | 49 return right; |
49 } | 50 } |
50 | 51 |
51 @Specialization | 52 @Specialization(guards = "isObjectKind") |
52 public Object writeGeneric(VirtualFrame frame, Object right) { | 53 public Object writeGeneric(VirtualFrame frame, Object right) { |
53 frame.setObject(slot, right); | 54 frame.setObject(slot, right); |
54 return right; | 55 return right; |
55 } | 56 } |
56 | 57 |
58 protected final boolean isIntKind() { | |
59 return isKind(FrameSlotKind.Int); | |
60 } | |
61 | |
62 protected final boolean isBooleanKind() { | |
63 return isKind(FrameSlotKind.Boolean); | |
64 } | |
65 | |
66 protected final boolean isObjectKind() { | |
67 if (slot.getKind() != FrameSlotKind.Object) { | |
68 CompilerDirectives.transferToInterpreter(); | |
69 slot.setKind(FrameSlotKind.Object); | |
70 } | |
71 return true; | |
72 } | |
73 | |
74 private boolean isKind(FrameSlotKind kind) { | |
75 return slot.getKind() == kind || initialSetKind(kind); | |
76 } | |
77 | |
78 private boolean initialSetKind(FrameSlotKind kind) { | |
79 if (slot.getKind() == FrameSlotKind.Illegal) { | |
80 CompilerDirectives.transferToInterpreter(); | |
81 slot.setKind(kind); | |
82 return true; | |
83 } | |
84 return false; | |
85 } | |
86 | |
57 } | 87 } |