Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java @ 9258:07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 23 Apr 2013 15:34:06 +0200 |
parents | aa9ffb3a715e |
children | 8cf939b349dd |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java Tue Apr 23 15:08:11 2013 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java Tue Apr 23 15:34:06 2013 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.truffle.sl.nodes; -import java.math.*; - import com.oracle.truffle.api.codegen.*; import com.oracle.truffle.api.frame.*; @@ -38,42 +36,44 @@ this(node.slot); } - @Specialization - public int write(VirtualFrame frame, int right) { - frame.setInt(slot, right); + @Specialization(rewriteOn = FrameSlotTypeException.class) + public int write(VirtualFrame frame, int right) throws FrameSlotTypeException { + try { + frame.setInt(slot, right); + } catch (FrameSlotTypeException e) { + if (slot.getType() == null) { + FrameUtil.setIntSafe(frame, slot, right); + } else { + throw e; + } + } return right; } - @Specialization - public BigInteger write(VirtualFrame frame, BigInteger right) { - frame.setObject(slot, right); - return right; - } - - @Specialization - public boolean write(VirtualFrame frame, boolean right) { - frame.setBoolean(slot, right); - return right; - } - - @Specialization - public String write(VirtualFrame frame, String right) { - frame.setObject(slot, right); + @Specialization(rewriteOn = FrameSlotTypeException.class) + public boolean write(VirtualFrame frame, boolean right) throws FrameSlotTypeException { + try { + frame.setBoolean(slot, right); + } catch (FrameSlotTypeException e) { + if (slot.getType() == null) { + FrameUtil.setBooleanSafe(frame, slot, right); + } else { + throw e; + } + } return right; } @Generic(useSpecializations = false) public Object writeGeneric(VirtualFrame frame, Object right) { - frame.setObject(slot, right); + try { + frame.setObject(slot, right); + } catch (FrameSlotTypeException e) { + FrameUtil.setObjectSafe(frame, slot, right); + } return right; } - @SpecializationListener - protected void onSpecialize(VirtualFrame frame, Object value) { - slot.setType(value.getClass()); - frame.updateToLatestVersion(); - } - @Override protected FrameSlotNode specialize(Class<?> clazz) { return WriteLocalNodeFactory.createSpecialized(this, clazz);