67
67
import com .oracle .truffle .api .dsl .ImportStatic ;
68
68
import com .oracle .truffle .api .dsl .Specialization ;
69
69
import com .oracle .truffle .api .frame .FrameDescriptor ;
70
- import com .oracle .truffle .api .frame .FrameSlot ;
71
70
import com .oracle .truffle .api .frame .MaterializedFrame ;
72
71
import com .oracle .truffle .api .frame .VirtualFrame ;
73
72
import com .oracle .truffle .api .library .CachedLibrary ;
77
76
import com .oracle .truffle .api .profiles .ConditionProfile ;
78
77
79
78
@ ExportLibrary (HashingStorageLibrary .class )
79
+ @ SuppressWarnings ("deprecation" ) // new Frame API
80
80
public final class LocalsStorage extends HashingStorage {
81
81
/* This won't be the real (materialized) frame but a clone of it. */
82
82
protected final MaterializedFrame frame ;
@@ -94,11 +94,11 @@ public MaterializedFrame getFrame() {
94
94
return this .frame ;
95
95
}
96
96
97
- private Object getValue (FrameSlot slot ) {
97
+ private Object getValue (com . oracle . truffle . api . frame . FrameSlot slot ) {
98
98
return getValue (this .frame , slot );
99
99
}
100
100
101
- private static Object getValue (MaterializedFrame frame , FrameSlot slot ) {
101
+ private static Object getValue (MaterializedFrame frame , com . oracle . truffle . api . frame . FrameSlot slot ) {
102
102
if (slot != null ) {
103
103
Object value = frame .getValue (slot );
104
104
if (value instanceof PCell ) {
@@ -122,32 +122,34 @@ public int length() {
122
122
@ TruffleBoundary
123
123
private void calculateLength () {
124
124
this .len = this .frame .getFrameDescriptor ().getSize ();
125
- for (FrameSlot slot : this .frame .getFrameDescriptor ().getSlots ()) {
125
+ for (com . oracle . truffle . api . frame . FrameSlot slot : this .frame .getFrameDescriptor ().getSlots ()) {
126
126
Object identifier = slot .getIdentifier ();
127
127
if (!isUserFrameSlot (identifier ) || getValue (frame , slot ) == null ) {
128
128
this .len --;
129
129
}
130
130
}
131
131
}
132
132
133
- @ SuppressWarnings ("unused" )
133
+ @ SuppressWarnings ({ "unused" , "deprecation" }) // new frame API
134
134
@ ExportMessage
135
135
@ ImportStatic (PGuards .class )
136
136
static class GetItemWithState {
137
137
@ Specialization (guards = {"key == cachedKey" , "desc == self.frame.getFrameDescriptor()" }, limit = "3" , assumptions = "desc.getVersion()" )
138
+ @ SuppressWarnings ("deprecation" ) // new Frame API
138
139
static Object getItemCached (LocalsStorage self , String key , ThreadState state ,
139
140
@ Cached ("key" ) String cachedKey ,
140
141
@ Cached ("self.frame.getFrameDescriptor()" ) FrameDescriptor desc ,
141
- @ Cached ("desc.findFrameSlot(key)" ) FrameSlot slot ) {
142
+ @ Cached ("desc.findFrameSlot(key)" ) com . oracle . truffle . api . frame . FrameSlot slot ) {
142
143
return self .getValue (slot );
143
144
}
144
145
145
146
@ Specialization (replaces = "getItemCached" )
147
+ @ SuppressWarnings ("deprecation" ) // new Frame API
146
148
static Object string (LocalsStorage self , String key , ThreadState state ) {
147
149
if (!isUserFrameSlot (key )) {
148
150
return null ;
149
151
}
150
- FrameSlot slot = findSlot (self , key );
152
+ com . oracle . truffle . api . frame . FrameSlot slot = findSlot (self , key );
151
153
return self .getValue (slot );
152
154
}
153
155
@@ -158,6 +160,7 @@ static Object pstring(LocalsStorage self, PString key, ThreadState state,
158
160
}
159
161
160
162
@ Specialization (guards = "!isBuiltinString(key, profile)" , limit = "1" )
163
+ @ SuppressWarnings ("deprecation" ) // new Frame API
161
164
static Object notString (LocalsStorage self , Object key , ThreadState state ,
162
165
@ Shared ("builtinProfile" ) @ Cached IsBuiltinClassProfile profile ,
163
166
@ Cached PyObjectRichCompareBool .EqNode eqNode ,
@@ -166,7 +169,7 @@ static Object notString(LocalsStorage self, Object key, ThreadState state,
166
169
CompilerDirectives .bailout ("accessing locals storage with non-string keys is slow" );
167
170
VirtualFrame frame = gotState .profile (state == null ) ? null : PArguments .frameForCall (state );
168
171
long hash = hashNode .execute (frame , key );
169
- for (FrameSlot slot : self .frame .getFrameDescriptor ().getSlots ()) {
172
+ for (com . oracle . truffle . api . frame . FrameSlot slot : self .frame .getFrameDescriptor ().getSlots ()) {
170
173
Object currentKey = slot .getIdentifier ();
171
174
if (currentKey instanceof String ) {
172
175
long keyHash = hashNode .execute (frame , currentKey );
@@ -179,7 +182,8 @@ static Object notString(LocalsStorage self, Object key, ThreadState state,
179
182
}
180
183
181
184
@ TruffleBoundary
182
- private static FrameSlot findSlot (LocalsStorage self , Object key ) {
185
+ @ SuppressWarnings ("deprecation" ) // new Frame API
186
+ private static com .oracle .truffle .api .frame .FrameSlot findSlot (LocalsStorage self , Object key ) {
183
187
return self .frame .getFrameDescriptor ().findFrameSlot (key );
184
188
}
185
189
}
@@ -217,9 +221,10 @@ private HashingStorage generalize(HashingStorageLibrary lib, boolean isStringKey
217
221
@ ExportMessage
218
222
@ TruffleBoundary
219
223
@ Override
224
+ @ SuppressWarnings ("deprecation" ) // new Frame API
220
225
public Object forEachUntyped (ForEachNode <Object > node , Object arg ) {
221
226
Object result = arg ;
222
- for (FrameSlot slot : this .frame .getFrameDescriptor ().getSlots ()) {
227
+ for (com . oracle . truffle . api . frame . FrameSlot slot : this .frame .getFrameDescriptor ().getSlots ()) {
223
228
Object identifier = slot .getIdentifier ();
224
229
if (identifier instanceof String ) {
225
230
if (isUserFrameSlot (identifier )) {
@@ -235,19 +240,21 @@ public Object forEachUntyped(ForEachNode<Object> node, Object arg) {
235
240
236
241
@ ExportMessage
237
242
static class AddAllToOther {
238
- protected static FrameSlot [] getSlots (FrameDescriptor desc ) {
239
- return desc .getSlots ().toArray (new FrameSlot [0 ]);
243
+ @ SuppressWarnings ("deprecation" ) // new Frame API
244
+ protected static com .oracle .truffle .api .frame .FrameSlot [] getSlots (FrameDescriptor desc ) {
245
+ return desc .getSlots ().toArray (new com .oracle .truffle .api .frame .FrameSlot [0 ]);
240
246
}
241
247
242
248
@ Specialization (guards = {"desc == self.frame.getFrameDescriptor()" }, limit = "1" , assumptions = "desc.getVersion()" )
243
249
@ ExplodeLoop
250
+ @ SuppressWarnings ("deprecation" ) // new Frame API
244
251
static HashingStorage cached (LocalsStorage self , HashingStorage other ,
245
252
@ CachedLibrary (limit = "2" ) HashingStorageLibrary lib ,
246
253
@ Exclusive @ SuppressWarnings ("unused" ) @ Cached ("self.frame.getFrameDescriptor()" ) FrameDescriptor desc ,
247
- @ Exclusive @ Cached (value = "getSlots(desc)" , dimensions = 1 ) FrameSlot [] slots ) {
254
+ @ Exclusive @ Cached (value = "getSlots(desc)" , dimensions = 1 ) com . oracle . truffle . api . frame . FrameSlot [] slots ) {
248
255
HashingStorage result = other ;
249
256
for (int i = 0 ; i < slots .length ; i ++) {
250
- FrameSlot slot = slots [i ];
257
+ com . oracle . truffle . api . frame . FrameSlot slot = slots [i ];
251
258
Object value = self .getValue (slot );
252
259
if (value != null ) {
253
260
result = lib .setItem (result , slot .getIdentifier (), value );
@@ -258,12 +265,13 @@ static HashingStorage cached(LocalsStorage self, HashingStorage other,
258
265
259
266
@ Specialization (replaces = "cached" )
260
267
@ TruffleBoundary
268
+ @ SuppressWarnings ("deprecation" ) // new Frame API
261
269
static HashingStorage generic (LocalsStorage self , HashingStorage other ,
262
270
@ CachedLibrary (limit = "2" ) HashingStorageLibrary lib ) {
263
271
HashingStorage result = other ;
264
- FrameSlot [] slots = getSlots (self .frame .getFrameDescriptor ());
272
+ com . oracle . truffle . api . frame . FrameSlot [] slots = getSlots (self .frame .getFrameDescriptor ());
265
273
for (int i = 0 ; i < slots .length ; i ++) {
266
- FrameSlot slot = slots [i ];
274
+ com . oracle . truffle . api . frame . FrameSlot slot = slots [i ];
267
275
Object value = self .getValue (slot );
268
276
if (value != null ) {
269
277
result = lib .setItem (result , slot .getIdentifier (), value );
@@ -296,12 +304,13 @@ public HashingStorageIterable<Object> reverseKeys() {
296
304
return new HashingStorageIterable <>(new ReverseLocalsIterator (this .frame ));
297
305
}
298
306
307
+ @ SuppressWarnings ("deprecation" ) // new Frame API
299
308
protected abstract static class AbstractLocalsIterator implements Iterator <Object > {
300
- protected List <? extends FrameSlot > slots ;
309
+ protected List <? extends com . oracle . truffle . api . frame . FrameSlot > slots ;
301
310
protected final int size ;
302
311
protected int index ;
303
312
protected final MaterializedFrame frame ;
304
- protected FrameSlot nextFrameSlot = null ;
313
+ protected com . oracle . truffle . api . frame . FrameSlot nextFrameSlot = null ;
305
314
306
315
AbstractLocalsIterator (MaterializedFrame frame ) {
307
316
this .frame = frame ;
@@ -311,7 +320,7 @@ protected abstract static class AbstractLocalsIterator implements Iterator<Objec
311
320
}
312
321
313
322
@ TruffleBoundary
314
- private static List <? extends FrameSlot > getSlots (MaterializedFrame frame ) {
323
+ private static List <? extends com . oracle . truffle . api . frame . FrameSlot > getSlots (MaterializedFrame frame ) {
315
324
return frame .getFrameDescriptor ().getSlots ();
316
325
}
317
326
@@ -348,10 +357,10 @@ public Object next() {
348
357
}
349
358
350
359
@ TruffleBoundary
351
- public FrameSlot nextSlot () {
360
+ public com . oracle . truffle . api . frame . FrameSlot nextSlot () {
352
361
if (hasNext ()) {
353
362
assert this .nextFrameSlot != null ;
354
- FrameSlot value = this .nextFrameSlot ;
363
+ com . oracle . truffle . api . frame . FrameSlot value = this .nextFrameSlot ;
355
364
this .nextFrameSlot = null ;
356
365
return value ;
357
366
}
@@ -368,9 +377,10 @@ private static final class LocalsIterator extends AbstractLocalsIterator {
368
377
369
378
@ TruffleBoundary
370
379
@ Override
380
+ @ SuppressWarnings ("deprecation" ) // new Frame API
371
381
protected boolean loadNext () {
372
382
while (this .index < this .size ) {
373
- FrameSlot nextCandidate = this .slots .get (this .index ++);
383
+ com . oracle . truffle . api . frame . FrameSlot nextCandidate = this .slots .get (this .index ++);
374
384
Object identifier = nextCandidate .getIdentifier ();
375
385
if (identifier instanceof String ) {
376
386
if (isUserFrameSlot (identifier )) {
@@ -395,9 +405,10 @@ private static final class ReverseLocalsIterator extends AbstractLocalsIterator
395
405
396
406
@ TruffleBoundary
397
407
@ Override
408
+ @ SuppressWarnings ("deprecation" ) // new Frame API
398
409
protected boolean loadNext () {
399
410
while (this .index >= 0 ) {
400
- FrameSlot nextCandidate = this .slots .get (this .index --);
411
+ com . oracle . truffle . api . frame . FrameSlot nextCandidate = this .slots .get (this .index --);
401
412
Object identifier = nextCandidate .getIdentifier ();
402
413
if (identifier instanceof String ) {
403
414
if (isUserFrameSlot (identifier )) {
0 commit comments