Mercurial > hg > graal-compiler
annotate 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 |
rev | line source |
---|---|
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.sl.nodes; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import com.oracle.truffle.api.codegen.*; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 import com.oracle.truffle.api.frame.*; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 |
9222
aa9ffb3a715e
Updated Truffle-SL to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
8277
diff
changeset
|
28 @NodeChild(value = "rightNode", type = TypedNode.class) |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 public abstract class WriteLocalNode extends FrameSlotNode { |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 |
9222
aa9ffb3a715e
Updated Truffle-SL to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
8277
diff
changeset
|
31 public WriteLocalNode(FrameSlot slot) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 super(slot); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 public WriteLocalNode(WriteLocalNode node) { |
9222
aa9ffb3a715e
Updated Truffle-SL to new codegen API.
Christian Humer <christian.humer@gmail.com>
parents:
8277
diff
changeset
|
36 this(node.slot); |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
39 @Specialization(rewriteOn = FrameSlotTypeException.class) |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
40 public int write(VirtualFrame frame, int right) throws FrameSlotTypeException { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
41 try { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
42 frame.setInt(slot, right); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
43 } catch (FrameSlotTypeException e) { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
44 if (slot.getType() == null) { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
45 FrameUtil.setIntSafe(frame, slot, right); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
46 } else { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
47 throw e; |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
48 } |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
49 } |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 return right; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
53 @Specialization(rewriteOn = FrameSlotTypeException.class) |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
54 public boolean write(VirtualFrame frame, boolean right) throws FrameSlotTypeException { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
55 try { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
56 frame.setBoolean(slot, right); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
57 } catch (FrameSlotTypeException e) { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
58 if (slot.getType() == null) { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
59 FrameUtil.setBooleanSafe(frame, slot, right); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
60 } else { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
61 throw e; |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
62 } |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
63 } |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 return right; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 |
8277
97ee911c4c74
Fixed behaviour of useSpecializations for Generic specializations.
Christian Humer <christian.humer@gmail.com>
parents:
8260
diff
changeset
|
67 @Generic(useSpecializations = false) |
8260
b81f42160093
Fix use specializations in generic until further fixes are done.
Christian Humer <christian.humer@gmail.com>
parents:
8254
diff
changeset
|
68 public Object writeGeneric(VirtualFrame frame, Object right) { |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
69 try { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
70 frame.setObject(slot, right); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
71 } catch (FrameSlotTypeException e) { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
72 FrameUtil.setObjectSafe(frame, slot, right); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9222
diff
changeset
|
73 } |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 return right; |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 @Override |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7503
diff
changeset
|
78 protected FrameSlotNode specialize(Class<?> clazz) { |
7503
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 return WriteLocalNodeFactory.createSpecialized(this, clazz); |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 } |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 |
31da1716950f
Updated truffle-sl for the changed operation code generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 } |