Skip to content

Commit 9ce7519

Browse files
committed
Pass frame when obtaining next element from an iterator
1 parent 7f66f25 commit 9ce7519

File tree

16 files changed

+216
-258
lines changed

16 files changed

+216
-258
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ static PException report(VirtualFrame frame, Object type,
16601660
@Cached CastToJavaStringNode cast,
16611661
@Cached ListNodes.ConstructListNode constructListNode,
16621662
@Cached PRaiseNode raiseNode) {
1663-
PList list = constructListNode.execute(readAttributeFromObjectNode.execute(type, __ABSTRACTMETHODS__));
1663+
PList list = constructListNode.execute(frame, readAttributeFromObjectNode.execute(type, __ABSTRACTMETHODS__));
16641664
int methodCount = lib.lengthWithFrame(list, frame);
16651665
lib.lookupAndCallRegularMethod(list, frame, "sort");
16661666
String joined = cast.execute(lib.lookupAndCallRegularMethod(", ", frame, "join", list));

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Object locals(VirtualFrame frame, @SuppressWarnings("unused") Object object,
486486

487487
Object localsDict = LocalsNode.getLocalsDict(frame, this, readLocalsNode, readCallerFrameNode, materializeNode, inGenerator);
488488
Object keysObj = callKeysNode.executeObject(frame, localsDict);
489-
PList list = constructListNode.execute(keysObj);
489+
PList list = constructListNode.execute(frame, keysObj);
490490
sortNode.sort(frame, list);
491491
return list;
492492
}
@@ -496,7 +496,7 @@ static Object dir(VirtualFrame frame, Object object,
496496
@Cached ListBuiltins.ListSortNode sortNode,
497497
@Cached ListNodes.ConstructListNode constructListNode,
498498
@CachedLibrary("object") PythonObjectLibrary lib) {
499-
PList list = constructListNode.execute(lib.lookupAndCallSpecialMethod(object, frame, __DIR__));
499+
PList list = constructListNode.execute(frame, lib.lookupAndCallSpecialMethod(object, frame, __DIR__));
500500
sortNode.sort(frame, list);
501501
return list;
502502
}
@@ -1699,7 +1699,7 @@ public abstract static class SortedNode extends PythonBuiltinNode {
16991699
Object sorted(VirtualFrame frame, Object iterable, PKeyword[] keywords,
17001700
@Cached ConstructListNode constructListNode,
17011701
@Cached ListSortNode sortNode) {
1702-
PList list = constructListNode.execute(iterable);
1702+
PList list = constructListNode.execute(frame, iterable);
17031703
sortNode.execute(frame, list, PythonUtils.EMPTY_OBJECT_ARRAY, keywords);
17041704
return list;
17051705
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JArrayModuleBuiltins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
7171
import com.oracle.truffle.api.dsl.NodeFactory;
7272
import com.oracle.truffle.api.dsl.Specialization;
73+
import com.oracle.truffle.api.frame.VirtualFrame;
7374
import com.oracle.truffle.api.interop.InteropLibrary;
7475
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
7576
import com.oracle.truffle.api.interop.UnsupportedMessageException;
@@ -208,14 +209,14 @@ Object fromSequence(PSequence sequence, Object type,
208209
}
209210

210211
@Specialization(guards = "!isPSequence(sequence)")
211-
Object fromIterable(Object sequence, Object type,
212+
Object fromIterable(VirtualFrame frame, Object sequence, Object type,
212213
@Cached ListNodes.ConstructListNode constructListNode,
213214
@CachedLibrary(limit = "5") InteropLibrary lib,
214215
@Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode,
215216
@Cached SequenceStorageNodes.LenNode lenNode,
216217
@Cached SequenceStorageNodes.GetItemScalarNode getItemScalarNode,
217218
@Cached ZerosNode zerosNode) {
218-
PList list = constructListNode.execute(sequence);
219+
PList list = constructListNode.execute(frame, sequence);
219220
return fromSequence(list, type, lib, getSequenceStorageNode, lenNode, getItemScalarNode, zerosNode);
220221
}
221222
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Object[] doSequence(VirtualFrame frame, Object processArgs,
122122
@Cached("createNotNormalized()") GetItemNode getItemNode) {
123123
PSequence argsSequence;
124124
try {
125-
argsSequence = fastConstructListNode.execute(processArgs);
125+
argsSequence = fastConstructListNode.execute(frame, processArgs);
126126
} catch (PException e) {
127127
e.expect(TypeError, isBuiltinClassProfile);
128128
throw raise(TypeError, ErrorMessages.S_MUST_BE_S, "argv", "a tuple");

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private ObjAndFDList seq2set(VirtualFrame frame, Object sequence, PythonObjectLi
187187
// repeatedly in the loop condition
188188
ArrayBuilder<Object> objects = new ArrayBuilder<>();
189189
IntArrayBuilder fds = new IntArrayBuilder();
190-
PSequence pSequence = constructListNode.execute(sequence);
190+
PSequence pSequence = constructListNode.execute(frame, sequence);
191191
boolean containsSocket = false;
192192
for (int i = 0; i < sequenceLib.lengthWithState(sequence, threadState); i++) {
193193
Object pythonObject = callGetItemNode.executeObject(frame, pSequence, i);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,9 @@ Object tobytes(PArray self) {
10861086
@GenerateNodeFactory
10871087
abstract static class ToListNode extends PythonUnaryBuiltinNode {
10881088
@Specialization
1089-
static Object tolist(PArray self,
1089+
static Object tolist(VirtualFrame frame, PArray self,
10901090
@Cached ListNodes.ConstructListNode constructListNode) {
1091-
return constructListNode.execute(self);
1091+
return constructListNode.execute(frame, self);
10921092
}
10931093
}
10941094

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static PNone doItem(VirtualFrame frame, PByteArray self, Object idx, Object valu
197197
}
198198

199199
@Specialization
200-
PNone doSliceSequence(PByteArray self, PSlice slice, PSequence value,
200+
PNone doSliceSequence(VirtualFrame frame, PByteArray self, PSlice slice, PSequence value,
201201
@Cached ConditionProfile differentLenProfile,
202202
@Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode,
203203
@Cached SequenceStorageNodes.SetItemSliceNode setItemSliceNode,
@@ -212,12 +212,12 @@ PNone doSliceSequence(PByteArray self, PSlice slice, PSequence value,
212212
if (differentLenProfile.profile(info.sliceLength != otherLen)) {
213213
self.checkCanResize(this);
214214
}
215-
setItemSliceNode.execute(storage, info, value, false);
215+
setItemSliceNode.execute(frame, storage, info, value, false);
216216
return PNone.NONE;
217217
}
218218

219219
@Specialization(guards = "bufferLib.isBuffer(value)", limit = "3")
220-
PNone doSliceBuffer(PByteArray self, PSlice slice, Object value,
220+
PNone doSliceBuffer(VirtualFrame frame, PByteArray self, PSlice slice, Object value,
221221
@CachedLibrary("value") PythonObjectLibrary bufferLib,
222222
@Cached ConditionProfile differentLenProfile,
223223
@Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode,
@@ -228,14 +228,14 @@ PNone doSliceBuffer(PByteArray self, PSlice slice, Object value,
228228
@Cached SliceLiteralNode.AdjustIndices adjustIndices) {
229229
try {
230230
PBytes bytes = factory().createBytes(bufferLib.getBufferBytes(value));
231-
return doSliceSequence(self, slice, bytes, differentLenProfile, getSequenceStorageNode, setItemSliceNode, sliceCast, lenNode, unpack, adjustIndices);
231+
return doSliceSequence(frame, self, slice, bytes, differentLenProfile, getSequenceStorageNode, setItemSliceNode, sliceCast, lenNode, unpack, adjustIndices);
232232
} catch (UnsupportedMessageException e) {
233233
throw CompilerDirectives.shouldNotReachHere();
234234
}
235235
}
236236

237237
@Specialization(replaces = {"doSliceSequence", "doSliceBuffer"})
238-
PNone doSliceGeneric(PByteArray self, PSlice slice, Object value,
238+
PNone doSliceGeneric(VirtualFrame frame, PByteArray self, PSlice slice, Object value,
239239
@Cached ConditionProfile differentLenProfile,
240240
@Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode,
241241
@Cached SequenceStorageNodes.SetItemSliceNode setItemSliceNode,
@@ -244,8 +244,8 @@ PNone doSliceGeneric(PByteArray self, PSlice slice, Object value,
244244
@Cached SliceLiteralNode.SliceUnpack unpack,
245245
@Cached SliceLiteralNode.AdjustIndices adjustIndices,
246246
@Cached ListNodes.ConstructListNode constructListNode) {
247-
PList values = constructListNode.execute(value);
248-
return doSliceSequence(self, slice, values, differentLenProfile, getSequenceStorageNode, setItemSliceNode, sliceCast, lenNode, unpack, adjustIndices);
247+
PList values = constructListNode.execute(frame, value);
248+
return doSliceSequence(frame, self, slice, values, differentLenProfile, getSequenceStorageNode, setItemSliceNode, sliceCast, lenNode, unpack, adjustIndices);
249249
}
250250

251251
@Fallback

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PySequenceArrayWrapper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ abstract static class WriteArrayItemNode extends Node {
320320
@Specialization
321321
void doBytes(PBytesLike s, long idx, byte value,
322322
@Shared("setByteItemNode") @Cached SequenceStorageNodes.SetItemDynamicNode setByteItemNode) {
323-
setByteItemNode.execute(NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx, value);
323+
setByteItemNode.execute(null, NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx, value);
324324
}
325325

326326
@Specialization
327327
@ExplodeLoop
328328
void doBytes(PBytesLike s, long idx, short value,
329329
@Shared("setByteItemNode") @Cached SequenceStorageNodes.SetItemDynamicNode setByteItemNode) {
330330
for (int offset = 0; offset < Short.BYTES; offset++) {
331-
setByteItemNode.execute(NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx + offset, (byte) (value >> (8 * offset)) & 0xFF);
331+
setByteItemNode.execute(null, NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx + offset, (byte) (value >> (8 * offset)) & 0xFF);
332332
}
333333
}
334334

@@ -337,7 +337,7 @@ void doBytes(PBytesLike s, long idx, short value,
337337
void doBytes(PBytesLike s, long idx, int value,
338338
@Shared("setByteItemNode") @Cached SequenceStorageNodes.SetItemDynamicNode setByteItemNode) {
339339
for (int offset = 0; offset < Integer.BYTES; offset++) {
340-
setByteItemNode.execute(NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx + offset, (byte) (value >> (8 * offset)) & 0xFF);
340+
setByteItemNode.execute(null, NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx + offset, (byte) (value >> (8 * offset)) & 0xFF);
341341
}
342342
}
343343

@@ -346,7 +346,7 @@ void doBytes(PBytesLike s, long idx, int value,
346346
void doBytes(PBytesLike s, long idx, long value,
347347
@Shared("setByteItemNode") @Cached SequenceStorageNodes.SetItemDynamicNode setByteItemNode) {
348348
for (int offset = 0; offset < Long.BYTES; offset++) {
349-
setByteItemNode.execute(NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx + offset, (byte) (value >> (8 * offset)) & 0xFF);
349+
setByteItemNode.execute(null, NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx + offset, (byte) (value >> (8 * offset)) & 0xFF);
350350
}
351351
}
352352

@@ -356,7 +356,7 @@ void doList(PList s, long idx, Object value,
356356
@Cached SequenceStorageNodes.SetItemDynamicNode setListItemNode,
357357
@Cached("createBinaryProfile()") ConditionProfile updateStorageProfile) {
358358
SequenceStorage storage = s.getSequenceStorage();
359-
SequenceStorage updatedStorage = setListItemNode.execute(ListGeneralizationNode.SUPPLIER, storage, idx, toJavaNode.execute(value));
359+
SequenceStorage updatedStorage = setListItemNode.execute(null, ListGeneralizationNode.SUPPLIER, storage, idx, toJavaNode.execute(value));
360360
if (updateStorageProfile.profile(storage != updatedStorage)) {
361361
s.setSequenceStorage(updatedStorage);
362362
}
@@ -366,7 +366,7 @@ void doList(PList s, long idx, Object value,
366366
void doTuple(PTuple s, long idx, Object value,
367367
@Shared("toJavaNode") @Cached ToJavaStealingNode toJavaNode,
368368
@Cached SequenceStorageNodes.SetItemDynamicNode setListItemNode) {
369-
setListItemNode.execute(NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx, toJavaNode.execute(value));
369+
setListItemNode.execute(null, NoGeneralizationNode.DEFAULT, s.getSequenceStorage(), idx, toJavaNode.execute(value));
370370
}
371371

372372
@Specialization

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ Object execute(Object[] arguments,
17861786
try {
17871787
int idx = castToJavaIntExactNode.execute(arguments[2]);
17881788
Object value = asPythonObjectNode.execute(nativeContext, arguments[3]);
1789-
setItemNode.execute(NoGeneralizationNode.DEFAULT, storage, idx, value);
1789+
setItemNode.execute(null, NoGeneralizationNode.DEFAULT, storage, idx, value);
17901790
} catch (CannotCastException e) {
17911791
// fall through
17921792
} catch (PException e) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ public static HashingStorage addSequenceToStorage(VirtualFrame frame, Object ite
701701
try {
702702
while (true) {
703703
Object next = nextNode.execute(frame, it);
704-
PSequence element = createListNode.execute(next);
704+
PSequence element = createListNode.execute(frame, next);
705705
assert element != null;
706706
// This constructs a new list using the builtin type. So, the object cannot
707707
// be subclassed and we can directly call 'len()'.

0 commit comments

Comments
 (0)