Skip to content

Commit 9e999ad

Browse files
committed
Suppressed deprecation warnings for the new Frame API
1 parent 6673dcd commit 9e999ad

33 files changed

+245
-220
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/parser/BasicTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public void assert04() throws Exception {
129129
}
130130

131131
@Test
132+
@SuppressWarnings("deprecation") // new Frame API
132133
public void inline01() throws Exception {
133134
FrameDescriptor fd = new FrameDescriptor(44);
134135
fd.addFrameSlot("a");

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/parser/ParserTreePrinter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
import com.oracle.graal.python.parser.GeneratorInfo;
8181
import com.oracle.graal.python.runtime.ExecutionContext;
8282
import com.oracle.truffle.api.frame.FrameDescriptor;
83-
import com.oracle.truffle.api.frame.FrameSlot;
8483
import com.oracle.truffle.api.nodes.Node;
8584
import com.oracle.truffle.api.nodes.NodeVisitor;
8685
import com.oracle.truffle.api.nodes.RootNode;
@@ -483,6 +482,7 @@ private void addSignature(Signature signature) {
483482
level--;
484483
}
485484

485+
@SuppressWarnings("deprecation") // new Frame API
486486
private void addFrameDescriptor(FrameDescriptor fd) {
487487
indent(level);
488488
sb.append("FrameDescriptor: ");
@@ -535,12 +535,13 @@ private void add(String[] array) {
535535
}
536536
}
537537

538-
private void add(FrameSlot[] slots) {
538+
@SuppressWarnings("deprecation") // new Frame API
539+
private void add(com.oracle.truffle.api.frame.FrameSlot[] slots) {
539540
if (slots == null || slots.length == 0) {
540541
sb.append("None");
541542
} else {
542543
boolean first = true;
543-
for (FrameSlot slot : slots) {
544+
for (com.oracle.truffle.api.frame.FrameSlot slot : slots) {
544545
if (!first) {
545546
sb.append(", ");
546547
} else {
@@ -551,7 +552,8 @@ private void add(FrameSlot[] slots) {
551552
}
552553
}
553554

554-
private void add(FrameSlot slot) {
555+
@SuppressWarnings("deprecation") // new Frame API
556+
private void add(com.oracle.truffle.api.frame.FrameSlot slot) {
555557
if (printTmpSlots) {
556558
sb.append(slot.toString());
557559
} else {

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/parser/SSTSerializationTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import com.oracle.graal.python.runtime.PythonCodeSerializer;
6262
import com.oracle.graal.python.runtime.PythonParser;
6363
import com.oracle.truffle.api.TruffleFile;
64-
import com.oracle.truffle.api.frame.FrameSlot;
6564
import com.oracle.truffle.api.nodes.RootNode;
6665
import com.oracle.truffle.api.source.Source;
6766

@@ -1347,13 +1346,14 @@ private static void printSet(StringBuilder sb, Set<String> set) {
13471346
}
13481347
}
13491348

1350-
private static void printFrameSlots(StringBuilder sb, FrameSlot[] slots) {
1349+
@SuppressWarnings("deprecation") // new Frame API
1350+
private static void printFrameSlots(StringBuilder sb, com.oracle.truffle.api.frame.FrameSlot[] slots) {
13511351
if (slots.length == 0) {
13521352
sb.append("Empty");
13531353
} else {
13541354
sb.append("[");
13551355
boolean first = true;
1356-
for (FrameSlot slot : slots) {
1356+
for (com.oracle.truffle.api.frame.FrameSlot slot : slots) {
13571357
if (first) {
13581358
sb.append(slot.getIdentifier());
13591359
first = false;
@@ -1366,6 +1366,7 @@ private static void printFrameSlots(StringBuilder sb, FrameSlot[] slots) {
13661366

13671367
// here we can not use the ScopeInfo.debugPrint(), because we need exclude the temporary
13681368
// variables.
1369+
@SuppressWarnings("deprecation") // new Frame API
13691370
private static void printScope(ScopeInfo scope, StringBuilder sb, int indent) {
13701371
indent(sb, indent);
13711372
sb.append("Scope: ").append(scope.getScopeId()).append("\n");

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,13 @@ private static String extractName(RootNode rootNode) {
243243
}
244244

245245
@TruffleBoundary
246+
@SuppressWarnings("deprecation") // new Frame API
246247
private static int extractStackSize(RootNode rootNode) {
247248
return rootNode.getFrameDescriptor().getSize();
248249
}
249250

250251
@TruffleBoundary
252+
@SuppressWarnings("deprecation") // new Frame API
251253
private static Object[] extractVarnames(RootNode rootNode, String[] parameterIds, String[] keywordNames, Object[] freeVars, Object[] cellVars) {
252254
Set<Object> freeVarsSet = asSet(freeVars);
253255
Set<Object> cellVarsSet = asSet(cellVars);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/LocalsStorage.java

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import com.oracle.truffle.api.dsl.ImportStatic;
6868
import com.oracle.truffle.api.dsl.Specialization;
6969
import com.oracle.truffle.api.frame.FrameDescriptor;
70-
import com.oracle.truffle.api.frame.FrameSlot;
7170
import com.oracle.truffle.api.frame.MaterializedFrame;
7271
import com.oracle.truffle.api.frame.VirtualFrame;
7372
import com.oracle.truffle.api.library.CachedLibrary;
@@ -77,6 +76,7 @@
7776
import com.oracle.truffle.api.profiles.ConditionProfile;
7877

7978
@ExportLibrary(HashingStorageLibrary.class)
79+
@SuppressWarnings("deprecation") // new Frame API
8080
public final class LocalsStorage extends HashingStorage {
8181
/* This won't be the real (materialized) frame but a clone of it. */
8282
protected final MaterializedFrame frame;
@@ -94,11 +94,11 @@ public MaterializedFrame getFrame() {
9494
return this.frame;
9595
}
9696

97-
private Object getValue(FrameSlot slot) {
97+
private Object getValue(com.oracle.truffle.api.frame.FrameSlot slot) {
9898
return getValue(this.frame, slot);
9999
}
100100

101-
private static Object getValue(MaterializedFrame frame, FrameSlot slot) {
101+
private static Object getValue(MaterializedFrame frame, com.oracle.truffle.api.frame.FrameSlot slot) {
102102
if (slot != null) {
103103
Object value = frame.getValue(slot);
104104
if (value instanceof PCell) {
@@ -122,32 +122,34 @@ public int length() {
122122
@TruffleBoundary
123123
private void calculateLength() {
124124
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()) {
126126
Object identifier = slot.getIdentifier();
127127
if (!isUserFrameSlot(identifier) || getValue(frame, slot) == null) {
128128
this.len--;
129129
}
130130
}
131131
}
132132

133-
@SuppressWarnings("unused")
133+
@SuppressWarnings({"unused", "deprecation"}) // new frame API
134134
@ExportMessage
135135
@ImportStatic(PGuards.class)
136136
static class GetItemWithState {
137137
@Specialization(guards = {"key == cachedKey", "desc == self.frame.getFrameDescriptor()"}, limit = "3", assumptions = "desc.getVersion()")
138+
@SuppressWarnings("deprecation") // new Frame API
138139
static Object getItemCached(LocalsStorage self, String key, ThreadState state,
139140
@Cached("key") String cachedKey,
140141
@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) {
142143
return self.getValue(slot);
143144
}
144145

145146
@Specialization(replaces = "getItemCached")
147+
@SuppressWarnings("deprecation") // new Frame API
146148
static Object string(LocalsStorage self, String key, ThreadState state) {
147149
if (!isUserFrameSlot(key)) {
148150
return null;
149151
}
150-
FrameSlot slot = findSlot(self, key);
152+
com.oracle.truffle.api.frame.FrameSlot slot = findSlot(self, key);
151153
return self.getValue(slot);
152154
}
153155

@@ -158,6 +160,7 @@ static Object pstring(LocalsStorage self, PString key, ThreadState state,
158160
}
159161

160162
@Specialization(guards = "!isBuiltinString(key, profile)", limit = "1")
163+
@SuppressWarnings("deprecation") // new Frame API
161164
static Object notString(LocalsStorage self, Object key, ThreadState state,
162165
@Shared("builtinProfile") @Cached IsBuiltinClassProfile profile,
163166
@Cached PyObjectRichCompareBool.EqNode eqNode,
@@ -166,7 +169,7 @@ static Object notString(LocalsStorage self, Object key, ThreadState state,
166169
CompilerDirectives.bailout("accessing locals storage with non-string keys is slow");
167170
VirtualFrame frame = gotState.profile(state == null) ? null : PArguments.frameForCall(state);
168171
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()) {
170173
Object currentKey = slot.getIdentifier();
171174
if (currentKey instanceof String) {
172175
long keyHash = hashNode.execute(frame, currentKey);
@@ -179,7 +182,8 @@ static Object notString(LocalsStorage self, Object key, ThreadState state,
179182
}
180183

181184
@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) {
183187
return self.frame.getFrameDescriptor().findFrameSlot(key);
184188
}
185189
}
@@ -217,9 +221,10 @@ private HashingStorage generalize(HashingStorageLibrary lib, boolean isStringKey
217221
@ExportMessage
218222
@TruffleBoundary
219223
@Override
224+
@SuppressWarnings("deprecation") // new Frame API
220225
public Object forEachUntyped(ForEachNode<Object> node, Object arg) {
221226
Object result = arg;
222-
for (FrameSlot slot : this.frame.getFrameDescriptor().getSlots()) {
227+
for (com.oracle.truffle.api.frame.FrameSlot slot : this.frame.getFrameDescriptor().getSlots()) {
223228
Object identifier = slot.getIdentifier();
224229
if (identifier instanceof String) {
225230
if (isUserFrameSlot(identifier)) {
@@ -235,19 +240,21 @@ public Object forEachUntyped(ForEachNode<Object> node, Object arg) {
235240

236241
@ExportMessage
237242
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]);
240246
}
241247

242248
@Specialization(guards = {"desc == self.frame.getFrameDescriptor()"}, limit = "1", assumptions = "desc.getVersion()")
243249
@ExplodeLoop
250+
@SuppressWarnings("deprecation") // new Frame API
244251
static HashingStorage cached(LocalsStorage self, HashingStorage other,
245252
@CachedLibrary(limit = "2") HashingStorageLibrary lib,
246253
@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) {
248255
HashingStorage result = other;
249256
for (int i = 0; i < slots.length; i++) {
250-
FrameSlot slot = slots[i];
257+
com.oracle.truffle.api.frame.FrameSlot slot = slots[i];
251258
Object value = self.getValue(slot);
252259
if (value != null) {
253260
result = lib.setItem(result, slot.getIdentifier(), value);
@@ -258,12 +265,13 @@ static HashingStorage cached(LocalsStorage self, HashingStorage other,
258265

259266
@Specialization(replaces = "cached")
260267
@TruffleBoundary
268+
@SuppressWarnings("deprecation") // new Frame API
261269
static HashingStorage generic(LocalsStorage self, HashingStorage other,
262270
@CachedLibrary(limit = "2") HashingStorageLibrary lib) {
263271
HashingStorage result = other;
264-
FrameSlot[] slots = getSlots(self.frame.getFrameDescriptor());
272+
com.oracle.truffle.api.frame.FrameSlot[] slots = getSlots(self.frame.getFrameDescriptor());
265273
for (int i = 0; i < slots.length; i++) {
266-
FrameSlot slot = slots[i];
274+
com.oracle.truffle.api.frame.FrameSlot slot = slots[i];
267275
Object value = self.getValue(slot);
268276
if (value != null) {
269277
result = lib.setItem(result, slot.getIdentifier(), value);
@@ -296,12 +304,13 @@ public HashingStorageIterable<Object> reverseKeys() {
296304
return new HashingStorageIterable<>(new ReverseLocalsIterator(this.frame));
297305
}
298306

307+
@SuppressWarnings("deprecation") // new Frame API
299308
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;
301310
protected final int size;
302311
protected int index;
303312
protected final MaterializedFrame frame;
304-
protected FrameSlot nextFrameSlot = null;
313+
protected com.oracle.truffle.api.frame.FrameSlot nextFrameSlot = null;
305314

306315
AbstractLocalsIterator(MaterializedFrame frame) {
307316
this.frame = frame;
@@ -311,7 +320,7 @@ protected abstract static class AbstractLocalsIterator implements Iterator<Objec
311320
}
312321

313322
@TruffleBoundary
314-
private static List<? extends FrameSlot> getSlots(MaterializedFrame frame) {
323+
private static List<? extends com.oracle.truffle.api.frame.FrameSlot> getSlots(MaterializedFrame frame) {
315324
return frame.getFrameDescriptor().getSlots();
316325
}
317326

@@ -348,10 +357,10 @@ public Object next() {
348357
}
349358

350359
@TruffleBoundary
351-
public FrameSlot nextSlot() {
360+
public com.oracle.truffle.api.frame.FrameSlot nextSlot() {
352361
if (hasNext()) {
353362
assert this.nextFrameSlot != null;
354-
FrameSlot value = this.nextFrameSlot;
363+
com.oracle.truffle.api.frame.FrameSlot value = this.nextFrameSlot;
355364
this.nextFrameSlot = null;
356365
return value;
357366
}
@@ -368,9 +377,10 @@ private static final class LocalsIterator extends AbstractLocalsIterator {
368377

369378
@TruffleBoundary
370379
@Override
380+
@SuppressWarnings("deprecation") // new Frame API
371381
protected boolean loadNext() {
372382
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++);
374384
Object identifier = nextCandidate.getIdentifier();
375385
if (identifier instanceof String) {
376386
if (isUserFrameSlot(identifier)) {
@@ -395,9 +405,10 @@ private static final class ReverseLocalsIterator extends AbstractLocalsIterator
395405

396406
@TruffleBoundary
397407
@Override
408+
@SuppressWarnings("deprecation") // new Frame API
398409
protected boolean loadNext() {
399410
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--);
401412
Object identifier = nextCandidate.getIdentifier();
402413
if (identifier instanceof String) {
403414
if (isUserFrameSlot(identifier)) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import com.oracle.truffle.api.RootCallTarget;
4545
import com.oracle.truffle.api.Truffle;
4646
import com.oracle.truffle.api.frame.FrameDescriptor;
47-
import com.oracle.truffle.api.frame.FrameSlot;
4847
import com.oracle.truffle.api.frame.MaterializedFrame;
4948
import com.oracle.truffle.api.library.ExportMessage;
5049
import com.oracle.truffle.api.nodes.ExplodeLoop;
@@ -73,6 +72,7 @@ public final class PGenerator extends PythonBuiltinObject {
7372
// running means it is currently on the stack, not just started
7473
private boolean running;
7574

75+
@SuppressWarnings("deprecation") // new Frame API
7676
public static PGenerator create(PythonLanguage lang, String name, String qualname, RootCallTarget[] callTargets, FrameDescriptor frameDescriptor, Object[] arguments, PCell[] closure,
7777
ExecutionCellSlots cellSlots, GeneratorInfo generatorInfo, PythonObjectFactory factory,
7878
Object iterator) {
@@ -91,9 +91,9 @@ public static PGenerator create(PythonLanguage lang, String name, String qualnam
9191
PArguments.setCurrentFrameInfo(generatorFrameArguments, new PFrame.Reference(null));
9292
// set generator closure to the generator frame locals
9393
CompilerAsserts.partialEvaluationConstant(cellSlots);
94-
FrameSlot[] freeVarSlots = cellSlots.getFreeVarSlots();
94+
com.oracle.truffle.api.frame.FrameSlot[] freeVarSlots = cellSlots.getFreeVarSlots();
9595
CompilerAsserts.partialEvaluationConstant(freeVarSlots);
96-
FrameSlot[] cellVarSlots = cellSlots.getCellVarSlots();
96+
com.oracle.truffle.api.frame.FrameSlot[] cellVarSlots = cellSlots.getCellVarSlots();
9797
CompilerAsserts.partialEvaluationConstant(cellVarSlots);
9898
Assumption[] cellVarAssumptions = cellSlots.getCellVarAssumptions();
9999

@@ -109,7 +109,8 @@ public static PGenerator create(PythonLanguage lang, String name, String qualnam
109109
}
110110

111111
@ExplodeLoop
112-
private static void assignCells(MaterializedFrame generatorFrame, FrameSlot[] cellVarSlots, Assumption[] cellVarAssumptions) {
112+
@SuppressWarnings("deprecation") // new Frame API
113+
private static void assignCells(MaterializedFrame generatorFrame, com.oracle.truffle.api.frame.FrameSlot[] cellVarSlots, Assumption[] cellVarAssumptions) {
113114
// initialize own cell vars to new cells (these cells will be used by nested functions to
114115
// create their own closures)
115116
for (int i = 0; i < cellVarSlots.length; i++) {
@@ -118,7 +119,8 @@ private static void assignCells(MaterializedFrame generatorFrame, FrameSlot[] ce
118119
}
119120

120121
@ExplodeLoop
121-
private static void assignClosure(PCell[] closure, MaterializedFrame generatorFrame, FrameSlot[] freeVarSlots) {
122+
@SuppressWarnings("deprecation") // new Frame API
123+
private static void assignClosure(PCell[] closure, MaterializedFrame generatorFrame, com.oracle.truffle.api.frame.FrameSlot[] freeVarSlots) {
122124
for (int i = 0; i < freeVarSlots.length; i++) {
123125
generatorFrame.setObject(freeVarSlots[i], closure[i]);
124126
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
9797
import com.oracle.truffle.api.dsl.NodeFactory;
9898
import com.oracle.truffle.api.dsl.Specialization;
99-
import com.oracle.truffle.api.frame.FrameSlot;
10099
import com.oracle.truffle.api.frame.VirtualFrame;
101100
import com.oracle.truffle.api.library.CachedLibrary;
102101
import com.oracle.truffle.api.nodes.Node;
@@ -227,8 +226,9 @@ protected boolean isInBuiltinFunctionRoot() {
227226
return getRootNode() instanceof BuiltinFunctionRootNode;
228227
}
229228

229+
@SuppressWarnings("deprecation") // new Frame API
230230
protected ReadLocalVariableNode createRead(VirtualFrame frame) {
231-
FrameSlot slot = frame.getFrameDescriptor().findFrameSlot(SpecialAttributeNames.__CLASS__);
231+
com.oracle.truffle.api.frame.FrameSlot slot = frame.getFrameDescriptor().findFrameSlot(SpecialAttributeNames.__CLASS__);
232232
if (slot == null) {
233233
throw raise(PythonErrorType.RuntimeError, ErrorMessages.SUPER_NO_CLASS);
234234
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ModuleRootNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.oracle.truffle.api.CompilerAsserts;
3838
import com.oracle.truffle.api.CompilerDirectives;
3939
import com.oracle.truffle.api.frame.FrameDescriptor;
40-
import com.oracle.truffle.api.frame.FrameSlot;
4140
import com.oracle.truffle.api.frame.VirtualFrame;
4241
import com.oracle.truffle.api.source.SourceSection;
4342

@@ -49,7 +48,9 @@ public class ModuleRootNode extends PClosureRootNode {
4948
@Child private WriteGlobalNode writeAnnotations;
5049
@Child private CalleeContext calleeContext = CalleeContext.create();
5150

52-
public ModuleRootNode(PythonLanguage language, String name, String doc, ExpressionNode file, FrameDescriptor descriptor, FrameSlot[] freeVarSlots, boolean hasAnnotations) {
51+
@SuppressWarnings("deprecation") // new Frame API
52+
public ModuleRootNode(PythonLanguage language, String name, String doc, ExpressionNode file, FrameDescriptor descriptor, com.oracle.truffle.api.frame.FrameSlot[] freeVarSlots,
53+
boolean hasAnnotations) {
5354
super(language, descriptor, freeVarSlots, hasAnnotations);
5455
if (name.startsWith("<")) {
5556
this.name = "<module>";

0 commit comments

Comments
 (0)