Mercurial > hg > graal-compiler
diff 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 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java Sun Dec 15 23:32:41 2013 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java Tue Dec 17 15:44:02 2013 +0100 @@ -22,6 +22,7 @@ */ package com.oracle.truffle.sl.nodes; +import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; @@ -36,22 +37,51 @@ this(node.slot); } - @Specialization + @Specialization(guards = "isIntKind") public int write(VirtualFrame frame, int right) { frame.setInt(slot, right); return right; } - @Specialization + @Specialization(guards = "isBooleanKind") public boolean write(VirtualFrame frame, boolean right) { frame.setBoolean(slot, right); return right; } - @Specialization + @Specialization(guards = "isObjectKind") public Object writeGeneric(VirtualFrame frame, Object right) { frame.setObject(slot, right); return right; } + protected final boolean isIntKind() { + return isKind(FrameSlotKind.Int); + } + + protected final boolean isBooleanKind() { + return isKind(FrameSlotKind.Boolean); + } + + protected final boolean isObjectKind() { + if (slot.getKind() != FrameSlotKind.Object) { + CompilerDirectives.transferToInterpreter(); + slot.setKind(FrameSlotKind.Object); + } + return true; + } + + private boolean isKind(FrameSlotKind kind) { + return slot.getKind() == kind || initialSetKind(kind); + } + + private boolean initialSetKind(FrameSlotKind kind) { + if (slot.getKind() == FrameSlotKind.Illegal) { + CompilerDirectives.transferToInterpreter(); + slot.setKind(kind); + return true; + } + return false; + } + }