Skip to content

Commit 2518768

Browse files
committed
Revert "Suppressed deprecation warnings for the new Frame API"
This reverts commit 9e999ad.
1 parent 2548852 commit 2518768

33 files changed

+220
-245
lines changed

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

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

131131
@Test
132-
@SuppressWarnings("deprecation") // new Frame API
133132
public void inline01() throws Exception {
134133
FrameDescriptor fd = new FrameDescriptor(44);
135134
fd.addFrameSlot("a");

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
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;
8384
import com.oracle.truffle.api.nodes.Node;
8485
import com.oracle.truffle.api.nodes.NodeVisitor;
8586
import com.oracle.truffle.api.nodes.RootNode;
@@ -482,7 +483,6 @@ private void addSignature(Signature signature) {
482483
level--;
483484
}
484485

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

538-
@SuppressWarnings("deprecation") // new Frame API
539-
private void add(com.oracle.truffle.api.frame.FrameSlot[] slots) {
538+
private void add(FrameSlot[] slots) {
540539
if (slots == null || slots.length == 0) {
541540
sb.append("None");
542541
} else {
543542
boolean first = true;
544-
for (com.oracle.truffle.api.frame.FrameSlot slot : slots) {
543+
for (FrameSlot slot : slots) {
545544
if (!first) {
546545
sb.append(", ");
547546
} else {
@@ -552,8 +551,7 @@ private void add(com.oracle.truffle.api.frame.FrameSlot[] slots) {
552551
}
553552
}
554553

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

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
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;
6465
import com.oracle.truffle.api.nodes.RootNode;
6566
import com.oracle.truffle.api.source.Source;
6667

@@ -1346,14 +1347,13 @@ private static void printSet(StringBuilder sb, Set<String> set) {
13461347
}
13471348
}
13481349

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

13671367
// here we can not use the ScopeInfo.debugPrint(), because we need exclude the temporary
13681368
// variables.
1369-
@SuppressWarnings("deprecation") // new Frame API
13701369
private static void printScope(ScopeInfo scope, StringBuilder sb, int indent) {
13711370
indent(sb, indent);
13721371
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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,11 @@ private static String extractName(RootNode rootNode) {
243243
}
244244

245245
@TruffleBoundary
246-
@SuppressWarnings("deprecation") // new Frame API
247246
private static int extractStackSize(RootNode rootNode) {
248247
return rootNode.getFrameDescriptor().getSize();
249248
}
250249

251250
@TruffleBoundary
252-
@SuppressWarnings("deprecation") // new Frame API
253251
private static Object[] extractVarnames(RootNode rootNode, String[] parameterIds, String[] keywordNames, Object[] freeVars, Object[] cellVars) {
254252
Set<Object> freeVarsSet = asSet(freeVars);
255253
Set<Object> cellVarsSet = asSet(cellVars);

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

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
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;
7071
import com.oracle.truffle.api.frame.MaterializedFrame;
7172
import com.oracle.truffle.api.frame.VirtualFrame;
7273
import com.oracle.truffle.api.library.CachedLibrary;
@@ -76,7 +77,6 @@
7677
import com.oracle.truffle.api.profiles.ConditionProfile;
7778

7879
@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(com.oracle.truffle.api.frame.FrameSlot slot) {
97+
private Object getValue(FrameSlot slot) {
9898
return getValue(this.frame, slot);
9999
}
100100

101-
private static Object getValue(MaterializedFrame frame, com.oracle.truffle.api.frame.FrameSlot slot) {
101+
private static Object getValue(MaterializedFrame frame, FrameSlot slot) {
102102
if (slot != null) {
103103
Object value = frame.getValue(slot);
104104
if (value instanceof PCell) {
@@ -122,34 +122,32 @@ public int length() {
122122
@TruffleBoundary
123123
private void calculateLength() {
124124
this.len = this.frame.getFrameDescriptor().getSize();
125-
for (com.oracle.truffle.api.frame.FrameSlot slot : this.frame.getFrameDescriptor().getSlots()) {
125+
for (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", "deprecation"}) // new frame API
133+
@SuppressWarnings("unused")
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
139138
static Object getItemCached(LocalsStorage self, String key, ThreadState state,
140139
@Cached("key") String cachedKey,
141140
@Cached("self.frame.getFrameDescriptor()") FrameDescriptor desc,
142-
@Cached("desc.findFrameSlot(key)") com.oracle.truffle.api.frame.FrameSlot slot) {
141+
@Cached("desc.findFrameSlot(key)") FrameSlot slot) {
143142
return self.getValue(slot);
144143
}
145144

146145
@Specialization(replaces = "getItemCached")
147-
@SuppressWarnings("deprecation") // new Frame API
148146
static Object string(LocalsStorage self, String key, ThreadState state) {
149147
if (!isUserFrameSlot(key)) {
150148
return null;
151149
}
152-
com.oracle.truffle.api.frame.FrameSlot slot = findSlot(self, key);
150+
FrameSlot slot = findSlot(self, key);
153151
return self.getValue(slot);
154152
}
155153

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

162160
@Specialization(guards = "!isBuiltinString(key, profile)", limit = "1")
163-
@SuppressWarnings("deprecation") // new Frame API
164161
static Object notString(LocalsStorage self, Object key, ThreadState state,
165162
@Shared("builtinProfile") @Cached IsBuiltinClassProfile profile,
166163
@Cached PyObjectRichCompareBool.EqNode eqNode,
@@ -169,7 +166,7 @@ static Object notString(LocalsStorage self, Object key, ThreadState state,
169166
CompilerDirectives.bailout("accessing locals storage with non-string keys is slow");
170167
VirtualFrame frame = gotState.profile(state == null) ? null : PArguments.frameForCall(state);
171168
long hash = hashNode.execute(frame, key);
172-
for (com.oracle.truffle.api.frame.FrameSlot slot : self.frame.getFrameDescriptor().getSlots()) {
169+
for (FrameSlot slot : self.frame.getFrameDescriptor().getSlots()) {
173170
Object currentKey = slot.getIdentifier();
174171
if (currentKey instanceof String) {
175172
long keyHash = hashNode.execute(frame, currentKey);
@@ -182,8 +179,7 @@ static Object notString(LocalsStorage self, Object key, ThreadState state,
182179
}
183180

184181
@TruffleBoundary
185-
@SuppressWarnings("deprecation") // new Frame API
186-
private static com.oracle.truffle.api.frame.FrameSlot findSlot(LocalsStorage self, Object key) {
182+
private static FrameSlot findSlot(LocalsStorage self, Object key) {
187183
return self.frame.getFrameDescriptor().findFrameSlot(key);
188184
}
189185
}
@@ -221,10 +217,9 @@ private HashingStorage generalize(HashingStorageLibrary lib, boolean isStringKey
221217
@ExportMessage
222218
@TruffleBoundary
223219
@Override
224-
@SuppressWarnings("deprecation") // new Frame API
225220
public Object forEachUntyped(ForEachNode<Object> node, Object arg) {
226221
Object result = arg;
227-
for (com.oracle.truffle.api.frame.FrameSlot slot : this.frame.getFrameDescriptor().getSlots()) {
222+
for (FrameSlot slot : this.frame.getFrameDescriptor().getSlots()) {
228223
Object identifier = slot.getIdentifier();
229224
if (identifier instanceof String) {
230225
if (isUserFrameSlot(identifier)) {
@@ -240,21 +235,19 @@ public Object forEachUntyped(ForEachNode<Object> node, Object arg) {
240235

241236
@ExportMessage
242237
static class AddAllToOther {
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]);
238+
protected static FrameSlot[] getSlots(FrameDescriptor desc) {
239+
return desc.getSlots().toArray(new FrameSlot[0]);
246240
}
247241

248242
@Specialization(guards = {"desc == self.frame.getFrameDescriptor()"}, limit = "1", assumptions = "desc.getVersion()")
249243
@ExplodeLoop
250-
@SuppressWarnings("deprecation") // new Frame API
251244
static HashingStorage cached(LocalsStorage self, HashingStorage other,
252245
@CachedLibrary(limit = "2") HashingStorageLibrary lib,
253246
@Exclusive @SuppressWarnings("unused") @Cached("self.frame.getFrameDescriptor()") FrameDescriptor desc,
254-
@Exclusive @Cached(value = "getSlots(desc)", dimensions = 1) com.oracle.truffle.api.frame.FrameSlot[] slots) {
247+
@Exclusive @Cached(value = "getSlots(desc)", dimensions = 1) FrameSlot[] slots) {
255248
HashingStorage result = other;
256249
for (int i = 0; i < slots.length; i++) {
257-
com.oracle.truffle.api.frame.FrameSlot slot = slots[i];
250+
FrameSlot slot = slots[i];
258251
Object value = self.getValue(slot);
259252
if (value != null) {
260253
result = lib.setItem(result, slot.getIdentifier(), value);
@@ -265,13 +258,12 @@ static HashingStorage cached(LocalsStorage self, HashingStorage other,
265258

266259
@Specialization(replaces = "cached")
267260
@TruffleBoundary
268-
@SuppressWarnings("deprecation") // new Frame API
269261
static HashingStorage generic(LocalsStorage self, HashingStorage other,
270262
@CachedLibrary(limit = "2") HashingStorageLibrary lib) {
271263
HashingStorage result = other;
272-
com.oracle.truffle.api.frame.FrameSlot[] slots = getSlots(self.frame.getFrameDescriptor());
264+
FrameSlot[] slots = getSlots(self.frame.getFrameDescriptor());
273265
for (int i = 0; i < slots.length; i++) {
274-
com.oracle.truffle.api.frame.FrameSlot slot = slots[i];
266+
FrameSlot slot = slots[i];
275267
Object value = self.getValue(slot);
276268
if (value != null) {
277269
result = lib.setItem(result, slot.getIdentifier(), value);
@@ -304,13 +296,12 @@ public HashingStorageIterable<Object> reverseKeys() {
304296
return new HashingStorageIterable<>(new ReverseLocalsIterator(this.frame));
305297
}
306298

307-
@SuppressWarnings("deprecation") // new Frame API
308299
protected abstract static class AbstractLocalsIterator implements Iterator<Object> {
309-
protected List<? extends com.oracle.truffle.api.frame.FrameSlot> slots;
300+
protected List<? extends FrameSlot> slots;
310301
protected final int size;
311302
protected int index;
312303
protected final MaterializedFrame frame;
313-
protected com.oracle.truffle.api.frame.FrameSlot nextFrameSlot = null;
304+
protected FrameSlot nextFrameSlot = null;
314305

315306
AbstractLocalsIterator(MaterializedFrame frame) {
316307
this.frame = frame;
@@ -320,7 +311,7 @@ protected abstract static class AbstractLocalsIterator implements Iterator<Objec
320311
}
321312

322313
@TruffleBoundary
323-
private static List<? extends com.oracle.truffle.api.frame.FrameSlot> getSlots(MaterializedFrame frame) {
314+
private static List<? extends FrameSlot> getSlots(MaterializedFrame frame) {
324315
return frame.getFrameDescriptor().getSlots();
325316
}
326317

@@ -357,10 +348,10 @@ public Object next() {
357348
}
358349

359350
@TruffleBoundary
360-
public com.oracle.truffle.api.frame.FrameSlot nextSlot() {
351+
public FrameSlot nextSlot() {
361352
if (hasNext()) {
362353
assert this.nextFrameSlot != null;
363-
com.oracle.truffle.api.frame.FrameSlot value = this.nextFrameSlot;
354+
FrameSlot value = this.nextFrameSlot;
364355
this.nextFrameSlot = null;
365356
return value;
366357
}
@@ -377,10 +368,9 @@ private static final class LocalsIterator extends AbstractLocalsIterator {
377368

378369
@TruffleBoundary
379370
@Override
380-
@SuppressWarnings("deprecation") // new Frame API
381371
protected boolean loadNext() {
382372
while (this.index < this.size) {
383-
com.oracle.truffle.api.frame.FrameSlot nextCandidate = this.slots.get(this.index++);
373+
FrameSlot nextCandidate = this.slots.get(this.index++);
384374
Object identifier = nextCandidate.getIdentifier();
385375
if (identifier instanceof String) {
386376
if (isUserFrameSlot(identifier)) {
@@ -405,10 +395,9 @@ private static final class ReverseLocalsIterator extends AbstractLocalsIterator
405395

406396
@TruffleBoundary
407397
@Override
408-
@SuppressWarnings("deprecation") // new Frame API
409398
protected boolean loadNext() {
410399
while (this.index >= 0) {
411-
com.oracle.truffle.api.frame.FrameSlot nextCandidate = this.slots.get(this.index--);
400+
FrameSlot nextCandidate = this.slots.get(this.index--);
412401
Object identifier = nextCandidate.getIdentifier();
413402
if (identifier instanceof String) {
414403
if (isUserFrameSlot(identifier)) {

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
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;
4748
import com.oracle.truffle.api.frame.MaterializedFrame;
4849
import com.oracle.truffle.api.library.ExportMessage;
4950
import com.oracle.truffle.api.nodes.ExplodeLoop;
@@ -72,7 +73,6 @@ public final class PGenerator extends PythonBuiltinObject {
7273
// running means it is currently on the stack, not just started
7374
private boolean running;
7475

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-
com.oracle.truffle.api.frame.FrameSlot[] freeVarSlots = cellSlots.getFreeVarSlots();
94+
FrameSlot[] freeVarSlots = cellSlots.getFreeVarSlots();
9595
CompilerAsserts.partialEvaluationConstant(freeVarSlots);
96-
com.oracle.truffle.api.frame.FrameSlot[] cellVarSlots = cellSlots.getCellVarSlots();
96+
FrameSlot[] cellVarSlots = cellSlots.getCellVarSlots();
9797
CompilerAsserts.partialEvaluationConstant(cellVarSlots);
9898
Assumption[] cellVarAssumptions = cellSlots.getCellVarAssumptions();
9999

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

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

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

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
@@ -103,6 +103,7 @@
103103
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
104104
import com.oracle.truffle.api.dsl.NodeFactory;
105105
import com.oracle.truffle.api.dsl.Specialization;
106+
import com.oracle.truffle.api.frame.FrameSlot;
106107
import com.oracle.truffle.api.frame.VirtualFrame;
107108
import com.oracle.truffle.api.library.CachedLibrary;
108109
import com.oracle.truffle.api.profiles.ConditionProfile;
@@ -223,9 +224,8 @@ protected boolean isInBuiltinFunctionRoot() {
223224
return getRootNode() instanceof BuiltinFunctionRootNode;
224225
}
225226

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

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
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;
4041
import com.oracle.truffle.api.frame.VirtualFrame;
4142
import com.oracle.truffle.api.source.SourceSection;
4243

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

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) {
52+
public ModuleRootNode(PythonLanguage language, String name, String doc, ExpressionNode file, FrameDescriptor descriptor, FrameSlot[] freeVarSlots, boolean hasAnnotations) {
5453
super(language, descriptor, freeVarSlots, hasAnnotations);
5554
if (name.startsWith("<")) {
5655
this.name = "<module>";

0 commit comments

Comments
 (0)