Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java @ 14991:64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 06 Apr 2014 17:46:24 +0200 |
parents | 856a9864ed93 |
children | 422f913e9310 |
comparison
equal
deleted
inserted
replaced
14989:a0dbb3628f2a | 14991:64dcb92ee75a |
---|---|
22 * or visit www.oracle.com if you need additional information or have any | 22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. | 23 * questions. |
24 */ | 24 */ |
25 package com.oracle.truffle.api.frame; | 25 package com.oracle.truffle.api.frame; |
26 | 26 |
27 import com.oracle.truffle.api.*; | |
28 | |
29 /** | 27 /** |
30 * Represents a frame containing values of local variables of the guest language. Instances of this | 28 * Represents a frame containing values of local variables of the guest language. Instances of this |
31 * type must not be stored in a field or cast to {@link java.lang.Object}. | 29 * type must not be stored in a field or cast to {@link java.lang.Object}. |
32 */ | 30 */ |
33 public interface Frame { | 31 public interface Frame { |
37 */ | 35 */ |
38 FrameDescriptor getFrameDescriptor(); | 36 FrameDescriptor getFrameDescriptor(); |
39 | 37 |
40 /** | 38 /** |
41 * Retrieves the arguments object from this frame. The runtime assumes that the arguments object | 39 * Retrieves the arguments object from this frame. The runtime assumes that the arguments object |
42 * is never null. Additionally, the runtime may assume that the given parameter indicating the | 40 * is never null. |
43 * class of the arguments object is correct. The runtime is not required to actually check the | 41 * |
44 * type of the arguments object. The parameter must be a value that can be reduced to a compile | |
45 * time constant. | |
46 * | |
47 * @param clazz the known type of the arguments object as a compile time constant | |
48 * @return the arguments used when calling this method | 42 * @return the arguments used when calling this method |
49 */ | 43 */ |
50 <T extends Arguments> T getArguments(Class<T> clazz); | 44 Object[] getArguments(); |
51 | 45 |
52 /** | 46 /** |
53 * Read access to a local variable of type {@link Object}. | 47 * Read access to a local variable of type {@link Object}. |
54 * | 48 * |
55 * @param slot the slot of the local variable | 49 * @param slot the slot of the local variable |
56 * @return the current value of the local variable | 50 * @return the current value of the local variable |
57 */ | 51 */ |
58 Object getObject(FrameSlot slot) throws FrameSlotTypeException; | 52 Object getObject(FrameSlot slot) throws FrameSlotTypeException; |
59 | 53 |
60 /** | 54 /** |
61 * Write access to a local variable of type {@link Object}. | 55 * Write access to a local variable of type {@link Object}. |
62 * | 56 * |
63 * @param slot the slot of the local variable | 57 * @param slot the slot of the local variable |
64 * @param value the new value of the local variable | 58 * @param value the new value of the local variable |
65 */ | 59 */ |
66 void setObject(FrameSlot slot, Object value); | 60 void setObject(FrameSlot slot, Object value); |
67 | 61 |
68 /** | 62 /** |
69 * Read access to a local variable of type byte. | 63 * Read access to a local variable of type byte. |
70 * | 64 * |
71 * @param slot the slot of the local variable | 65 * @param slot the slot of the local variable |
72 * @return the current value of the local variable | 66 * @return the current value of the local variable |
73 * @throws FrameSlotTypeException | 67 * @throws FrameSlotTypeException |
74 */ | 68 */ |
75 byte getByte(FrameSlot slot) throws FrameSlotTypeException; | 69 byte getByte(FrameSlot slot) throws FrameSlotTypeException; |
76 | 70 |
77 /** | 71 /** |
78 * Write access to a local variable of type byte. | 72 * Write access to a local variable of type byte. |
79 * | 73 * |
80 * @param slot the slot of the local variable | 74 * @param slot the slot of the local variable |
81 * @param value the new value of the local variable | 75 * @param value the new value of the local variable |
82 */ | 76 */ |
83 | 77 |
84 void setByte(FrameSlot slot, byte value); | 78 void setByte(FrameSlot slot, byte value); |
85 | 79 |
86 /** | 80 /** |
87 * Read access to a local variable of type boolean. | 81 * Read access to a local variable of type boolean. |
88 * | 82 * |
89 * @param slot the slot of the local variable | 83 * @param slot the slot of the local variable |
90 * @return the current value of the local variable | 84 * @return the current value of the local variable |
91 */ | 85 */ |
92 boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException; | 86 boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException; |
93 | 87 |
94 /** | 88 /** |
95 * Write access to a local variable of type boolean. | 89 * Write access to a local variable of type boolean. |
96 * | 90 * |
97 * @param slot the slot of the local variable | 91 * @param slot the slot of the local variable |
98 * @param value the new value of the local variable | 92 * @param value the new value of the local variable |
99 */ | 93 */ |
100 void setBoolean(FrameSlot slot, boolean value); | 94 void setBoolean(FrameSlot slot, boolean value); |
101 | 95 |
102 /** | 96 /** |
103 * Read access to a local variable of type int. | 97 * Read access to a local variable of type int. |
104 * | 98 * |
105 * @param slot the slot of the local variable | 99 * @param slot the slot of the local variable |
106 * @return the current value of the local variable | 100 * @return the current value of the local variable |
107 */ | 101 */ |
108 int getInt(FrameSlot slot) throws FrameSlotTypeException; | 102 int getInt(FrameSlot slot) throws FrameSlotTypeException; |
109 | 103 |
110 /** | 104 /** |
111 * Write access to a local variable of type int. | 105 * Write access to a local variable of type int. |
112 * | 106 * |
113 * @param slot the slot of the local variable | 107 * @param slot the slot of the local variable |
114 * @param value the new value of the local variable | 108 * @param value the new value of the local variable |
115 */ | 109 */ |
116 void setInt(FrameSlot slot, int value); | 110 void setInt(FrameSlot slot, int value); |
117 | 111 |
118 /** | 112 /** |
119 * Read access to a local variable of type long. | 113 * Read access to a local variable of type long. |
120 * | 114 * |
121 * @param slot the slot of the local variable | 115 * @param slot the slot of the local variable |
122 * @return the current value of the local variable | 116 * @return the current value of the local variable |
123 */ | 117 */ |
124 long getLong(FrameSlot slot) throws FrameSlotTypeException; | 118 long getLong(FrameSlot slot) throws FrameSlotTypeException; |
125 | 119 |
126 /** | 120 /** |
127 * Write access to a local variable of type long. | 121 * Write access to a local variable of type long. |
128 * | 122 * |
129 * @param slot the slot of the local variable | 123 * @param slot the slot of the local variable |
130 * @param value the new value of the local variable | 124 * @param value the new value of the local variable |
131 */ | 125 */ |
132 void setLong(FrameSlot slot, long value); | 126 void setLong(FrameSlot slot, long value); |
133 | 127 |
134 /** | 128 /** |
135 * Read access to a local variable of type float. | 129 * Read access to a local variable of type float. |
136 * | 130 * |
137 * @param slot the slot of the local variable | 131 * @param slot the slot of the local variable |
138 * @return the current value of the local variable | 132 * @return the current value of the local variable |
139 */ | 133 */ |
140 float getFloat(FrameSlot slot) throws FrameSlotTypeException; | 134 float getFloat(FrameSlot slot) throws FrameSlotTypeException; |
141 | 135 |
142 /** | 136 /** |
143 * Write access to a local variable of type float. | 137 * Write access to a local variable of type float. |
144 * | 138 * |
145 * @param slot the slot of the local variable | 139 * @param slot the slot of the local variable |
146 * @param value the new value of the local variable | 140 * @param value the new value of the local variable |
147 */ | 141 */ |
148 void setFloat(FrameSlot slot, float value); | 142 void setFloat(FrameSlot slot, float value); |
149 | 143 |
150 /** | 144 /** |
151 * Read access to a local variable of type double. | 145 * Read access to a local variable of type double. |
152 * | 146 * |
153 * @param slot the slot of the local variable | 147 * @param slot the slot of the local variable |
154 * @return the current value of the local variable | 148 * @return the current value of the local variable |
155 */ | 149 */ |
156 double getDouble(FrameSlot slot) throws FrameSlotTypeException; | 150 double getDouble(FrameSlot slot) throws FrameSlotTypeException; |
157 | 151 |
158 /** | 152 /** |
159 * Write access to a local variable of type double. | 153 * Write access to a local variable of type double. |
160 * | 154 * |
161 * @param slot the slot of the local variable | 155 * @param slot the slot of the local variable |
162 * @param value the new value of the local variable | 156 * @param value the new value of the local variable |
163 */ | 157 */ |
164 void setDouble(FrameSlot slot, double value); | 158 void setDouble(FrameSlot slot, double value); |
165 | 159 |
166 /** | 160 /** |
167 * Read access to a local variable of any type. | 161 * Read access to a local variable of any type. |
168 * | 162 * |
169 * @param slot the slot of the local variable | 163 * @param slot the slot of the local variable |
170 * @return the current value of the local variable or defaultValue if unset | 164 * @return the current value of the local variable or defaultValue if unset |
171 */ | 165 */ |
172 Object getValue(FrameSlot slot); | 166 Object getValue(FrameSlot slot); |
173 | |
174 /** | |
175 * Converts this virtual frame into a packed frame that has no longer direct access to the local | |
176 * variables. This packing is an important hint to the Truffle optimizer and therefore passing | |
177 * around a {@link PackedFrame} should be preferred over passing around a {@link VirtualFrame} | |
178 * when the probability that an unpacking will occur is low. | |
179 * | |
180 * @return the packed frame | |
181 */ | |
182 PackedFrame pack(); | |
183 | 167 |
184 /** | 168 /** |
185 * Materializes this frame, which allows it to be stored in a field or cast to | 169 * Materializes this frame, which allows it to be stored in a field or cast to |
186 * {@link java.lang.Object}. The frame however looses the ability to be packed or to access the | 170 * {@link java.lang.Object}. The frame however looses the ability to be packed or to access the |
187 * caller frame. | 171 * caller frame. |
188 * | 172 * |
189 * @return the new materialized frame | 173 * @return the new materialized frame |
190 */ | 174 */ |
191 MaterializedFrame materialize(); | 175 MaterializedFrame materialize(); |
192 | 176 |
193 /** | 177 /** |